输出预测结果

main
鸽子 12 months ago
parent 6f21ab6485
commit 5e3d97c389

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -83,20 +83,19 @@ print(goal2)
import numpy as np
X_eval = np.array([
[16.2, 3.2, 0, 0, 1, 2023],
[17.9, 6.4, 0, 0, 1, 2023],
[15.7, 9.0, 0, 0, 1, 2023],
[19.2, 8.1, 0, 3, 1, 2023],
[11.8, 2.4, 0, 3, 1, 2023]
[16.2, 6.5, 0, 0, 1, 2023],
[15.9, 6.9, 0, 0, 1, 2023],
[19.1, 7.4, 0, 3, 1, 2023],
[13.4, 3.2, 0, 3, 1, 2023]
])
# X_eval = np.array([[6.2,5.1,0,0,1,2023]])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28','2023-12-29','2023-12-30','2023-12-31' ])
result = pd.DataFrame(result, index=['2023-12-28','2023-12-29','2023-12-30','2023-12-31' ])
result = pd.concat((result_eval['eval'], result))
result.index = result.index.map(lambda x: str(x)[:10])
result.columns = ['预测值']
print(result)
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx',mode='a',if_sheet_exists='replace',engine='openpyxl') as writer:
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1229.xlsx',mode='a',if_sheet_exists='replace',engine='openpyxl') as writer:
result.to_excel(writer,sheet_name='丽水')

@ -82,20 +82,19 @@ print(result_eval)
import numpy as np
X_eval = np.array([
[17.3, 2.2, 0, 0, 1, 2023],
[19, 5.5, 0, 0, 1, 2023],
[16, 6.5, 0, 0, 1, 2023],
[19.7, 7.9, 0, 3, 1, 2023],
[11.9, 3.2, 0, 3, 1, 2023]
[17.4, 5.4, 0, 0, 1, 2023],
[15.8, 4.8, 0, 0, 1, 2023],
[19.4, 8.9, 0, 3, 1, 2023],
[13.3, 3.3, 0, 3, 1, 2023]
])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31'])
result = pd.DataFrame(result, index=['2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31'])
result = pd.concat((result_eval['eval'], result))
result.index = result.index.map(lambda x: str(x)[:10])
result.columns = ['预测值']
print(result)
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1229.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
result.to_excel(writer, sheet_name='台州')

@ -81,20 +81,19 @@ loaded_model.load_model('jiaxing.bin')
import numpy as np
X_eval = np.array([
[13.8, 2.1, 0, 0, 1, 2023],
[12.1, 1.7, 0, 0, 1, 2023],
[10.3, 3.0, 0, 0, 1, 2023],
[12.1, 7.1, 0, 3, 1, 2023],
[8.2, 1.3, 0, 3, 1, 2023]
[10.7, 0.9, 0, 0, 1, 2023],
[9.8, 4.5, 0, 0, 1, 2023],
[11.2, 5.3, 0, 3, 1, 2023],
[9.0, 2.1, 0, 3, 1, 2023]
])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31'])
result = pd.DataFrame(result, index=['2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31'])
result = pd.concat((result_eval['eval'], result))
result.index = result.index.map(lambda x: str(x)[:10])
result.columns = ['预测值']
print(result)
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1229.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
result.to_excel(writer, sheet_name='嘉兴')

@ -80,21 +80,19 @@ print(result_eval)
import numpy as np
X_eval = np.array([
[16.0, 3.0, 0, 0, 1, 2023],
[14.8, 5.0, 0, 0, 1, 2023],
[12.8, 4.8, 0, 0, 1, 2023],
[20.9, 6.8, 0, 3, 1, 2023],
[9.5, 2.6, 0, 3, 1, 2023]
[14.4, 3.7, 0, 0, 1, 2023],
[12.6, 5.5, 0, 0, 1, 2023],
[16.4, 7.6, 0, 3, 1, 2023],
[10.9, 3.7, 0, 3, 1, 2023]
])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31'])
result = pd.DataFrame(result, index=['2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31'])
result = pd.concat((result_eval['eval'], result))
result.index = result.index.map(lambda x: str(x)[:10])
result.columns = ['预测值']
print(result)
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1229.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
result.to_excel(writer, sheet_name='宁波')

