close

[Solved] Got continuous is not supported in RandomForestRegressor

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Got continuous is not supported in RandomForestRegressor in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Got continuous is not supported in RandomForestRegressor Error Occurs?

Today I get the following error Got continuous is not supported in RandomForestRegressor in python.

How To Solve Got continuous is not supported in RandomForestRegressor Error ?

  1. How To Solve Got continuous is not supported in RandomForestRegressor Error ?

    To Solve Got continuous is not supported in RandomForestRegressor Error Where X_test is samples, y_test is corresponding ground truth values. It will compute predictions inside.

  2. Got continuous is not supported in RandomForestRegressor

    To Solve Got continuous is not supported in RandomForestRegressor Error Where X_test is samples, y_test is corresponding ground truth values. It will compute predictions inside.

Solution 1

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.

Solution 2

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)

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read