# Response variable with very high number of class levels in R

I've got a dependent variable in R with about 11,000 class levels. There's ample data for modeling this many classes, however some statistical packages like h2o only support up to 1,000 classes or so.

What are the best options for classification models in R with this high number of class levels?

## 1 Answer

Cluster your n response classes into m clusters, where m < 1,000. With an incoming instance i assign it to one of the m clusters using your favorite classification algorithm. Once the instance has been assigned to a specific cluster, you just need to run it through a classifier trained on the classes that comprise that particular cluster.

I've used this particular architecture to assign texts to one of n possible "emotions", which I illustrate below. The incoming text was first scored with a binary classifier trained on positive & negative texts. Given the text's probability of being positive (as predicted by the classifier), the text was then routed to either a series of all positive or a series of all negative emotion classifiers where it was a assigned a specific emotion.

This same sort of design should work your case. First you assign your instance a cluster. Given that assignment, send your instance to the next stage - where the final classification occurs.

• Sorry if this description is murky - its surprisingly hard to describe this - does anybody know if there is a design pattern name for this type of ensemble? – Brandon Loudermilk May 13 '16 at 23:38
• I have a similar problem I'm working on right now. It's not unlike taking the groups from the first level of a regression tree, then taking the data that fall into those groups, and running a separate model depending on which group it falls into. I'm definitely lacking the vocabulary here. I just want to take the first two turns of Guess Who, not play the whole game ... – rbatt May 15 '16 at 0:53