title: Trying to reduce the levels of the categorical variable I want to predict (on R)
body: <p>I am working on a classification task with a categorical dependent variable with 99 levels (each corresponding to a country)</p>
  
  <p>I am using a decision tree, and it looks like I cannot have more than 32 levels so that I need to reduce the number of levels. I was thinking to cluster countries by similarity such that the ones that are similar based on the 200 variables I have (v1, v2, v3...), would be grouped.</p>
  
  <p>I was thinking of using UMAP in order to reduce the dimensionality of the dataset and then group the countries together (for instance Norway+Sweden, Laos+Cambodia or whatever) but I am having some hard times doing so, here is what I have so far ( working on a subsample), I tried to plot it but it doesn't much sense to me</p>
  
  <pre><code>data = sample_n(surveydata, 15000)
  cluster.data = data[, grep("v", colnames(surveydata))]
  library(umap)
  
  data.umap = umap(cluster.data)
  plot(data.umap$layout, col=data$Nationality)
  </code></pre>
  
  <p>(Nationality is the cathegorical variables with 99 levels I have to predict)</p>
  
  <p>do you know any method I can use to reduce the levels to less than 32?</p>
  
  <p>thank you in advance for your help!</p>