输出预测结果

main
鸽子 11 months ago
parent fcff6a72f3
commit 6f21ab6485

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,19 +83,20 @@ print(goal2)
import numpy as np
X_eval = np.array([
[11.59, 0.6, 0, 0, 1, 2023],
[16.6, 2.4, 0, 0, 1, 2023],
[15.5, 6.7, 0, 0, 1, 2023],
[15, 9.4, 0, 0, 1, 2023],
[18.6, 7.5, 0, 1, 1, 2023]
[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]
])
# 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-26', '2023-12-27', '2023-12-28','2023-12-29','2023-12-30'])
result = pd.DataFrame(result, index=['2023-12-27', '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\市区日电量预测_1227.xlsx',mode='a',if_sheet_exists='replace',engine='openpyxl') as writer:
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx',mode='a',if_sheet_exists='replace',engine='openpyxl') as writer:
result.to_excel(writer,sheet_name='丽水')

@ -82,20 +82,20 @@ print(result_eval)
import numpy as np
X_eval = np.array([
[13.1, -0.7, 0, 0, 1, 2023],
[17.9, 2.8, 0, 0, 1, 2023],
[15.8, 7.6, 0, 0, 1, 2023],
[15.9, 8, 0, 0, 1, 2023],
[19.7, 7.8, 0, 1, 1, 2023]
[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]
])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30'])
result = pd.DataFrame(result, index=['2023-12-27', '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\市区日电量预测_1227.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
result.to_excel(writer, sheet_name='台州')

@ -81,20 +81,20 @@ loaded_model.load_model('jiaxing.bin')
import numpy as np
X_eval = np.array([
[10.7, -2.2, 0, 0, 1, 2023],
[12.8, 2.2, 0, 0, 1, 2023],
[11.7, 2.3, 0, 0, 1, 2023],
[13, 1, 0, 0, 1, 2023],
[11.5, 5.8, 0, 1, 1, 2023]
[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]
])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30'])
result = pd.DataFrame(result, index=['2023-12-27', '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\市区日电量预测_1227.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
result.to_excel(writer, sheet_name='嘉兴')

@ -81,20 +81,20 @@ import numpy as np
X_eval = np.array([
[12.9, -2.9, 0, 0, 1, 2023],
[16.4, 3.4, 0, 0, 1, 2023],
[12.8, 4.9, 0, 0, 1, 2023],
[12.9, 4.6, 0, 0, 1, 2023],
[17.9, 6.4, 0, 1, 1, 2023]
[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]
])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30'])
result = pd.DataFrame(result, index=['2023-12-27', '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\市区日电量预测_1227.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
result.to_excel(writer, sheet_name='宁波')

@ -37,7 +37,7 @@ parent_dir = os.path.abspath(os.path.join(os.getcwd(), os.pardir))
data = pd.read_excel(os.path.join(parent_dir, '入模数据/杭州.xlsx'))
data['dtdate'] = pd.to_datetime(data['dtdate'], format='%Y-%m-%d')
data['year'] = data['dtdate'].dt.year
# data.index = pd.to_datetime(data.index, format='%Y-%m-%d')
data.set_index('dtdate', inplace=True)
data = data.loc[normal(data['售电量']).index]
@ -58,7 +58,6 @@ data = data.loc[normal(data['售电量']).index]
data['season'] = data.index.map(season)
df_train = data[-180:]
df_eval = data.loc['2023-12']
print(df_train)
@ -87,20 +86,20 @@ print(result_eval)
print('r2:', r2_score(y_test, y_pred))
X_eval = np.array([
[11.8, -2.8, 0, 0, 1, 2023],
[15.1, 0.2, 0, 0, 1, 2023],
[12.9, 2.2, 0, 0, 1, 2023],
[11.4, 1.3, 0, 0, 1, 2023],
[14.8, 3.6, 0, 1, 1, 2023]
[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]
])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30'])
result = pd.DataFrame(result, index=['2023-12-27', '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\市区日电量预测_1227.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
result.to_excel(writer, sheet_name='杭州')

@ -83,20 +83,20 @@ print(result_eval)
import numpy as np
X_eval = np.array([
[13.7, -0.1, 0, 0, 1, 2023],
[18.9, 3.4, 0, 0, 1, 2023],
[16.3, 11.3, 0, 0, 1, 2023],
[16.6, 9.7, 0, 0, 1, 2023],
[20.6, 20.2, 0, 1, 1, 2023]
[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]
])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30'])
result = pd.DataFrame(result, index=['2023-12-27', '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\市区日电量预测_1227.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
result.to_excel(writer, sheet_name='温州')

@ -84,20 +84,20 @@ import numpy as np
X_eval = np.array([
[9.7, -2.3, 0, 0, 1, 2023],
[13.1, 0.8, 0, 0, 1, 2023],
[10.3, 5.8, 0, 0, 1, 2023],
[10.1, 0.1, 0, 0, 1, 2023],
[12.8, 5.1, 0, 1, 1, 2023]
[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]
])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30'])
result = pd.DataFrame(result, index=['2023-12-27', '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\市区日电量预测_1227.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
result.to_excel(writer, sheet_name='湖州')

@ -80,20 +80,20 @@ import numpy as np
X_eval = np.array([
[13.1, -3.5, 0, 0, 1, 2023],
[15.6, 0.1, 0, 0, 1, 2023],
[13.2, 3.6, 0, 0, 1, 2023],
[14.4, 3.2, 0, 0, 1, 2023],
[15.5, 5.3, 0, 1, 1, 2023]
[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]
])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30'])
result = pd.DataFrame(result, index=['2023-12-27', '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\市区日电量预测_1227.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
result.to_excel(writer, sheet_name='绍兴')

@ -74,20 +74,20 @@ print(result_eval)
import numpy as np
X_eval = np.array([
[11.4, 5.1, 0, 0, 1, 2023],
[15.5, 9.1, 0, 0, 1, 2023],
[11, 7.9, 0, 0, 1, 2023],
[12.7, 7.2, 0, 0, 1, 2023],
[16, 10.3, 0, 1, 1, 2023]
[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]
])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30'])
result = pd.DataFrame(result, index=['2023-12-27', '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\市区日电量预测_1227.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
result.to_excel(writer, sheet_name='舟山')

@ -69,21 +69,21 @@ print(result_eval)
import numpy as np
X_eval = np.array([
[11.7, -0.8, 0, 0, 1, 2023],
[15.2, 3.0, 0, 0, 1, 2023],
[14.8, 5.3, 0, 0, 1, 2023],
[15.1, 5.7, 0, 0, 1, 2023],
[17.5, 7.5, 0, 1, 1, 2023]
[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]
])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30'])
result = pd.DataFrame(result, index=['2023-12-27', '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\市区日电量预测_1227.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
result.to_excel(writer, sheet_name='衢州')

@ -74,20 +74,20 @@ print(result_eval)
import numpy as np
X_eval = np.array([
[11.7, -0.8, 0, 0, 1],
[15.2, 3.0, 0, 0, 1],
[14.8, 5.3, 0, 0, 1],
[15.1, 5.7, 0, 0, 1],
[17.5, 7.5, 0, 1, 1]
[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]
])
print(model.predict(X_eval))
result = model.predict(X_eval)
result = pd.DataFrame(result, index=['2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29', '2023-12-30'])
result = pd.DataFrame(result, index=['2023-12-27', '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\市区日电量预测_1227.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市区日电量预测_1228.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\浙江power1225.xlsx', sheet_name=1)
df = pd.read_excel(r'C:\Users\鸽子\Desktop\zj20231228.xlsx', sheet_name=1)
df['pt_date'] = pd.to_datetime(df['pt_date'])
# 移动平均
@ -9,7 +9,7 @@ dict_ok = {}
for city in df['city_name'].drop_duplicates():
df_city1 = df[(df['city_name'] == city) & (df['county_name'].isnull())].set_index('pt_date').loc['2023-12']
df_city1 = df[(df['city_name'] == city) & (df['county_name'].isnull())].set_index('pt_date').loc['2023-12'].sort_index()
resut_df = pd.DataFrame({})
index_level = []
tq_list = []
@ -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-26', periods=5, freq='D')
future = pd.date_range(start='2023-12-27', periods=5, 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\市分压电量预测_1227.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\市分压电量预测_1228.xlsx', mode='a', if_sheet_exists='replace',
engine='openpyxl') as writer:
resut_df.to_excel(writer, sheet_name=f'{city[4:6]}')

@ -1,14 +1,13 @@
import pandas as pd
df = pd.read_excel(r'C:\Users\鸽子\Desktop\浙江power1225.xlsx', sheet_name=2)
df = pd.read_excel(r'C:\Users\鸽子\Desktop\zj20231228.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']
df_city = df[df['city_name'] == city].set_index('stat_date').loc['2023-12'].sort_index()
dict_big = {}
dict_ok = {}
resut_df = pd.DataFrame({})
@ -21,7 +20,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-26', periods=5, freq='D')
future = pd.date_range(start='2023-12-27', periods=5, freq='D')
for date in future:
df_moving_avg.loc[date, industry] = df_moving_avg[-3:].mean().values
@ -33,7 +32,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\行业电量预测_1227.xlsx', mode='a', if_sheet_exists='replace',
with pd.ExcelWriter(r'C:\Users\鸽子\Desktop\行业电量预测_1228.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