├── README.md ├── README.txt ├── data └── STLF_DATA_IN_1.xls ├── img ├── accu_box.png ├── accu_scatter.png ├── load_boxplot.png ├── real_pred.png ├── real_pred1.png ├── train_test_accu.png ├── train_test_mse.png ├── weather_type.png └── weather_type2.png ├── src ├── LF_Forecasting.ipynb ├── model.pt └── predict.py ├── 电力系统短期负荷预测.pdf └── 电力系统短期负荷预测.pptx /README.md: -------------------------------------------------------------------------------- 1 | ## 需要使用的python库 2 | 1. pytorch 3 | 2. pandas 4 | 3. numpy 5 | 4. matplotlib 6 | 5. xlwt 7 | 用于导出excel文件 8 | 6. chinese_calendar 9 | 用于获得节假日信息,pip install chinesecalendar 10 | 11 | ## 各文件信息 12 | 1. ./data/STLF_DATA_IN_1.xls 数据集 13 | 2. ./src/LF_Forecasting.ipynb 数据预处理、模型搭建&训练、结果分析 14 | 3. ./src/model.th 最终训练好的模型 15 | 4. ./src/predict.py 用于预测某一天的负荷曲线 16 | 6. ./img 项目过程中的图片 -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | ## 需要使用的python库 2 | 1. pytorch 3 | 2. pandas 4 | 3. numpy 5 | 4. matplotlib 6 | 5. xlwt 7 | 用于导出excel文件 8 | 6. chinese_calendar 9 | 用于获得节假日信息,pip install chinesecalendar 10 | 11 | ## 各文件信息 12 | 1. ./data/STLF_DATA_IN_1.xls 数据集 13 | 2. ./src/LF_Forecasting.ipynb 数据预处理、模型搭建&训练、结果分析 14 | 3. ./src/model.th 最终训练好的模型 15 | 4. ./src/predict.py 用于预测某一天的负荷曲线 16 | 6. ./img 项目过程中的图片 -------------------------------------------------------------------------------- /data/STLF_DATA_IN_1.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TNTmohan/LFforecast/f809093456906d11b78228b501b43a2fd30ebf11/data/STLF_DATA_IN_1.xls -------------------------------------------------------------------------------- /img/accu_box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TNTmohan/LFforecast/f809093456906d11b78228b501b43a2fd30ebf11/img/accu_box.png -------------------------------------------------------------------------------- /img/accu_scatter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TNTmohan/LFforecast/f809093456906d11b78228b501b43a2fd30ebf11/img/accu_scatter.png -------------------------------------------------------------------------------- /img/load_boxplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TNTmohan/LFforecast/f809093456906d11b78228b501b43a2fd30ebf11/img/load_boxplot.png -------------------------------------------------------------------------------- /img/real_pred.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TNTmohan/LFforecast/f809093456906d11b78228b501b43a2fd30ebf11/img/real_pred.png -------------------------------------------------------------------------------- /img/real_pred1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TNTmohan/LFforecast/f809093456906d11b78228b501b43a2fd30ebf11/img/real_pred1.png -------------------------------------------------------------------------------- /img/train_test_accu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TNTmohan/LFforecast/f809093456906d11b78228b501b43a2fd30ebf11/img/train_test_accu.png -------------------------------------------------------------------------------- /img/train_test_mse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TNTmohan/LFforecast/f809093456906d11b78228b501b43a2fd30ebf11/img/train_test_mse.png -------------------------------------------------------------------------------- /img/weather_type.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TNTmohan/LFforecast/f809093456906d11b78228b501b43a2fd30ebf11/img/weather_type.png -------------------------------------------------------------------------------- /img/weather_type2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TNTmohan/LFforecast/f809093456906d11b78228b501b43a2fd30ebf11/img/weather_type2.png -------------------------------------------------------------------------------- /src/model.pt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TNTmohan/LFforecast/f809093456906d11b78228b501b43a2fd30ebf11/src/model.pt -------------------------------------------------------------------------------- /src/predict.py: -------------------------------------------------------------------------------- 1 | from torch import load, Tensor 2 | import pandas as pd 3 | import numpy as np 4 | from chinese_calendar import is_holiday 5 | import matplotlib.pyplot as plt 6 | import warnings 7 | 8 | warnings.simplefilter('ignore') 9 | 10 | print('Loading data...') 11 | df_load = pd.read_excel('../data/STLF_DATA_IN_1.xls', sheet_name=0, header=None) 12 | df_weather = pd.read_excel('../data/STLF_DATA_IN_1.xls', sheet_name=1, header=None) 13 | 14 | 15 | predict_date = int(input('请输入待预测日(示例:20080605):')) 16 | date = pd.to_datetime(predict_date, format='%Y%m%d') 17 | load_index = df_load.loc[df_load[0] == predict_date].index.item() 18 | load_data = df_load.iloc[load_index-7:load_index, 1:].values.reshape((1, -1)) / 7000 19 | 20 | 21 | max_tempe = df_weather.loc[(df_weather[0] == predict_date) & (df_weather[1] == '最高温度'), [2]].values / 20 22 | min_tempe = df_weather.loc[(df_weather[0] == predict_date) & (df_weather[1] == '最低温度'), [2]].values / 20 23 | avg_tempe = df_weather.loc[(df_weather[0] == predict_date) & (df_weather[1] == '平均温度'), [2]].values / 20 24 | humidity = df_weather.loc[(df_weather[0] == predict_date) & (df_weather[1] == '湿度'), [2]].values / 100 25 | weather_data = np.concatenate([max_tempe, min_tempe, avg_tempe, humidity]).reshape((1, -1)) 26 | 27 | 28 | type_of_day = np.eye(7)[date.dayofweek] 29 | holiday = np.eye(2)[int(is_holiday(date))] 30 | time_data = np.concatenate([type_of_day, holiday]).reshape((1, -1)) 31 | 32 | 33 | features = np.concatenate([load_data, weather_data, time_data], axis=1).reshape(1, 685) 34 | features = Tensor(features) 35 | 36 | print('Loading model...') 37 | net = load('./model.pt', map_location='cpu') 38 | 39 | print('Start predicting...') 40 | net.eval() 41 | labels = net(features).detach().numpy() * 7000 42 | 43 | print('Start ploting...') 44 | plt.figure(figsize=(10, 8)) 45 | plt.title(predict_date) 46 | plt.xlabel('Time') 47 | plt.ylabel('Load/MW') 48 | plt.plot(labels.reshape(96)) 49 | plt.grid() 50 | 51 | print('Done!') 52 | 53 | -------------------------------------------------------------------------------- /电力系统短期负荷预测.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TNTmohan/LFforecast/f809093456906d11b78228b501b43a2fd30ebf11/电力系统短期负荷预测.pdf -------------------------------------------------------------------------------- /电力系统短期负荷预测.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TNTmohan/LFforecast/f809093456906d11b78228b501b43a2fd30ebf11/电力系统短期负荷预测.pptx --------------------------------------------------------------------------------