Can a Random Forest be trained to appropriately predict count data? How would this proceed? I have quite a extensive range of values so classification doesn't really make sense. If I would use regression would I simply truncate the results? I'm quite lost here. Any ideas?
There is a R package called
mobForest which can fit a real random forest for count data. It is based on
mod() (model-based recursive partitioning) in the
party package. It performs Poisson regression if the
family argument is specified as
poisson(). The package is no longer in the CRAN repository, but formerly available versions can be obtained from the archive.
If you are not restricted to random forest / bagging, a boosting version is also available for count data. That is,
gbm (generalized boosted regression models). It can also fit a Poisson model.
I see a few possibilities.
- You could bin the response into a few arbitrary categories and use a classification tree
- If the counts are typically very low, 0, 0, 0, 1, 0, 3, 0, 2, you could treat each integer count as a class and again use a classification tree (probably not your case). In these cases, it's going to be harder to get a high variance explained type metric as opposed to continuous regression.
- If the counts are not typically low and there is a lot of variation, I'd just go for it with a regression tree. Using poisson regression over linear regression, for instance, is only gravy when it comes to getting a good linear predictor. If you're not seeing good predictive power with the random forest, then I doubt a fancier model that specifically accommodates count data is going to do a lot for you.
Well, its not random forest, but CatBoost supports a poisson loss function that could be used for count regression with boosted trees: