Site icon R-bloggers

Deploying a CARET Machine Learning model as an API with Plumber

[This article was first published on R Blogs – Hutsons-hacks, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

I have deployed many models in my time working as a Senior Data Scientist and as a Principal Analyst at Nottingham University Hospitals. I have deployed into SQL, on client sites, in Node.JS and other types of deployment. This was the first time I used the Plumber library, and I loved it.

How to deploy your model as an API

My new YouTube page is up and it takes you through the steps of how you can deploy your machine learning model as an API:

Training a supervised machine learning model

In this section I will use a number of packages to train a R model. The packages include:

Creating the Plumber files

This has two main functions – a GET request which shows if the website is running and a POST request which is used to pass JSON data from the API, to the model and then the predictions are returned to the API. The R documentation on Plumber is extensive and definitely worth checking out.

Where to get the supporting files?

The supporting GitHub repository contains everything you need to get going. Hereunder are the important files:

Where to go next

To deploy your API you could use a number of different methods:

The full list is in the Plumber official hosting guide.

Coming soon…

I will write a how to deploy on docker as a component to this, but until then, I hope you find the tutorials useful, and remember:

To leave a comment for the author, please follow the link and comment on their blog: R Blogs – Hutsons-hacks.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.