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

石家庄做网站建设的公司排名seo服务合同

石家庄做网站建设的公司排名,seo服务合同,网站页面建设方案书模板,修改wordpress的首页1. 随机森林超参数 极其重要的三个超参数是必须要调整的,一般再加上两到三个其他超参数进行优化即可。 2. 学习曲线确定n_estimators搜索范围 首先导入必要的库,使用sklearn自带的房价预测数据集: 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_estimators=n_estimators, random_state=1412)# 交叉验证输出结果cv = KFold(n_splits=5,shuffle=True,random_state=1412)result_f = cross_validate(reg_f,X,y,cv=cv,scoring="neg_mean_squared_error",return_train_score=True,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,color='k',label='RandomForestTrain')plt.plot(xaxis, testRMSE, color='red', label='RandomForestTest')# 将标准差围绕在RMSE旁边,区间越大表示模型越不稳定plt.plot(xaxis, trainRMSE + trainSTD, color='k', linestyle='dotted')plt.plot(xaxis, trainRMSE - trainSTD, color='k', linestyle='dotted')plt.plot(xaxis, testRMSE + testSTD, color='red', linestyle='dotted')plt.plot(xaxis, testRMSE - testSTD, color='red', linestyle='dotted')plt.xticks([*xaxis])plt.legend(loc=1)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_estimators=100,random_state=1412)
reg_f = reg_f.fit(X,y)
d = pd.Series([],dtype="int64")
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_estimators=100,random_state=1412)
reg_f = reg_f.fit(X,y)
n = pd.Series([],dtype="int64")
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_estimators=20,random_state=1412)
reg_f = reg_f.fit(X,y)
s = pd.Series([],dtype="int64")
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/644879/

相关文章:

  • 制作好网站黑帽seo教程
  • 云南 网站建设网站seo优化对网店的推广的作用为
  • 网站建设免费国外舆情服务公司
  • 怎么做网站banner查排名网站
  • 做网站好看的背景图片相关搜索优化软件
  • 怎么查网站是哪家制作公司做的百度收录查询
  • 企业年金交了有好处吗网络优化工程师吃香吗
  • python做网站开发百度6大核心部门
  • 自己做网站平台企业网站优化价格
  • 淘宝网网站建设的需求分析百度会员登录入口
  • 建网站的专业公司推广网站多少钱
  • 网站不去公安局备案自己怎么搭建网站
  • 外贸网站建设入门深圳网络推广哪家
  • 网站模板资源公司网站推广
  • 广东省建设教育协会官方网站首页html简单网页代码
  • 个人网站意义阿里指数官网最新版本
  • 网站开发方式有哪四种搜索引擎优化课程总结
  • 申请做网站、论坛版主app推广接单
  • 青海网站建设广州seo优化推广
  • 物流公司网站制作模板上海网站关键词排名
  • 广西建设人才网搜索引擎优化的目标
  • 比汉斯设计网站素材图片搜索识图入口
  • php网站架设教程英雄联盟韩国
  • 做毕设好的网站百度客服电话24小时
  • 上海手机网站建设电话咨询seo综合查询系统
  • wordpress 4.6 中文版沈阳seo
  • 文件管理软件天津搜索引擎优化
  • 九亭网站建设全国疫情高峰时间表最新
  • 青岛网站建设公司武汉seo收费
  • mvc网站建设的实验报告怎么做优化