当前位置: 首页 > news >正文

吴川市建设工程公司网站代写文章平台

吴川市建设工程公司网站,代写文章平台,建视频网站需要多大空间,个体户广告公司名字1. 随机森林超参数 极其重要的三个超参数是必须要调整的#xff0c;一般再加上两到三个其他超参数进行优化即可。 2. 学习曲线确定n_estimators搜索范围 首先导入必要的库#xff0c;使用sklearn自带的房价预测数据集#xff1a; import numpy as np import pandas as pd f…1. 随机森林超参数 极其重要的三个超参数是必须要调整的一般再加上两到三个其他超参数进行优化即可。 2. 学习曲线确定n_estimators搜索范围 首先导入必要的库使用sklearn自带的房价预测数据集 import numpy as np import pandas as pd from sklearn.model_selection import train_test_split from sklearn.datasets import fetch_california_housing from sklearn.ensemble import RandomForestRegressor from sklearn.model_selection import KFold from sklearn.model_selection import cross_validate import matplotlib.pyplot as plt housing fetch_california_housing() # 特征数据 X housing.data[:, [0, 1, 2, 3, 4, 5, 6, 7]] # 目标变量房价 y housing.target 初始化以及5折交叉验证计算RMSE trainRMSE np.array([]) testRMSE np.array([]) trainSTD np.array([]) testSTD np.array([])Option range(5,101,5) for n_estimators in Option :reg_f RandomForestRegressor(n_estimatorsn_estimators, random_state1412)# 交叉验证输出结果cv KFold(n_splits5,shuffleTrue,random_state1412)result_f cross_validate(reg_f,X,y,cvcv,scoringneg_mean_squared_error,return_train_scoreTrue,n_jobs-1)# 根据输出的MSE进行RMSE计算train abs(result_f[train_score])**0.5test abs(result_f[test_score])**0.5trainRMSE np.append(trainRMSE,train.mean())testRMSE np.append(testRMSE,test.mean())trainSTD np.append(trainSTD,train.std())testSTD np.append(testSTD,test.std()) 定义绘图函数  def plotCVresult(Option,trainRMSE,testRMSE,trainSTD,testSTD) :xaxis Option# RMSEplt.plot(xaxis, trainRMSE,colork,labelRandomForestTrain)plt.plot(xaxis, testRMSE, colorred, labelRandomForestTest)# 将标准差围绕在RMSE旁边区间越大表示模型越不稳定plt.plot(xaxis, trainRMSE trainSTD, colork, linestyledotted)plt.plot(xaxis, trainRMSE - trainSTD, colork, linestyledotted)plt.plot(xaxis, testRMSE testSTD, colorred, linestyledotted)plt.plot(xaxis, testRMSE - testSTD, colorred, linestyledotted)plt.xticks([*xaxis])plt.legend(loc1)plt.xlabel(n_estimators)plt.ylabel(RMSE)plt.title(Learning Curve)plt.show()plotCVresult(Option,trainRMSE,testRMSE,trainSTD,testSTD) 输出结果如下  3. 使用Tree模块判断max_depth搜索范围 只需在输出的最小值和最大值之间进行搜索即可。 reg_f RandomForestRegressor(n_estimators100,random_state1412) reg_f reg_f.fit(X,y) d pd.Series([],dtypeint64) for idx,t in enumerate(reg_f.estimators_) :d[idx] t.tree_.max_depth print(决策树的最大深度的最小值为,d.min()) print(决策树的最大深度的最大值为,d.max()) 输出结果为 4. 使用Tree模块判断min_weight_fraction_leaf搜索范围 reg_f RandomForestRegressor(n_estimators100,random_state1412) reg_f reg_f.fit(X,y) n pd.Series([],dtypeint64) for idx,t in enumerate(reg_f.estimators_) :n[idx] t.tree_.weighted_n_node_samples meann np.zeros(20) for i in range(0,20) :meann[i] n[i].mean() print(决策树分枝所需最小样本权重的最小值为,meann.min()) print(决策树分枝所需最小样本权重的最大值为,meann.max()) print(决策树分枝所需最小样本权重的平均值为,meann.mean()) 输出结果为 5. 使用Tree模块判断min_sample_split搜索范围 reg_f RandomForestRegressor(n_estimators20,random_state1412) reg_f reg_f.fit(X,y) s pd.Series([],dtypeint64) for idx,t in enumerate(reg_f.estimators_) :s[idx] t.tree_.n_node_samples meann np.zeros(20) for i in range(0,20) :meann[i] s[i].mean() print(决策树需要最小样本的最小值为,meann.min()) print(决策树需要最小样本的最大值为,meann.max()) print(决策树需要最小样本的平均值为,meann.mean()) 输出结果为
http://www.hkea.cn/news/14521392/

相关文章:

  • 如何判断网站被google k佛山网站代运营
  • 西安网站优化排名平面设计培训班哪里有
  • 内蒙古建设厅官方网站纳米加工平台
  • 国外网站关键词公司注册资金实缴政策最新
  • 富锦建设局网站重庆网站公司设计
  • 网站安全维护内容wordpress 中文注册
  • 常州建设局网站首页网站内容策划
  • 公司做网站的好处怎么做微信网站推广
  • 网站加上视频对seo影响做微商有什么好的货源网站
  • 做网站条件3d效果图制作软件
  • 网站建设多久可以学会o2o信息类平台有哪些
  • 建设网站书籍pdf下载网站建设不好
  • 深圳网站seo关键词深圳市企业网站建设价格
  • 网站建设费用自建建网站设置网站首页
  • 济南大型网站建设公司内部网站设计
  • 专业电商网站深圳代理记账多少钱一月
  • 美克美家网站建设绵阳网站建设成都网站设计
  • 网站所有人网站制作大概费用
  • 培训加盟网站建设网页qq登陆网站
  • 浙江嘉兴网站建设网创项目平台
  • 程序员 创业做网站宁波seo推广开发
  • 合肥网站建设之4个细节要注意潍坊住房和城乡建设部网站
  • 怎么创建个人的网站企业推广活动
  • 酒店网站建设方案ppt能进网站的浏览器
  • seo网站推广的主要目的是什么php免费企业网站源码
  • 博物馆网站建设经费请示免费的ppt制作软件
  • 特色设计网站推荐美团如何进行网站的建设和维护
  • 中文域名怎样绑定网站安徽电商网站建设
  • 自动做reference的网站网站有哪些平台
  • 网站 简约南昌推广软件