0
$\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$
3
  • $\begingroup$ Check the documentation for the software you’re using. A continuous response variable might be the default. $\endgroup$
    – Dave
    Mar 26, 2020 at 16:18
  • $\begingroup$ What are the 13 values? $\endgroup$
    – Ben Reiniger
    Mar 26, 2020 at 16:27
  • $\begingroup$ Are you sure it’s a problem that the model is not predicting an integer? Poisson regression, for instance, has integer $y$ values but does necessarily predict integers. Ditto for logistic regression. $\endgroup$
    – Dave
    Sep 10, 2021 at 10:48

1 Answer 1

1
$\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.)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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