当我运行这段代码时:
from yellowbrick.classifier import ROCAUC
from sklearn.ensemble import RandomForestClassifier
rf = RandomForestClassifier(**{"max_features": 0.4, "n_estimators":15,"min_samples_leaf": 0.1,"random_state":42})
rf.fit(X_train, y_train)
roc_viz = ROCAUC(rf)
roc_viz.score(X_test, y_test)
我有这个错误
'RandomForestClassifier' object has no attribute 'target_type_'
有人有想法吗?谢谢
当我调试时,按照指令
roc_viz = ROCAUC(rf)
我得到错误:
unable to get repr for <class 'yellowbrick.classifier.rocauc.ROCAUC'
最佳答案
一些事情
你总是需要适配可视化工具
如果您已经拟合了您的模型,那么您必须将参数
is_fitted
设置为 Truerf = RandomForestClassifier(**{"max_features": 0.4, "n_estimators":15,"min_samples_leaf": 0.1,"random_state":42})
rf.fit(X_train, y_train)
roc_viz = ROCAUC(rf, is_fitted=True)
roc_viz.fit(X_train, y_train)
roc_viz.score(X_test, y_test)
关于random-forest - 错误 'RandomForestClassifier' 对象没有属性 'target_type_',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70024992/