1

当我运行这段代码时:

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)

我得到错误:

无法获得 <class 'yellowbrick.classifier.rocauc.ROCAUC' 的代表

4

1 回答 1

0

几件事

  1. 你总是需要适应可视化器

  2. 如果您已经安装了模型,则必须将参数设置is_fitted为 True

    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, is_fitted=True)

    roc_viz.fit(X_train, y_train)

    roc_viz.score(X_test, y_test)

于 2022-02-26T22:35:05.207 回答