一.代码流程(运行视频:短期光伏发电量短期预测(Python代码,基于LSTM模型)_哔哩哔哩_bilibili)

  1. 数据预处理:

    • 读取CSV文件,并使用Pandas库将数据加载到DataFrame中。
    • 将时间列转换为日期时间格式。
    • 对数据进行重采样和插值,将数据转换为每分钟的数据。
    • 将数据保存到CSV文件中,并重新读取为新的DataFrame。
  2. 数据预处理和模型训练:

    • 使用MinMaxScaler进行数据归一化。
    • 将数据分为训练集和测试集,并创建时间序列数据的输入序列和输出标签。
    • 使用LSTM模型进行序列建模,训练模型并评估损失。
  3. 预测和评估:

    • 对测试数据进行预测,并将预测结果逆转换为原始数据的范围。
    • 绘制实际数据和预测结果的图形,以比较它们之间的差异。

二.数据集(68779条数据)

这些数据是在印度的两个太阳能发电厂收集的,时间跨度为34天。每对文件包含一个电力发电数据集和一个传感器读数数据集。电力发电数据集是在逆变器级别收集的,每个逆变器都连接着多行太阳能电池板。传感器数据是在发电厂级别收集的,是单个传感器阵列在发电厂中的最佳放置。

  • DATE_TIME: 表示日期和时间的时间戳,记录数据采集的具体时间点。
  • PLANT_ID: 发电厂的唯一标识符,用于区分不同的太阳能发电厂。
  • SOURCE_KEY: 太阳能发电设备的唯一标识符,用于区分不同的发电设备。
  • DC_POWER: 直流功率的测量值,表示从太阳能电池板产生的直流电功率。
  • AC_POWER: 交流功率的测量值,表示从逆变器转换后的交流电功率。
  • DAILY_YIELD: 每天的发电量,表示在给定日期内生成的总电量。
  • TOTAL_YIELD: 总发电量,表示从安装以来生成的总电量。

这些列提供了关于太阳能发电厂的重要信息,包括发电设备的功率输出、每天的发电量以及总发电量。通过这些数据,可以进行发电量的分析、设备性能的评估以及故障检测等任务。

开始时间

DATE_TIMEPLANT_IDSOURCE_KEYDC_POWERAC_POWERDAILY_YIELDTOTAL_YIELD
15-05-2020 00:0041350011BY6WEcLGh8j5v70006259559
15-05-2020 00:0041350011IF53ai7Xc0U56Y0006183645
15-05-2020 00:0041350013PZuoBAID5Wc2HD0006987759
15-05-2020 00:0041350017JYdWkrLSPkdwr40007602960
15-05-2020 00:004135001McdE0feGgRqW7Ca0007158964
15-05-2020 00:004135001VHMLBKoKgIrUVDU0007206408
15-05-2020 00:004135001WRmjgnKYAwPKWDb0007028673
15-05-2020 00:004135001ZnxXDlPa8U1GXgE0006522172
15-05-2020 00:004135001ZoEaEvLYb1n2sOq0007098099
15-05-2020 00:004135001adLQvlD726eNBSB0006271355
15-05-2020 00:004135001bvBOhCH3iADSZry0006316803
15-05-2020 00:004135001iCRJl6heRkivqQ30007177992
15-05-2020 00:004135001ih0vzX44oOqAx2f0006185184
15-05-2020 00:004135001pkci93gMrogZuBj0007169102
15-05-2020 00:004135001rGa61gmuvPhdLxV0007111493
15-05-2020 00:004135001sjndEbLyjtCKgGv0007016832
15-05-2020 00:004135001uHbuxQJl8lW7ozc0007038681
15-05-2020 00:004135001wCURE6d3bPkepu20006782598
15-05-2020 00:004135001z9Y9gH1T5YWrNuG0007007866
15-05-2020 00:004135001zBIq5rxdHJRwDNY0006339380
15-05-2020 00:004135001zVJPv84UY57bAof0007116151
15-05-2020 00:1541350011BY6WEcLGh8j5v70006259559
15-05-2020 00:1541350011IF53ai7Xc0U56Y0006183645
15-05-2020 00:1541350013PZuoBAID5Wc2HD0006987759
15-05-2020 00:1541350017JYdWkrLSPkdwr40007602960
15-05-2020 00:154135001McdE0feGgRqW7Ca0007158964
15-05-2020 00:154135001VHMLBKoKgIrUVDU0007206408
15-05-2020 00:154135001WRmjgnKYAwPKWDb0007028673
15-05-2020 00:154135001ZnxXDlPa8U1GXgE0006522172

中期时间段数据展示

