【问题标题】:error 'RandomForestClassifier' object has no attribute 'target_type_'错误“RandomForestClassifier”对象没有属性“target_type_”
【发布时间】:2022-02-27 06:35:05
【问题描述】:

当我运行这段代码时:

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)

我得到错误:

无法获得

【问题讨论】:

    标签: random-forest yellowbrick


    【解决方案1】:

    几件事

    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)

    【讨论】:

      猜你喜欢
      • 2018-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-21
      • 2014-05-14
      • 2016-04-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多