Hello, I’ve been getting an error message I can’t figure out when trying to plot PDP’s from a XGBoost model that I’ve fit. Here’s the code snipped that is throwing the error:
Smooth_PDP = final_model %>%
partial(pred.var = “Nitrogen”, train=as.matrix(dataset[,-1])) %>%
autoplot(smooth = TRUE, ylab = expression(f(Nitrogen))) +
The error is:
*Error in if (object$params$objective %in% c(“reg:linear”, “reg:logistic”, : *
- argument is of length zero*
At one point I made a code change and the error changed to something about “partial plots can only be made for classification and regression models.” I updated all the packages being used, so I hope that’s not an issue. I never specified the objective function in the params of the original fitting of “final_model” , but the default is “reg:squarederror”, which is what I want (this is a regression model), so why is it asking again? I have tried explicitly re-stating the params just above the PDP code, and also adding the params into the function call to partial, but that didn’t seem to help either.
Thanks for any advice!