Building a fully custom container for R
R is a popular language for data exploration and analysis. In this example, we're going to build a custom container to train and deploy a linear regression model on the Boston Housing dataset.
The overall process is similar to building a custom container for Python. Instead of using Flask
to build our prediction API, we'll use plumber
(https://www.rplumber.io).
Coding with R and Plumber
Don't worry if you're not familiar with R. This is a really simple example, and I'm sure you'll be able to follow along:
- We write a function to train our model. It loads the hyperparameters and the dataset from the conventional paths. It normalizes the dataset if we requested it:
# train_function.R library("rjson") train <- function() {Â Â Â Â hp <- fromJSON(file = Â Â Â Â Â Â Â Â Â Â '/opt/ml/input/config/hyperparameters.json')Â ...