sklearn.ensemble.RandomForestClassifier as a Regression?

8154
3
Jump to solution
08-11-2018 08:44 AM
HannesZiegler2
Occasional Contributor II

Hi, I'm attempting to use sklearn.ensemble.RandomForestClassifier as a regression, but when I run it, I get the following error regarding my dependent variable y: 

ValueError: Unknown label type: 'continuous'
0 Kudos
1 Solution

Accepted Solutions
HannesZiegler3
New Contributor II

Hey, I found out why. I was using sklearn.ensemble.RandomForestClassifier, which is for categorical data. Use sklearn.ensemble.RandomForestRegressor instead, which takes floating point i.e. "continuous" values.

View solution in original post

3 Replies
XanderBakker
Esri Esteemed Contributor

A similar problem has been reported here: python - ValueError: Unknown label type: 'continuous' - Stack Overflow . There are some suggestions that might help. BTW, the OP on Stack Overflow provided a lot more information. 

HannesZiegler3
New Contributor II

Hey, I found out why. I was using sklearn.ensemble.RandomForestClassifier, which is for categorical data. Use sklearn.ensemble.RandomForestRegressor instead, which takes floating point i.e. "continuous" values.

XanderBakker
Esri Esteemed Contributor

Great to hear you figured out what the problem was and thanks for posting back the result.