【负荷预测】基于贝叶斯网络的考虑不确定性的短期电能负荷预测(Python代码实现)

 👨‍🎓个人主页:研学社的博客 

💥💥💞💞欢迎来到本博客❤️❤️💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

📋📋📋本文目录如下:🎁🎁🎁

目录

💥1 概述

📚2 运行结果

🌈3 Matlab代码实现

🎉4 参考文献


💥1 概述

短期电力负荷预测是现代电力系统控制与运行分析的一项重要研究内容。随着电力体制改革的深化,电力市场的不断完善以及智能电,网建设目标的逐步实施,电网运行中对于经济性和安全性的要求越来越高,对短期负荷预测也提出了更高的要求。
传统预测方法由于其原理比较简单,理论相对成熟,因此至今仍被广泛应用。传统预测方法主要有:趋势外推法、时间序列法、回归分析法等。由于电力负荷有着非线性、时变性和不确定性的特点,而传统预测方法采用的数学模型过于简单.不能及时、准确地对预测模型的参数进行估计和调整,更不能方便描述负荷的突然变化,从而使这些方法难以获得较高的预测精度。随着负荷预测技术研究的不断深化,相继出现了以人工智能为代表的负荷预测新方法.如:灰色预测法[1、模糊预测法!2!、优选组合法[31、小波分析法!4和人工神经网络法等。由于一些方法考虑了负荷预测系统的鲁棒性,并且能够拟合出负荷的复杂非线性关系,因此,人工智能方法与传统方法相比有许多优点。

📚2 运行结果

print('偶然不确定性:',std_mean)
print('认知不确定性:',mean_sigma)

print('偶然不确定性:',np.mean(std_mean))
print('认知不确定性:',np.mean(mean_sigma))

 结果:

偶然不确定性: [0.37458175 0.37458175 0.37458175 0.37461463 0.38332063 0.4107164
 0.45222163 0.48494232 0.5312848  0.5443692  0.58056927 0.6104524
 0.6372883  0.6621181  0.6731655  0.6266249  0.63724846 0.65924484
 0.6147452  0.57374454 0.5360238  0.5130135  0.4896349  0.4747888 ]
认知不确定性: [0.0162899  0.0162899  0.0162899  0.01622007 0.06685151 0.0674182
 0.06788017 0.03853567 0.04431767 0.04643966 0.05136628 0.05558429
 0.05943689 0.06303471 0.06498456 0.06015231 0.06211003 0.06539844
 0.06097266 0.05708234 0.05377384 0.0522627  0.0508984  0.05050901]
偶然不确定性: 0.5247449
认知不确定性: 0.050170798

部分代码:

y_stds = np.concatenate(y_pred_stds, axis=1)
std_mean = np.mean(y_stds, axis=1) #Aleatoric uncertainty
std_sigma = np.std(y_stds, axis=1)
fig=plt.figure(figsize=(12, 6),dpi=200)
ax = fig.add_subplot(1,1,1)
ax.fill_between(test_dates,
                 mean_mean + 2*mean_sigma,
                 mean_mean - 2*mean_sigma,
                 alpha=0.9, label='认知不确定性')
ax.fill_between(test_dates,    
                 mean_mean + std_mean,  # Aleatoric uncertainty 条件均值的方差
                 mean_mean - std_mean,
                 alpha=0.5, label='偶然不确定性')
ax.plot(test_dates,y_test,label='实际负荷',marker='*')
ax.plot(test_dates, test_mean, 'r-', label='预测均值',marker='^');
#plt.title('2月24日BNN日前电力负荷预测不确定性表示')
ax.xaxis.set_major_locator(test_loc)
ax.xaxis.set_major_formatter(test_fmt)
ax.set_ylabel("电力负荷(GW)")
ax.set_xlabel("时间(H)")
plt.legend()
plt.ylim((2,7))
plt.grid()
plt.show()
y_stds = np.concatenate(y_pred_stds, axis=1)
std_mean = np.mean(y_stds, axis=1) #Aleatoric uncertainty
std_sigma = np.std(y_stds, axis=1)
fig=plt.figure(figsize=(12, 6),dpi=200)
ax = fig.add_subplot(1,1,1)
ax.fill_between(test_dates,
                 mean_mean + 2*mean_sigma,
                 mean_mean - 2*mean_sigma,
                 alpha=0.9, label='认知不确定性')
ax.fill_between(test_dates,    
                 mean_mean + std_mean,  # Aleatoric uncertainty 条件均值的方差
                 mean_mean - std_mean,
                 alpha=0.5, label='偶然不确定性')
ax.plot(test_dates,y_test,label='实际负荷',marker='*')
ax.plot(test_dates, test_mean, 'r-', label='预测均值',marker='^');
#plt.title('2月24日BNN日前电力负荷预测不确定性表示')
ax.xaxis.set_major_locator(test_loc)
ax.xaxis.set_major_formatter(test_fmt)
ax.set_ylabel("电力负荷(GW)")
ax.set_xlabel("时间(H)")
plt.legend()
plt.ylim((2,7))
plt.grid()
plt.show()

🌈3 Matlab代码实现

🎉4 参考文献

部分理论来源于网络,如有侵权请联系删除。

[1]周玉,崔高颖,易永仙,陈霄,石坤,许高杰.基于贝叶斯网络的短期负荷预测方法[J].电气应用,2015,34(S2):130-134.

[2]李慧良,李鹏鹏,彭显刚,孟安波,农为踊.基于贝叶斯神经网络的短期负荷预测应用研究[J].广东电力,2012,25(11):16-19.

python写的一段贝叶斯网络的程序 This file describes a Bayes Net Toolkit that we will refer to now as BNT. This version is 0.1. Let's consider this code an "alpha" version that contains some useful functionality, but is not complete, and is not a ready-to-use "application". The purpose of the toolkit is to facilitate creating experimental Bayes nets that analyze sequences of events. The toolkit provides code to help with the following: (a) creating Bayes nets. There are three classes of nodes defined, and to construct a Bayes net, you can write code that calls the constructors of these classes, and then you can create links among them. (b) displaying Bayes nets. There is code to create new windows and to draw Bayes nets in them. This includes drawing the nodes, the arcs, the labels, and various properties of nodes. (c) propagating a-posteriori probabilities. When one node's probability changes, the posterior probabilities of nodes downstream from it may need to change, too, depending on firing thresholds, etc. There is code in the toolkit to support that. (d) simulating events ("playing" event sequences) and having the Bayes net respond to them. This functionality is split over several files. Here are the files and the functionality that they represent. BayesNetNode.py: class definition for the basic node in a Bayes net. BayesUpdating.py: computing the a-posteriori probability of a node given the probabilities of its parents. InputNode.py: class definition for "input nodes". InputNode is a subclass of BayesNetNode. Input nodes have special features that allow them to recognize evidence items (using regular-expression pattern matching of the string descriptions of events). OutputNode.py: class definition for "output nodes". OutputBode is a subclass of BayesNetNode. An output node can have a list of actions to be performed when the node's posterior probability exceeds a threshold ReadWriteSigmaFiles.py: Functionality for loading and saving Bayes nets in an XML format. SampleNets.py: Some code that constructs a sample Bayes net. This is called when SIGMAEditor.py is started up. SIGMAEditor.py: A main program that can be turned into an experimental application by adding menus, more code, etc. It has some facilities already for loading event sequence files and playing them. sample-event-file.txt: A sequence of events that exemplifies the format for these events. gma-mona.igm: A sample Bayes net in the form of an XML file. The SIGMAEditor program can read this type of file. Here are some limitations of the toolkit as of 23 February 2009: 1. Users cannot yet edit Bayes nets directly in the SIGMAEditor. Code has to be written to create new Bayes nets, at this time. 2. If you select the File menu's option to load a new Bayes net file, you get a fixed example: gma-mona.igm. This should be changed in the future to bring up a file dialog box so that the user can select the file. 3. When you "run" an event sequence in the SIGMAEditor, the program will present each event to each input node and find out if the input node's filter matches the evidence. If it does match, that fact is printed to standard output, but nothing else is done. What should then happen is that the node's probability is updated according to its response method, and if the new probability exceeds the node's threshold, then its successor ("children") get their probabilities updated, too. 4. No animation of the Bayes net is performed when an event sequence is run. Ideally, the diagram would be updated dynamically to show the activity, especially when posterior probabilities of nodes change and thresholds are exceeded. To use the BNT, do three kinds of development: A. create your own Bayes net whose input nodes correspond to pieces of evidence that might be presented and that might be relevant to drawing inferences about what's going on in the situation or process that you are analyzing. You do this by writing Python code that calls constructors etc. See the example in SampleNets.py. B. create a sample event stream that represents a plausible sequence of events that your system should be able to analyze. Put this in a file in the same format as used in sample-event-sequence.txt. C. modify the code of BNT or add new modules as necessary to obtain the functionality you want in your system. This could include code to perform actions whenever an output node's threshold is exceeded. It could include code to generate events (rather than read them from a file). And it could include code to describe more clearly what is going on whenever a node's probability is updated (e.g., what the significance of the update is -- more certainty about something, an indication that the weight of evidence is becoming strong, etc.)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

荔枝科研社

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值