我正在嘗試在 sklearn 中運行隨機森林分類器:
from sklearn.ensemble import RandomForestClassifier
model_rf_man = RandomForestClassifier(n_estimators= 183, max_features= 'sqrt', max_depth = 10, min_samples_split=5, min_samples_leaf = 3, bootstrap = True)
model_rf_man.fit(x_training_data, y_training_data)
y_pred_rf_man = model_rf_man.predict(x_test_data)
from sklearn.metrics import classification_report
from sklearn.metrics import plot_roc_curve
print(classification_report(y_test_data, y_pred_rf_man))
plot_roc_curve(y_pred_rf_man, x_test_data, y_test_data)
然后我得到這個錯誤:
ndarray should be a binary classifier
我不知道這是什么意思。我認為我的代碼是正確的,其他模型運行得很好。如果您有任何有用的建議
uj5u.com熱心網友回復:
傳遞給的第一個引數plot_roc_curve應該是您的估算器物件model_rf_man。查看檔案
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/456584.html
標籤:Python 机器学习 scikit-学习 错误处理 随机森林
上一篇:異步函式后陣列未排序
下一篇:如何通過回圈獲得混淆矩陣值?
