【发布时间】:2022-01-22 11:33:06
【问题描述】:
尝试如下训练随机森林分类器:
%%time
# defining model
Model = RandomForestClassifier(random_state=1)
# Parameter grid to pass in RandomSearchCV
param_grid = {
"n_estimators": [200,250,300],
"min_samples_leaf": np.arange(1, 4),
"max_features": [np.arange(0.3, 0.6, 0.1),"sqrt"],
"max_samples": np.arange(0.4, 0.7, 0.1)
}
#Calling RandomizedSearchCV
randomized_cv = RandomizedSearchCV(estimator=Model, param_distributions=param_grid, n_iter=50, n_jobs = -1, scoring=scorer, cv=5, random_state=1)
#Fitting parameters in RandomizedSearchCV
randomized_cv.fit(X_train_over,y_train_over) ## Complete the code to fit the model on over sampled data
print("Best parameters are {} with CV score={}:" .format(randomized_cv.best_params_,randomized_cv.best_score_))
我收到以下错误: "610: FitFailedWarning: Estimator fit failed。这些参数在这个训练测试分区上的分数将设置为 nan。"
知道我的代码是否有错误吗?
【问题讨论】:
标签: python scikit-learn random-forest