Model Deployment and Plumber
plumber
modeling
This resource showcases how to expose a machine learning model built in R via a Plumber API. A model is first trained and saved as an .rds
file. The Plumber file loads this saved model from disk, interprets data submitted via POST request, and returns a JSON object containing predictions based on the input data. A simple Shiny app is provided to interact with the API. Click here for source code.
Model
Train a simple model that predicts MPG.
<- lm(mpg ~ cyl + hp, data = mtcars)
cars_model saveRDS(cars_model, here::here("R", "model-api", "cars-model.rds"))
API
Build an API that predicts MPG based on user inputs and the trained model.
View the API on Connect | Dashboard view (login required)
Prediction app
Use a Shiny app to predicts MPG based from the API.