1
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Check the documentation for the software you’re using. A continuous response variable might be the default. $\endgroup$ – Dave Mar 26 at 16:18
  • $\begingroup$ What are the 13 values? $\endgroup$ – Ben Reiniger Mar 26 at 16:27
0
$\begingroup$

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.)

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.