Got continuous is not supported error in RandomForestRegressor

前端 未结 2 1428
礼貌的吻别
礼貌的吻别 2021-01-01 11:50

I\'m just trying to do a simple RandomForestRegressor example. But while testing the accuracy I get this error

/Users/noppanit/anaconda/lib/pyt         


        
相关标签:
2条回答
  • 2021-01-01 12:14

    It's because accuracy_score is for classification tasks only. For regression you should use something different, for example:

    clf.score(X_test, y_test)
    

    Where X_test is samples, y_test is corresponding ground truth values. It will compute predictions inside.

    0 讨论(0)
  • 2021-01-01 12:20

    Since you are doing a classification task, you should be using the metric R-squared (co-effecient of determination) instead of accuracy score (accuracy score is used for classification purposes).

    To avoid any confusion I suggest you to use different variable name like reg/rfr.

    R-squared can be computed by calling score function provided by RandomForestRegressor, for example:

    rfr.score(X_test,Y_test)
    
    0 讨论(0)
提交回复
热议问题