Deploying trained CARET Machine Learning Model with Docker and 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 been busy learning Docker, as it was one of those things I have been putting off for a while. But, I am so glad that I did. Essentially, I have gone through all the pain so you don’t have to.

Building the ML Model and creating API with Plumber

I can’t tell you how much I love Plumber. This tool allows you to create REST APIs so quickly. Additionally, with the inclusion of swagger, it allows you to have a user interface to effectively deploy your machine learning models at scale.

To find out how to build the model with CARET and create the Plumber API, see:

Scaling up our web service with Docker

Building on the example above I then take you through the process of working with Docker. Docker is set out as below:

Hello Docker - Things Solver

This allows you to connect to a host Daemon and build images and containers. Here I show you how to build the image and run the service. This service can then be accessed in a web browser and would persist if you had a web server, Azure Cloud account or R Connect. The essence is it creates an isolated environment for you to build a mini R environment and deploy your services.

What the heck is Swagger?

I thought this was something from my Oasis days when I first heard it, thinking more Liam than Noel.

Swagger is an API framework to allow easy hosting of APIs and creates a nice user interface to test models. Otherwise you are stuck using postman and other HTTP apps to send and receive requests.

How can you deploy to Docker?

The YouTube below takes your through the process of:

  1. Testing the Plumber API
  2. Building a Dockerfile
  3. Deploying your API to Docker with a REST API Swagger interface
  4. Learn a bit of Windows Powershell, for good measure.

See how:

Where can I get this code?

The code can be accessed for each of the tutorials in the supporting GitHub account. Please feel free to have a nosey around other directories of interest. Also, please star and fork the code – I don’t mind.

It is good, as a Windows user, to be able to use Linux containers and deploy services under different Operating Systems. I like this comparison when my Linux friends pile on the pressure to uninstall Windows:

Windows Vs Mac Vs Linux: 10 Funny Jokes In Pictures

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.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)