gravatar for carina2817

2 hours ago by


I am trying to create partial dependence plots for my multinomial gbm predictions but I haven't been able to figure out how to produce the correct plots, the ones that I am getting have a single line instead of a line for every level of my response variable (in my case are 3 different species names). I have seen several examples but they require objects created with other packages (not gbm objects) and most of the examples don't include multinomial variables.

gbm fit<-readRDS(file = "gbm_fit_final1_organism.rds")

getting table with variable importance

  cBars = 10,
  method = relative.influence, 
  las = 2)

The table looks like this:

      var   rel.inf
 MA0356.1 22.641689
 MA1071.1 21.707397
 MA0311.1 16.010605
 MA0210.1  7.249431
 MA0271.1  4.958186

I used the following code to generate the partial dependence plot for the most important predictor variable: %>%
  partial(pred.var = "MA0356.1", n.trees =$n.trees, grid.resolution = 100, prob=T) %>%
  autoplot(rug = TRUE, train = motifs_train.100) +

motifs_train.100 is the training data that I used to create the gbm fit (, I am not sure if it is necessary to add the training data.

I got the following plot:

plot 1

I would like to get a plot like this one (I think I need to get marginal probabilities):

plot with a line for every level of response

I am very new to gbm package. I don't know if there is an argument of the function partial that I am omitting, or if there is a better function to do this. Any help would be appreciated. Thanks!


modified 2 hours ago

2 hours ago


Source link