@ -86,20 +86,19 @@ print(result_eval)
print('r2:', r2_score(y_test, y_pred))
X_eval = np.array([
[14.9, 0.3, 0, 0, 1, 2023],
[14.3, 1.2, 0, 0, 1, 2023],
[10.6, 2.7, 0, 0, 1, 2023],
[17.2, 2.7, 0, 3, 1, 2023],
[10.7, 0.6, 0, 3, 1, 2023]
[13.8, 1.4, 0, 0, 1, 2023],
[10.1, 2.7, 0, 0, 1, 2023],
[15.3, 6.3, 0, 3, 1, 2023],
[12.2, 1.8, 0, 3, 1, 2023]
])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31'])
result = pd.DataFrame(result, index=['2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31'])
result = pd.concat((result_eval['eval'], result))
result.index = result.index.map(lambda x: str(x)[:10])
result.columns = ['预测值']
print(result)
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1229.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
result.to_excel(writer, sheet_name='杭州')

@ -83,20 +83,19 @@ print(result_eval)
import numpy as np
X_eval = np.array([
[18, 3.3, 0, 0, 1, 2023],
[18.8, 8.2, 0, 0, 1, 2023],
[16.9, 11.2, 0, 0, 1, 2023],
[20.7, 11.6, 0, 3, 1, 2023],
[14.5, 3.3, 0, 3, 1, 2023]
[19.0, 7.1, 0, 0, 1, 2023],
[17.2, 8.2, 0, 0, 1, 2023],
[19.9, 11.0, 0, 3, 1, 2023],
[15.8, 4.2, 0, 3, 1, 2023]
])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31'])
result = pd.DataFrame(result, index=['2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31'])
result = pd.concat((result_eval['eval'], result))
result.index = result.index.map(lambda x: str(x)[:10])
result.columns = ['预测值']
print(result)
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1229.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
result.to_excel(writer, sheet_name='温州')

@ -83,21 +83,19 @@ print(result_eval)
import numpy as np
X_eval = np.array([
[12.9, 2.1, 0, 0, 1, 2023],
[11.7, 2.2, 0, 0, 1, 2023],
[8, 1.9, 0, 0, 1, 2023],
[13, 4.4, 0, 3, 1, 2023],
[9.7, 0.7, 0, 3, 1, 2023]
[10.6, 1.7, 0, 0, 1, 2023],
[9.1, 3.7, 0, 0, 1, 2023],
[11, 5.1, 0, 3, 1, 2023],
[11.0, 1.5, 0, 3, 1, 2023]
])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31'])
result = pd.DataFrame(result, index=['2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31'])
result = pd.concat((result_eval['eval'], result))
result.index = result.index.map(lambda x: str(x)[:10])
result.columns = ['预测值']
print(result)
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1229.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
result.to_excel(writer, sheet_name='湖州')

@ -79,21 +79,19 @@ print(result_eval)
import numpy as np
X_eval = np.array([
[15.4, 0.1, 0, 0, 1, 2023],
[14.2, 3.5, 0, 0, 1, 2023],
[12.8, 4.6, 0, 0, 1, 2023],
[19.7, 5.2, 0, 3, 1, 2023],
[10.9, 0.8, 0, 3, 1, 2023]
[13.5, 3.2, 0, 0, 1, 2023],
[12.3, 4.2, 0, 0, 1, 2023],
[16.4, 6.2, 0, 3, 1, 2023],
[12.2, 2.1, 0, 3, 1, 2023]
])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31'])
result = pd.DataFrame(result, index=['2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31'])
result = pd.concat((result_eval['eval'],result))
result.index = result.index.map(lambda x:str(x)[:10])
result.columns = ['预测值']
print(result)
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1229.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
result.to_excel(writer, sheet_name='绍兴')

@ -74,20 +74,19 @@ print(result_eval)
import numpy as np
X_eval = np.array([
[15.1, 8.2, 0, 0, 1, 2023],
[12.5, 8.5, 0, 0, 1, 2023],
[12, 8.0, 0, 0, 1, 2023],
[15.0, 10.0, 0, 3, 1, 2023],
[9.3, 5.9, 0, 3, 1, 2023]
[12.3, 8.4, 0, 0, 1, 2023],
[13.3, 7.9, 0, 0, 1, 2023],
[13.0, 10.6, 0, 3, 1, 2023],
[10.5, 6.1, 0, 3, 1, 2023]
])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31'])
result = pd.DataFrame(result, index=['2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31'])
result = pd.concat((result_eval['eval'], result))
result.index = result.index.map(lambda x: str(x)[:10])
result.columns = ['预测值']
print(result)
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1229.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
result.to_excel(writer, sheet_name='舟山')

