import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
#定义学习函数
def logsig(x):
return 1/(1+np.exp(-x))
#气象因素数据
Load_Waether_data=pd.read_excel(io=r'D:\sublime_Program\Pyhton Data analysis and mining practice\test20190618\input\20141223前20天数据.xlsx',header=-1)
最高温度 = Load_Waether_data['最高温度℃'].as_matrix()
最低温度 = Load_Waether_data['最低温度℃'].as_matrix()
平均温度 = Load_Waether_data['平均温度℃'].as_matrix()
相对湿度=Load_Waether_data['相对湿度(平均)'].as_matrix()
降雨量 = Load_Waether_data['降雨量(mm)'].as_matrix()
日期类型 = Load_Waether_data['日期类型'].as_matrix()
T0000=Load_Waether_data['T0000'].as_matrix()
T0015=Load_Waether_data['T0015'].as_matrix()
T0030=Load_Waether_data['T0030'].as_matrix()
T0045=Load_Waether_data['T0045'].as_matrix()
T0100=Load_Waether_data['T0100'].as_matrix()
T0115=Load_Waether_data['T0115'].as_matrix()
T0130=Load_Waether_data['T0130'].as_matrix()
T0145=Load_Waether_data['T0145'].as_matrix()
T0200=Load_Waether_data['T0200'].as_matrix()
T0215=Load_Waether_data['T0215'].as_matrix()
T0230=Load_Waether_data['T0230'].as_matrix()
T0245=Load_Waether_data['T0245'].as_matrix()
T0300=Load_Waether_data['T0300'].as_matrix()
T0315=Load_Waether_data['T0315'].as_matrix()
T0330=Load_Waether_data['T0330'].as_matrix()
T0345=Load_Waether_data['T0345'].as_matrix()
T0400=Load_Waether_data['T0400'].as_matrix()
T0415=Load_Waether_data['T0415'].as_matrix()
T0430=Load_Waether_data['T0430'].as_matrix()
T0445=Load_Waether_data['T0445'].as_matrix()
T0500=Load_Waether_data['T0500'].as_matrix()
T0515=Load_Waether_data['T0515'].as_matrix()
T0530=Load_Waether_data['T0530'].as_matrix()
T0545=Load_Waether_data['T0545'].as_matrix()
T0600=Load_Waether_data['T0600'].as_matrix()
T0615=Load_Waether_data['T0615'].as_matrix()
T0630=Load_Waether_data['T0630'].as_matrix()
T0645=Load_Waether_data['T0645'].as_matrix()
T0700=Load_Waether_data['T0700'].as_matrix()
T0715=Load_Waether_data['T0715'].as_matrix()
T0730=Load_Waether_data['T0730'].as_matrix()
T0745=Load_Waether_data['T0745'].as_matrix()
T0800=Load_Waether_data['T0800'].as_matrix()
T0815=Load_Waether_data['T0815'].as_matrix()
T0830=Load_Waether_data['T0830'].as_matrix()
T0845=Load_Waether_data['T0845'].as_matrix()
T0900=Load_Waether_data['T0900'].as_matrix()
T0915=Load_Waether_data['T0915'].as_matrix()
T0930=Load_Waether_data['T0930'].as_matrix()
T0945=Load_Waether_data['T0945'].as_matrix()
T1000=Load_Waether_data['T1000'].as_matrix()
T1015=Load_Waether_data['T1015'].as_matrix()
T1030=Load_Waether_data['T1030'].as_matrix()
T1045=Load_Waether_data['T1045'].as_matrix()
T1100=Load_Waether_data['T1100'].as_matrix()
T1115=Load_Waether_data['T1115'].as_matrix()
T1130=Load_Waether_data['T1130'].as_matrix()
T1145=Load_Waether_data['T1145'].as_matrix()
T1200=Load_Waether_data['T1200'].as_matrix()
T1215=Load_Waether_data['T1215'].as_matrix()
T1230=Load_Waether_data['T1230'].as_matrix()
T1245=Load_Waether_data['T1245'].as_matrix()
T1300=Load_Waether_data['T1300'].as_matrix()
T1315=Load_Waether_data['T1315'].as_matrix()
T1330=Load_Waether_data['T1330'].as_matrix()
T1345=Load_Waether_data['T1345'].as_matrix()
T1400=Load_Waether_data['T1400'].as_matrix()
T1415=Load_Waether_data['T1415'].as_matrix()
T1430=Load_Waether_data['T1430'].as_matrix()
T1445=Load_Waether_data['T1445'].as_matrix()
T1500=Load_Waether_data['T1500'].as_matrix()
T1515=Load_Waether_data['T1515'].as_matrix()
T1530=Load_Waether_data['T1530'].as_matrix()
T1545=Load_Waether_data['T1545'].as_matrix()
T1600=Load_Waether_data['T1600'].as_matrix()
T1615=Load_Waether_data['T1615'].as_matrix()
T1630=Load_Waether_data['T1630'].as_matrix()
T1645=Load_Waether_data['T1645'].as_matrix()
T1700=Load_Waether_data['T1700'].as_matrix()
T1715=Load_Waether_data['T1715'].as_matrix()
T1730=Load_Waether_data['T1730'].as_matrix()
T1745=Load_Waether_data['T1745'].as_matrix()
T1800=Load_Waether_data['T1800'].as_matrix()
T1815=Load_Waether_data['T1815'].as_matrix()
T1830=Load_Waether_data['T1830'].as_matrix()
T1845=Load_Waether_data['T1845'].as_matrix()
T1900=Load_Waether_data['T1900'].as_matrix()
T1915=Load_Waether_data['T1915'].as_matrix()
T1930=Load_Waether_data['T1930'].as_matrix()
T1945=Load_Waether_data['T1945'].as_matrix()
T2000=Load_Waether_data['T2000'].as_matrix()
T2015=Load_Waether_data['T2015'].as_matrix()
T2030=Load_Waether_data['T2030'].as_matrix()
T2045=Load_Waether_data['T2045'].as_matrix()
T2100=Load_Waether_data['T2100'].as_matrix()
T2115=Load_Waether_data['T2115'].as_matrix()
T2130=Load_Waether_data['T2130'].as_matrix()
T2145=Load_Waether_data['T2145'].as_matrix()
T2200=Load_Waether_data['T2200'].as_matrix()
T2215=Load_Waether_data['T2215'].as_matrix()
T2230=Load_Waether_data['T2230'].as_matrix()
T2245=Load_Waether_data['T2245'].as_matrix()
T2300=Load_Waether_data['T2300'].as_matrix()
T2315=Load_Waether_data['T2315'].as_matrix()
T2330=Load_Waether_data['T2330'].as_matrix()
T2345=Load_Waether_data['T2345'].as_matrix()
#将数据转换成矩阵,并使用最大最小归一数据
#输入
samplein = np.mat([最高温度,最低温度,平均温度,相对湿度,降雨量,日期类型]) #6行* 列
sampleinminmax = np.array([samplein.min(axis=1).T.tolist()[0],samplein.max(axis=1).T.tolist()[0]]).transpose()
#输出
sampleout = np.mat([T0000,T0015,T0030,T0045,T0100,T0115,T0130,T0145,
T0200,T0215,T0230,T0245,T0300,T0315,T0330,T0345,
T0400,T0415,T0430,T0445,T0500,T0515,T0530,T0545,
T0600,T0615,T0630,T0645,T0700,T0715,T0730,T0745,
T0800,T0815,T0830,T0845,T0900,T0915,T0930,T0945,
T1000,T1015,T1030,T1045,T1100,T1115,T1130,T1145,
T1200,T1215,T1230,T1245,T1300,T1315,T1330,T1345,
T1400,T1415,T1430,T1445,T1500,T1515,T1530,T1545,
T1600,T1615,T1630,T1645,T1700,T1715,T1730,T1745,
T1800,T1815,T1830,T1845,T1900,T1915,T1930,T1945,
T2000,T2015,T2030,T2045,T2100,T2115,T2130,T2145,
T2200,T2215,T2230,T2245,T2300,T2315,T2330,T2345])#2*20
sampleoutminmax = np.array([sampleout.min(axis=1).T.tolist()[0],sampleout.max(axis=1).T.tolist()[0]]).transpose()
sampleinnorm = (2*(np.array(samplein.T)-sampleinminmax.transpose()[0])/(sampleinminmax.transpose()[1]-sampleinminmax.transpose()[0])-1).transpose()
print(sampleinnorm)
print('=========================================')
sampleoutnorm = (2*(np.array(sampleout.T).astype(float)-sampleoutminmax.transpose()[0])/(sampleoutminmax.transpose()[1]-sampleoutminmax.transpose()[0])-1).transpose()
print(sampleoutnorm)
#给输入样本添加噪声
noise = 0.03*np.random.rand(sampleoutnorm.shape[0],sampleoutnorm.shape[1])
sampleoutnorm += noise
#========================================
'''
maxepochs=50000; %最多训练次数为50000
learnrate=0.035; %学习速率为0.035
errorfinal=0.65*10^(-3); %目标误差为0.65*10^(-3)
InDim=3; %网络输入维度为3
OutDim=2; %网络输出维度为2
SamNum=20; %输入样本数量为20
TestSamNum=20; %测试样本数量也是20
ForcastSamNum=2; %预测样本数量为2
HiddenUnitNum=8; %中间层隐节点数量取8,比工具箱程序多了1个
W1=0.5*rand(HiddenUnitNum,InDim)-0.1; %初始化输入层与隐含层之间的权值
B1=0.5*rand(HiddenUnitNum,1)-0.1; %初始化输入层与隐含层之间的阈值
W2=0.5*rand(OutDim,HiddenUnitNum)-0.1; %初始化输出层与隐含层之间的权值
B2=0.5*rand(OutDim,1)-0.1; %初始化输出层与隐含层之间的
梦回阑珊
- 粉丝: 5553
- 资源: 1717
最新资源
- 移动应用开发课程设计,Android课程设计,移动点餐系统
- 单相三电平NPC逆变器 载波层叠 可选SVPWM和SPWM 可提供参考文献
- 新能源动力电池装支架中框套钉设备sw21可编辑全套技术资料100%好用.zip
- 数据采集与数据分析课程设计,二手房数据采集与分析
- Matlab 基于VMD分解联合小波阈值去噪,程序包括VMD分解,小波阈值去噪,SNR评价指标,绘制不同小波函数不同分解层数SNR曲线,指出最佳的小波函数,分解层数
- COMSOL数值模拟,实现N2和CO2混合气体在THM热流固三场耦合情况下增强瓦斯(煤层气抽采)
- 建筑暖通空调与微电网智能控制协同设计(代码)
- 无刷直流电机BLDC sinulink仿真 无刷直流电机双闭环PId控制 1)主要由DC直流源、三相逆变桥、无刷直流电机、PWM发生器、霍尔位置解码模块、驱动信号模块、PID、示波器等构成 2)采用
- 数据仓库与数据挖掘课程设计
- 长短期记忆神经网络(LSTM)预测天气 环境:matlab 包含与ELM算法的对比 注:为.m程序编程,非工具箱
- HFI脉振方波高频注入代码 增强滑膜esmo代码 配套有文档,学习的好东西 1esmo和 hfi详细开发文
- 304.8宽转弯链板输送机(sw16可编辑+工程图+bom)全套技术资料100%好用.zip
- FactoryIO连续视觉分拣仿真,可移植到实际项目中使用,采用SCL编写先入先出算法,封装好FB块,源程序不密,直接调用,算法配有视频解说轻松学会 适用于各种立体仓库,连续物料分拣,多层电梯,出入
- 西门子博途PLC S型速度曲线加减速(带位置轨迹规划)
- 分布式系统与云计算课程设计+软件项目管理大作业
- 毕业设计-Python的flask-html基于深度学习的电影评论情感分析系统(毕业全套文档+源码)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