### 随机森林调参
start = time()
from sklearn.grid_search import GridSearchCV
rf = RandomForestClassifier(n_jobs = 4,random_state=0)
param_1 = {'n_estimators': list(range(30,91,10)),
'max_depth':[10,50,100,200],
'min_samples_split':[2,5,10],
'min_weight_fraction_leaf':[0.0,0.1,0.2,0.3,0.4,0.5]}
gs = GridSearchCV(rf,param_grid=param_1,n_jobs = 3)
gs.fit(X_train,y_train)
print(gs.scorer_)
print(gs.best_params_,gs.best_score_)
print(gs.best_estimator_)
end = time()
print ("时间:"+str((end-start)/60))
随机森林调参代码
最新推荐文章于 2022-09-13 10:54:19 发布