0

I have trained the following model through the train() function and using the "ranger" method. In my case, we are dealing with a very small dataset (about 100 samples) and where the predictors are 84 and with a binary outcome (0 or 1). The class to predict is the diagnosis, which is found as a factor. Thus, I have obtained the Overall importance of each predictor, but I would like to obtain the IMPORTANCE BY CLASS, that is, to know which predictors are used for the prediction of one diagnosis or another.

Here is the model code:

control_train <- trainControl(method = "repeatedcv", number = particiones,
                              repeats = repeticiones, seeds = seeds,
                              returnResamp = "final", verboseIter = FALSE,
                              allowParallel = TRUE, classProbs = TRUE, 
                              summaryFunction = defaultSummary)

set.seed(342)

model_rf <- ranger(Diagnosis ~ ., data = data,
                   method = "ranger",
                   tuneGrid = hiperparameters,
                   metric = c("Accuracy"),
                   trControl = control_train,
                   num.trees = 250, 
                   importance = "impurity")
model_rf

Thank you in advance!!!

I have already used the varImp function, but it only gives me the overall importance, and I would like to get the importance for each diagnosis.

0 Answers0