欢迎使用CSDN-markdown编辑器
来源:互联网 发布:iphone自动切换网络 编辑:程序博客网 时间:2024/06/06 01:00
列表内容
Test模型开发
import pandas as pdimport numpy as npimport matplotlib.pyplot as pltfrom sklearn.ensemble import RandomForestRegressorfrom sklearn.model_selection import train_test_splitfrom sklearn.multioutput import MultiOutputRegressorplt.ion()#prepare DatainputLabel=["WindSpeed","GenPower","GenSpeed","OutDoorTemp","NacelleTemp"]outputLabel=["GenBearDETemp","GenBearNDETemp","GenStatorUTemp","GenStatorVTemp", "GenStatorWTemp"]dataPath="E:/DevRawModelProject/RawModelData/test/goodt20014001f.csv"data_testPath="E:/DevRawModelProject/RawModelData/test/t20014001_test.csv"df=pd.read_csv(dataPath)df_test=pd.read_csv(data_testPath)X_train, y_train=(df[inputLabel].values,df[outputLabel].values)X_test, y_test=(df_test[inputLabel].values,df_test[outputLabel].values)
#cal mainmax_depth =8max_depth=max_depth#random_state=2regr_rf = RandomForestRegressor(max_depth=max_depth)regr_rf.fit(X_train, y_train)
RandomForestRegressor(bootstrap=True, criterion='mse', max_depth=8, max_features='auto', max_leaf_nodes=None, min_impurity_split=1e-07, min_samples_leaf=1, min_samples_split=2, min_weight_fraction_leaf=0.0, n_estimators=10, n_jobs=1, oob_score=False, random_state=None, verbose=0, warm_start=False)
#test modely_rf = regr_rf.predict(X_train)y_test_rf = regr_rf.predict(X_test)varR=np.var(y_train[:,2]-y_rf[:,2])varT=np.var(y_train[:,2])r2=1-varR/varTprint(r2)
0.820108692169
plt.plot(y_test[:,0])plt.plot(y_test_rf[:,0],'r')
[<matplotlib.lines.Line2D at 0x1018f9b0>]
print(y_rf.shape)#plot data#plt.scatter(X_train,y_train,c="red", marker="+",alpha=0.5,label="Data")plt.scatter(y_train[:,0],y_rf[:,0],c="cornflowerblue", alpha=0.5,label="predict")plt.scatter(y_train[:,1],y_rf[:,1],marker="+",c="red", alpha=0.3,label="predict")#plt.show()
(27627, 5)<matplotlib.collections.PathCollection at 0xeffacf8>
from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() ax = fig.add_subplot(111, projection='3d') X = X_train[:,0]Y = X_train[:,1]Z = y_train[:,2]ax.scatter(X, Y, Z) #ax = fig.add_subplot(111, projection='3d') X = X_train[:,0]Y = X_train[:,1]Z =y_rf[:,2]ax.scatter(X, Y, Z,c="red", marker="+",alpha=0.5,label="Data")plt.show()
plt.scatter(y_train[:,0],y_train[:,1],c="cornflowerblue",marker="+",alpha=0.5,label="predict")plt.scatter(y_rf[:,0],y_rf[:,1],marker="+",c="red", alpha=0.3,label="predict")
<matplotlib.collections.PathCollection at 0xd7a1a58>
df.columns
Index(['Unnamed: 0', 'TablePart', 'TurbineID', 'real_time', 'WindSpeed', 'GenPower', 'GenSpeed', 'OutDoorTemp', 'NacelleTemp', 'GenBearDETemp', 'GenBearNDETemp', 'GenStatorUTemp', 'GenStatorVTemp', 'GenStatorWTemp', 'con1'], dtype='object')
plt.plot(y_train[:,0])plt.plot(y_rf[:,0])
[<matplotlib.lines.Line2D at 0xb97ee80>]
plt.plot(y_train[:,1])plt.plot(y_rf[:,1])
[<matplotlib.lines.Line2D at 0xf07def0>]
plt.plot(y_train[:,1]-y_rf[:,1])
[<matplotlib.lines.Line2D at 0xf128dd8>]
plt.plot(y_train[:,0]-y_rf[:,0])
[<matplotlib.lines.Line2D at 0xf18dd30>]
plt.plot(y_train[:,2]-y_rf[:,2])
[<matplotlib.lines.Line2D at 0xf1db080>]
plt.plot(X_train[:,2],y_train[:,2]-y_rf[:,2],'*')#plt.title("T")plt.show()
import numpy as npvarR=np.var(y_train[:,2]-y_rf[:,2])varT=np.var(y_train[:,2])r2=1-varR/varTprint(r2)
0.962437941174
y_test_rf = regr_rf.predict(X_test)
plt.plot(X_test[:,2],y_test[:,2]-y_test_rf[:,2],'*')#plt.title("T")plt.show()
plt.plot(y_test[:,0],y_test_rf[:,0],'*')#plt.title("T")plt.show()
import numpy as npvarR=np.var(y_test[:,2]-y_test_rf[:,2])varT=np.var(y_test[:,2])r2=1-varR/varTprint(r2)
0.703730968599
df.WindSpeed.min()
1.02
plt.plot(df['WindSpeed'],df['GenPower'],"+")plt.plot(df_test['WindSpeed'],df_test['GenPower'],"o")
[<matplotlib.lines.Line2D at 0xf4e4470>]
plt.plot(y_test[:,0]-y_test_rf[:,0])plt.plot(y_test[:,1]-y_test_rf[:,1])
[<matplotlib.lines.Line2D at 0xfd5e208>]
plt.plot(y_test[:,0])plt.plot(y_test_rf[:,0],'r')
[<matplotlib.lines.Line2D at 0xfd2a6d8>]
plt.plot(y_train[:,2]-y_rf[:,2],y_train[:,3]-y_rf[:,3],'*')#plt.title("T")plt.show()
0 0
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- ARP协议报文格式及ARP表
- mongodb按照时间查询
- method chaining 方法链
- 求100W个数中的前K个最大的数
- 递归下降分析
- 欢迎使用CSDN-markdown编辑器
- 详解 TensorBoard-如何调参
- 1067 机器翻译
- [leetcode: Python]217. Contains Duplicate
- 河南第十届ACM省赛-D-年终奖金
- 前端工作流全解析
- Spring的jdbcTemplate查询执行原生sql
- 深度学习之Caffe框架
- BurnCtrl刻录控制系统