绿色移动云计算下生物质的预测分析
1. 模型训练与评估代码
在对生物质数据进行分析时,我们使用了线性回归模型,并进行了一系列的训练、预测和评估操作,以下是相关代码:
# 训练模型
step96: lr.fit(xtrain,ytrain)
# 进行预测
step97: pr = lr.predict(xtest)
step98: pr
# 绘制预测结果与真实值的关系图
step99: plt.figure(figsize=(6,5))
step100: plt.plot(pr,ytest,color="blue", lw=0.5, ls='',
marker='o',markerfacecolor="yellow",markersize=12)
step101: sns.regplot(pr,ytest,color='b')
step102: plt.ylabel('\nPowerPotential(MWe)',fontsize=20)
step103: plt.style.use('bmh')
# 计算模型得分
step105: lr.score(x,y)
# 计算误差指标
step108: from sklearn.metrics import mean_squared_error, mean_absolute_error
step110: mse = mean_squared_error(pr,ytest)
step111: mse
step113: mae = mean_absolute_error(pr,ytest)
step114: mae
step116: rmse = np.sqrt(mean_squared_err
超级会员免费看
订阅专栏 解锁全文
4

被折叠的 条评论
为什么被折叠?