20-05-2020 06:454135001uHbuxQJl8lW7ozc947.87592.087540.257071238.25
20-05-2020 06:454135001wCURE6d3bPkepu2944.2591.72541.256815390.25
20-05-2020 06:454135001z9Y9gH1T5YWrNuG953.87592.662540.3757040505.375
20-05-2020 06:454135001zBIq5rxdHJRwDNY936.759139.6256372010.625
20-05-2020 06:454135001zVJPv84UY57bAof933.62590.67540.1257148377.125
20-05-2020 07:0041350011BY6WEcLGh8j5v71564.714286152.9571429686290165
20-05-2020 07:0041350011IF53ai7Xc0U56Y1790.375175.237576.6256216506.625
20-05-2020 07:0041350013PZuoBAID5Wc2HD1728.714286169.157142973.714285717020585.714
20-05-2020 07:0041350017JYdWkrLSPkdwr41690.571429165.428571474.857142867635282.857
20-05-2020 07:004135001McdE0feGgRqW7Ca1628.714286159.257142971.428571437192169.429
20-05-2020 07:004135001VHMLBKoKgIrUVDU1727.428571169.042857176.571428577239618.571
20-05-2020 07:004135001WRmjgnKYAwPKWDb1700166.357142972.571428577061004.571
20-05-2020 07:004135001YxYtjZvoooNbGkE1593.857143155.7857143707212546
20-05-2020 07:004135001ZnxXDlPa8U1GXgE1638.428571160.185714359.571428576555195.571
20-05-2020 07:004135001ZoEaEvLYb1n2sOq1567153.185714369.571428577130401.571
20-05-2020 07:004135001adLQvlD726eNBSB1818.12517879.1256304592.125
20-05-2020 07:004135001bvBOhCH3iADSZry1535.71428615066.857142866346973.857
20-05-2020 07:004135001iCRJl6heRkivqQ31568.857143153.285714369.857142867210787.857
20-05-2020 07:004135001ih0vzX44oOqAx2f1584.142857154.8571429696217346
20-05-2020 07:004135001pkci93gMrogZuBj1550.571429151.568.571428577201417.571
20-05-2020 07:004135001rGa61gmuvPhdLxV1542150.671428668.571428577143880.571
20-05-2020 07:004135001sjndEbLyjtCKgGv1587.714286155.242857169.571428577049353.571
20-05-2020 07:004135001uHbuxQJl8lW7ozc1588.571429155.369.714285717071267.714
20-05-2020 07:004135001wCURE6d3bPkepu21578.571429154.3706815419

截止时间的数据展示

17-06-2020 23:304135001wCURE6d3bPkepu20058837028601
17-06-2020 23:304135001z9Y9gH1T5YWrNuG0058197251204
17-06-2020 23:304135001zBIq5rxdHJRwDNY0058176583369
17-06-2020 23:304135001zVJPv84UY57bAof0059107363272
17-06-2020 23:4541350011BY6WEcLGh8j5v70055216485319
17-06-2020 23:4541350011IF53ai7Xc0U56Y0060346433566
17-06-2020 23:4541350013PZuoBAID5Wc2HD0060527237425
17-06-2020 23:4541350017JYdWkrLSPkdwr40058567846821
17-06-2020 23:454135001McdE0feGgRqW7Ca0059927408587
17-06-2020 23:454135001VHMLBKoKgIrUVDU0060077456208
17-06-2020 23:454135001WRmjgnKYAwPKWDb0059537273532
17-06-2020 23:454135001YxYtjZvoooNbGkE0058867425442
17-06-2020 23:454135001ZnxXDlPa8U1GXgE0059296770737
17-06-2020 23:454135001ZoEaEvLYb1n2sOq0058717341753
17-06-2020 23:454135001adLQvlD726eNBSB005237.1428576524508
17-06-2020 23:454135001bvBOhCH3iADSZry0054606539009
17-06-2020 23:454135001iCRJl6heRkivqQ30059577426263
17-06-2020 23:454135001ih0vzX44oOqAx2f0057586426129
17-06-2020 23:454135001pkci93gMrogZuBj0059527415430
17-06-2020 23:454135001rGa61gmuvPhdLxV0059507356897
17-06-2020 23:454135001sjndEbLyjtCKgGv0058877261681
17-06-2020 23:454135001uHbuxQJl8lW7ozc0059677287002
17-06-2020 23:454135001wCURE6d3bPkepu2005147.6257028601
17-06-2020 23:454135001z9Y9gH1T5YWrNuG0058197251204
17-06-2020 23:454135001zBIq5rxdHJRwDNY0058176583369
17-06-2020 23:454135001zVJPv84UY57bAof0059107363272

三.效果图

原有数据集展示(所有光伏板的展示)

红色的为预测 ,与历史数据放在一个图像

真实值与预测值的对比