# How to determine when a random forest regression or random forest classification is appropriate

I understand that random forest regression has a numeric response variable, and random forest classification has a categorical response variable. The response for my data is always an integer representing a rate per hour. It is fairly constant over time. I have one year of hourly data and only 31 different possible rates appear in that time. In my application, the rate cannot be a decimal, and it also cannot be 0 or negative.

I fit a RF regression and a RF classification to compare the results. (using randomForest in R)

My regression does not output integers, so I round the result to the nearest whole number.

The classification model is concerning, because there is a range of possible values, say [0,N], but not every possible value occurs in the historic data, so these classes will never be predicted.

Assuming random forest is the appropriate model here (and I understand it may not be), I want to understand if I should use a classification or regression on this data, and how to arrive at that decision. Since my data is numeric, is it inappropriate to use a classification?

• What about Poisson regression? – Jon Dec 12 '16 at 20:57
• I agree a Poisson regression is probably best. I think it's inappropriate to use classification for your example. If you use classification as a response, then it would be possible to assign high probabilities at both extremes which wouldn't make sense (i.e. high probability for a 0 or 100 rate per hour). Since the rate per hour is numeric and can be ranked, I think regression would be better – Peter Calhoun Dec 14 '16 at 0:03
• Thank you @PeterCalhoun for the reply. Very helpful insights. – StatisticianInStilettos Dec 14 '16 at 15:03
• I would compare Poisson regression and the (rounded) random forest regression by cross-validation and would not say a-priori that one method is better. – PhilippPro Dec 27 '16 at 10:55