Jack
Jack

Reputation: 1

How to use predict() with xgboost package in a Shiny app online?

In my app.R file, my code for the prediction is: predict(fit, test_set())

The fit object (.rds) is from the xgboost package.

At the very beginning of the app.R file, I put: library(xgboost)

The app is working well on my local server. But if I try to deploy it online, it's not working. I have the following warning in my logs:

Warning: Error in UseMethod: no applicable method for 'predict' applied to an object of class "c('_xgb.Booster', 'model_fit')"

Do you have some ideas to solve my issue?

Thank you in advance.

Upvotes: 0

Views: 512

Answers (1)

Jack
Jack

Reputation: 1

I solve my own problem. In my logs, in shiny.io, there was a message telling me that "parnsnip" was missing. I add "library(parnsnip)" to my code, and it works perfectly. Parnsnip was required to use the predict function with my fit object. My fit object come from several functions of the package tidyverse.

Bretauv, as my model fit was very long to obtain (process using tidyverse), it was difficult for me to include a reproducible (code) example.

Upvotes: 0

Related Questions