gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 05:52:50 24 4
gpt4 key购买 nike

当我运行这段代码时:

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com