Discrete values as target variable

I have discrete values in the target variable(Exactly 13 different values in total) . When I am giving that as input to Random forest Classifier ,it gives error that input as continuous. And if I give it to regressor it is predicting a value between the discrete values. How can I treat this problem

Topic classifier random-forest scikit-learn python

Category Data Science


I suspect the problem is that your discrete values are non-integer floats. The classifier's fit method runs type_of_target, which returns (in part):

'continuous': y is an array-like of floats that are not all integers, and is 1d or a column vector.

(source)

(Tracing the source code wasn't straightforward; a traceback of the error from you would have been helpful. For reference here, RandomForestClassifier inherits from BaseForest, whose fit method calls _validate_y_class_weight which (in the ForestClassifier child class) calls check_classification_targets which calls type_of_target.)

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.