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; %初始化输出层与隐含层之间的
梦回阑珊
- 粉丝: 5280
- 资源: 1687
最新资源
- PHP开源商城系统源码带搭建教程数据库 MySQL源码类型 WebForm
- Delphi 12 控件之FastReport VCL Enterprise v2024.1 for Delphi 10.4-12 Athens with Source Code.7z
- Java实现的扫雷游戏.zip学习资源代码
- Delphi 12 控件fmxlinux1.78.exe
- C#ASP.NET广告合同备案源码数据库 SQL2008源码类型 WebForm
- 智谱文生视频+图生视频接口调用
- OSPF协议V10-03
- OSPF协议V10-02
- Delphi 12 控件之dotConnect-for-Sqlite-v6.3.104-Professional.rar
- OSPF协议V10-01
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