【问题标题】:'RandomForestRegressor' object has no attribute 'accuracy_score''RandomForestRegressor' 对象没有属性 'accuracy_score'
【发布时间】:2021-12-27 18:17:40
【问题描述】:
from sklearn.ensemble import RandomForestRegressor
RF=RandomForestRegressor(n_estimators=500,random_state=101)
RF.fit(predictors,target)
yPrediRF=RF.predict(x_test)
from sklearn.metrics import confusion_matrix,accuracy_score,recall_score,precision_score
RF.accuracy_score(x_test,y_test)

    AttributeError                            Traceback (most recent call last)

在 () ----> 1 RF.accuracy_score(x_test,y_test)

AttributeError: 'RandomForestRegressor' 对象没有属性 'accuracy_score'

【问题讨论】:

    标签: python model google-colaboratory random-forest attributeerror


    【解决方案1】:

    做

    accuracy_score(RF.predict(x_test), y_test)
    

    【讨论】:

    • 不支持连续报错。
    • ValueError Traceback (最近一次调用最后一次) in () ----> 1 accuracy_score(RF.predict(x_test), y_test) 1 帧/usr/local/lib/python3.7/dist-packages/sklearn/metrics/_classification.py in _check_targets(y_true, y_pred) 103 如果 y_type 不在 ["binary", "multiclass", "multilabel-indicator"] 中: --> 104 raise ValueError("{0} is not supported".format(y_type)) 105 106 if y_type in ["binary", "multiclass"]: ValueError: Continuous is not supported
    猜你喜欢
    • 1970-01-01
    • 2020-12-20
    • 2020-03-13
    • 1970-01-01
    • 1970-01-01
    • 2012-12-01
    • 2021-08-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多