@ -69,21 +69,20 @@ print(result_eval)
import numpy as np
X_eval = np.array([
[15.0, 3.0, 0, 0, 1, 2023],
[15.7, 5.1, 0, 0, 1, 2023],
[15.2, 5.6, 0, 0, 1, 2023],
[17.9, 6.8, 0, 3, 1, 2023],
[12.0, 2.9, 0, 3, 1, 2023]
[15.7, 4.5, 0, 0, 1, 2023],
[16.0, 4.8, 0, 0, 1, 2023],
[17.0, 7.4, 0, 3, 1, 2023],
[12.9, 4.1, 0, 3, 1, 2023]
])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31'])
result = pd.DataFrame(result, index=['2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31'])
result = pd.concat((result_eval['eval'],result))
result.index = result.index.map(lambda x:str(x)[:10])
result.columns = ['预测值']
print(result)
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1229.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
result.to_excel(writer, sheet_name='衢州')

@ -74,20 +74,19 @@ print(result_eval)
import numpy as np
X_eval = np.array([
[16.3, 2.5, 0, 0, 1],
[16.9, 3.8, 0, 0, 1],
[16.5, 6.2, 0, 0, 1],
[18.8, 7.8, 0, 3, 1],
[12.5, 2.8, 0, 3, 1]
[16.8, 3.2, 0, 0, 1],
[17.2, 5.3, 0, 0, 1],
[17.2, 6.4, 0, 3, 1],
[13.9, 4.0, 0, 3, 1]
])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31'])
result = pd.DataFrame(result, index=['2023-12-28', '2023-12-29', '2023-12-30', '2023-12-31'])
result = pd.concat((result_eval['eval'],result))
result.index = result.index.map(lambda x:str(x)[:10])
result.columns = ['预测值']
print(result)
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1229.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
result.to_excel(writer, sheet_name='金华')

@ -1,6 +1,6 @@
import pandas as pd
df = pd.read_excel(r'C:\Users\鸽子\Desktop\zj20231228.xlsx', sheet_name=1)
df = pd.read_excel(r'C:\Users\鸽子\Desktop\20231229.xlsx', sheet_name=1)
df['pt_date'] = pd.to_datetime(df['pt_date'])
# 移动平均
@ -21,7 +21,7 @@ for city in df['city_name'].drop_duplicates():
# index_level.append(level)
df_moving_avg = pd.DataFrame(df_city1[level], index=df_city1.index)
future = pd.date_range(start='2023-12-27', periods=5, freq='D')
future = pd.date_range(start='2023-12-28', periods=4, freq='D')
for date in future:
df_moving_avg.loc[date, level] = df_moving_avg[-3:].mean().values
@ -38,7 +38,7 @@ for city in df['city_name'].drop_duplicates():
# index=index_level)
# resut_df = pd.DataFrame({'预测电量': pred_list},index=index_level)
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市分压电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市分压电量预测_1229.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
resut_df.to_excel(writer, sheet_name=f'{city[4:6]}')

@ -1,12 +1,11 @@
import pandas as pd
df = pd.read_excel(r'C:\Users\鸽子\Desktop\zj20231228.xlsx', sheet_name=2)
df = pd.read_excel(r'C:\Users\鸽子\Desktop\20231229.xlsx', sheet_name=2)
df['stat_date'] = pd.to_datetime(df['stat_date'])
# 移动平均
for city in df['city_name'].drop_duplicates():
print(city)
df_city = df[df['city_name'] == city].set_index('stat_date').loc['2023-12'].sort_index()
dict_big = {}
dict_ok = {}
@ -20,7 +19,7 @@ for city in df['city_name'].drop_duplicates():
for industry in df_city.columns[2:]:
# index_industry.append(industry)
df_moving_avg = pd.DataFrame(df_city[industry], index=df_city.index)
future = pd.date_range(start='2023-12-27', periods=5, freq='D')
future = pd.date_range(start='2023-12-28', periods=4, freq='D')
for date in future:
df_moving_avg.loc[date, industry] = df_moving_avg[-3:].mean().values
@ -32,7 +31,7 @@ for city in df['city_name'].drop_duplicates():
# pred_list.append(df_moving_avg[industry].sum())
# loss_list.append(df_city1[industry].sum()-df_moving_avg[industry].sum())
# rate_list.append((df_city1[industry].sum()-df_moving_avg[industry].sum())/df_city1[industry].sum())
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\行业电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\行业电量预测_1229.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
resut_df.to_excel(writer, sheet_name=f'{city[4:6]}')

Loading…
Cancel
Save