小编New*_*bie的帖子

如何删除有关 n_estimators 将从 0.20 版本中的 10 更改为 0.22 版本中的 100 的警告?

运行其他功能良好的代码,我不断在 PyCharm 的控制台中收到以下消息(查看“控制台中的响应”:FutureWarning: The default value of n_estimators will change from 10 in version 0.20 to 100 in 0.22. "10 in version 0.22 中的 0.20 到 100。”,FutureWarning))。此外,该警告已多次列出。

到处查看,我了解到删除它的一种方法是将 n_estimators 从 10 更改为 100,从而扩展“森林中的树木”。然而,多次尝试都失败了。

from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier(n_estimators=100) <== added this line; not sure, if ok!
random_forest_classifier = RandomForestClassifier()
random_forest_classifier.fit(X_train, y_train)
y_pred_rfc = random_forest_classifier.predict(X_test)

import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
warnings.simplefilter(action='ignore', category=DeprecationWarning)
warnings.simplefilter(action='ignore', category=RuntimeWarning)

print("\nConfusion Matrix")
cm_random_forest_classifier = confusion_matrix(y_test,y_pred_rfc)
print(cm_random_forest_classifier, end="\n\n")

print("\nCalculating the accuracy from the confusion matrix for Random …
Run Code Online (Sandbox Code Playgroud)

python-3.x random-forest scikit-learn

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

python-3.x ×1

random-forest ×1

scikit-learn ×1