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
91 stars 12 forks source link

get_task fails in certain situations for xgboost #114

Open bgreenwell opened 3 years ago

bgreenwell commented 3 years ago

Seems like it will fail whever an xgboost model is fit without a params argument:

library(pdp)
library(xgboost)

boston <- pdp::boston
X <- data.matrix(subset(boston, select = -cmedv))
y <- boston$cmedv

set.seed(1612)
bst <- xgboost(X, label = y, nrounds = 100, verbose = 0)

partial(bst, pred.var = "chas", train = X)  # will fail
partial(bst, pred.var = "chas", train = X, type = "regression") 
bgreenwell commented 3 years ago

Need to check if bst$params$objective is NULL first.