Quantcast
Channel: r software hub
Viewing all articles
Browse latest Browse all 1015

Making an R based ML model accessible through a simple API

$
0
0

By FishyOperations

Building an accurate machine learning (ML) model is a feat on its own. But once you’re there, you still need to find a way to make the model accessible to users. If you want to create a GUI for it, the obvious approach is going after shiny. However, often you don’t want a direct GUI for a ML model but you want to integrate the logic you’ve created into an existing (or new) application things become a bit more difficult.

Let’s say you’ve created a robust ML model in R and explain the model to your in-house IT department, it is (currently) definitely not a given that they can easily integrate it. Be it either due to the technology used is unfamiliar to them or because they simply don’t have a in-depth knowledge on ML.

There are a lot of way to go about this. One way (and the focus of this post) is to built a sort of “black-box” model which is accessible through a web-based API. The advantage of this is that a web call can be very easily made from (almost) any programming language, making integration of the ML model quite easy.

Below an example ML model is made accessible by using Jug (disclaimer: I’m the author of Jug :).

Training the model

We start by creating a very simple model based on the mtcars dataset and the randomForest package (don’t interpret this as the way to correctly train a model). This model is then saved to the file system.

The model tries to predict mpg based on the disp, wt and hp variables.

The summary of the resulting model:


Call:
randomForest(formula = mpg ~ disp + wt + hp, data = mtcars)
Type of random forest: regression
...read more

Source:: r-bloggers.com


Viewing all articles
Browse latest Browse all 1015

Trending Articles