bgreenwell / pdp

A general framework for constructing partial dependence (i.e., marginal effect) plots from various types machine learning models in R.
http://bgreenwell.github.io/pdp
93 stars 12 forks source link

train() + gbm #105

Closed joshualerickson closed 4 years ago

joshualerickson commented 4 years ago

Having a hard time getting the partial() to work with a train object that was derived with gbm. I've had it work before but now I keep running into the error below.

"Error in UseMethod("predict") : no applicable method for 'predict' applied to an object of class "gbm"

Somewhere the 'predict' functions in caret and pdp are crossing up? Not sure if this is a easy fix like package management or '::' but I can't seem to figure it out. Any help would be much appreciated. Works when I use random forest and below is the script for the train object I'm using.Thanks.

rec_tune12g <- recipe(stream ~ ., data = traintune) %>% update_role(-accum30,-nppmmid30agg,-stream, new_role = "bring along")

set.seed(1234) rfe12gtune <- train(rec_tune12g, data = traintune, method = "gbm", tuneLength = 20, metric = "AUC", distribution = "bernoulli", trControl = trainControl(method = "repeatedcv", repeats = 5, classProbs = TRUE, savePredictions = 'all', index = indices12tune$index, summaryFunction = multiClassSummary), tuneGrid = gbmGrid)

bgreenwell commented 4 years ago

Hey @joshualerickson did you find the issue?

joshualerickson commented 4 years ago

Hey yes, just needed to add library(gbm) before running and also library(randomForest). I think it's a train() thing as I think i've seen that somewhere else.