节假日电力负荷预测之点对点倍比法

来源:互联网 发布:macbook pro 天气软件 编辑:程序博客网 时间:2024/04/29 06:58

使用点对点倍比法进行特殊值预测


要预测2016.12.25圣诞节的电力负荷,假设现在是距离12.25那天还有 天的某一天,选取这一天的前n 天作为计算数据,在2015年也同样选取n天。

应用倍比法公式
计算出平滑系数;
然后根据2015年圣诞节的电力负荷应用公式

预测出2016年圣诞节的电力负荷。
from __future__ import print_functionimport numpy as npfrom scipy import statsimport pandas as pdimport matplotlib.pyplot as pltdatas=pd.read_csv('C:\\Users\\nsw.csv')index=pd.date_range('1/1/2015','7/19/2017',freq='30min')index1=index[1:]dta=pd.Series(datas['TOTALDEMAND'])dta.index=pd.Index(pd.date_range('1/1/2015','7/19/2017',freq='30min')[1:])import timeholi='2016/12/25 0:00'a=time.strptime(holi, '%Y/%m/%d %H:%M' )print(a)import datetimed = datetime.datetime(* a[:6])print(d)index2=pd.date_range('12/10/2016','12/17/2016',freq='30min')index3=pd.date_range('12/4/2015','12/11/2015',freq='30min')index4=pd.date_range('12/25/2016','12/26/2016',freq='30min')B=0.5 #初始β为0.5rs=[]for i in range(0,48):#遍历一天的每一时刻    A1=B*(1-B)**5*dta[index2[i]]+B*(1-B)**4*dta[index2[i+48]]+B*(1-B)**3*dta[index2[i+48*2]]+B*(1-B)**2*dta[index2[i+48*3]]+B*(1-B)*dta[index2[i+48*4]]+B*dta[index2[i+48*5]]    A2=B*(1-B)**5*dta[index3[i]]+B*(1-B)**4*dta[index3[i+48]]+B*(1-B)**3*dta[index3[i+48*2]]+B*(1-B)**2*dta[index3[i+48*3]]+B*(1-B)*dta[index3[i+48*4]]+B*dta[index3[i+48*5]]    Pre=(A1/A2)*dta[index4[i]]    rs.append(Pre)predict=pd.DataFrame({'predict':rs})pred=pd.Series(predict['predict'])pred.index=pd.Index(index4[0:48])predmis=0for i in range(0,48) :        mis+=abs((dta[index4[i]]-pred[index4[i]])/dta[index4[i]])mis=mis/48print(mis)plt.plot(pred, 'r--', dta[index4[0:47]], 'b--')plt.show()



阅读全文
1 0
原创粉丝点击