标签:bsp param ams for amp cores set imp 最好
1.GridSeach(RandomRegressor(), param_grid, cv=3)
GridSearch第一个参数是算法本身, 第二个参数是传入的参数组合, cv表示的是交叉验证的次数
GridSearch 对给定的参数进行两两的组合搜索,比如参数为[1, 2, 3], [1, 2, 3], 那么此时就有9种参数的组合
from sklearn.grid_search import GridSearchCV from sklearn.ensemble import RandomForestRegressor from sklearn.datasets.california_housing import fetch_california_housing # 载入数据 housing = fetch_california_housing() # 列出参数列表 tree_grid_parameter = {‘min_samples_split‘:list((3, 6, 9)), ‘n_estimators‘:list((10, 50, 100))} # 进行参数的搜索组合 grid = GridSearchCV(RandomForestRegressor(), param_grid=tree_grid_parameter, cv=3) grid.fit(train_x, train_y) print(grid.grid_scores_) # 打印得分 print(grid.best_params_) # 打印最好的参数组合 print(grid.best_score_) # 打印最好的得分
机器学习入门-使用GridSearch进行网格参数搜索GridSeach(RandomRegressor(), param_grid, cv=3)
标签:bsp param ams for amp cores set imp 最好
原文地址:https://www.cnblogs.com/my-love-is-python/p/10280851.html