1
$\begingroup$

I'm training a random forest regression model on a dataset that consinsts of values in the range of 0-50. It has many values close to zero and only 500 observations. The R^2 is also small, about 0.25-0.4. When I use the model on a new test data set I get predictions exceeding the range of 0-50, how can I deal with that?

Sometimes I also get predicted values only in the range of 10-40 but I'm certain there should be many zeros and at least one 50.

Is there a better algorithm that can handle this problem?

I'm using R and the caret package. Thanks.

$\endgroup$
2
  • 1
    $\begingroup$ Is your output space continuous? Which is to say, should be output of your model be a real number in [0,50], or should it be one of the 51 whole numbers in the set [0,1,...,50]? In the latter case, you may want to try a forest of classification trees instead of regression trees. $\endgroup$ – Louis Cialdella Mar 16 '15 at 23:49
  • $\begingroup$ @LCialdella thanks for your answer. Indeed I do have only integer numbers from 1..50. But I don't have enough training material for every "class" if I treat the problem this way. I have many observations for zeros but for many integers I have no oberservation. $\endgroup$ – spore234 Mar 17 '15 at 13:20
2
$\begingroup$

The trainControl function has an argument called predictionBounds that will truncate predictions within a range of your choosing.

However, you might think about using some sort of transformation of the data to map [0-40] -> [-Inf, Inf]. I think that doing this will produce better models. log(y+1) maybe?

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