I'm applying a random forest algorithm, using the randomForest library in R, on a data set with 3 variables (gre, gpa, rank), one of the variables (rank) is categorical with 4 levels (1, 2, 3, 4), when extracting feature importance I get the "Mean Decrease Gini" of each variable, my question is: Is there a way to get the importance of each level of the rank predictor, the influence of each one of'em on the dependent variable, the significance of each or something similar to these three in R when using a randomForest classifier or any classifier for that matter?
The code:
library(randomForest)
mydata <- read.csv("https://stats.idre.ucla.edu/stat/data/binary.csv")
mydata$rank <- factor(mydata$rank)
RF <- randomForest(factor(admit) ~gre + gpa + rank, data = mydata)
importance(RF)
output:
A matrix: 3 × 1 of type dbl
MeanDecreaseGini
gre 30.63603
gpa 42.76386
rank 18.85539
Thanks in advance.