random-forest - 错误 'RandomForestClassifier' 对象没有属性 'target_type_'

标签 random-forest yellowbrick

当我运行这段代码时:

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'

最佳答案

一些事情

  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)

关于random-forest - 错误 'RandomForestClassifier' 对象没有属性 'target_type_',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70024992/

相关文章:

python - scikit-learn ExtraTreeClassifier 和 RandomForestClassifier 的图

python - 如何在Python中获得随机森林模型的准确性?

python - 如何在 python 中对 PMML 模型进行超参数调优?

随机森林变量选择

python - Scikit-learn 和 Yellowbrick 给出不同的分数

python - 如何调整matplotlib图表图形

machine-learning - 尝试查看拟合模型的辨别阈值图

r - 使用 step_naomit 进行预测并使用 tidymodels 保留 ID

python - Yellowbrick t-SNE 拟合引发 ValueError

python - 从黄砖KElbowVisualizer中提取k