当我运行这段代码时:
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‘对象没有属性'target_type_’
有人有主意吗?谢谢
当我调试时,在指令roc_viz = ROCAUC(rf)上
我知道错误:
无法为< 'yellowbrick.classifier.rocauc.ROCAUC'类获得repr的
发布于 2022-02-26 22:35:05
几件事
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)
发布于 2022-09-02 10:13:19
您的代码在您原来的问题中,上面只需要增加一行,它将顺利工作。请在正确的位置添加以下一行:
roc_viz.fit(X_train, y_train)您可以在下面的原始代码中看到这一行添加的代码,它将以这种方式工作,不会出错:
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.fit(X_train, y_train)
roc_viz.score(X_test, y_test)希望这能有所帮助!
https://stackoverflow.com/questions/70024992
复制相似问题