By exposing the R Model as Rest API, we can let other applications to use model for the purposes it is designed for without having to worry about the underlying environment/architecture. We can do this using an R package - "Plumber". Plumber is straightforward and easy to use. It is an open source package that lets you create APIs by decorating the R functions with special annotations/comments. Comments can be prefixed with "#'" or "#*". "#'" is recommended.
- randomForest: R package used for taining the titanic problem using random forest algorithm. Check the random forest R Documentation for more details
- caret: R package used for plotting Confusion Matrix to evaluate model performance. Check the caret R Documentation for more details
- plumber: R package to create REST APIs. Check the rplumber Documentation for more details
- Postman: API Development Tool used for REST API validation. Check the Postman website for more details
- curl: Command line tool used for REST API validation. Check the curl website for more details
Dataset used as an example here is downloaded from Kaggle - Titanic: Machine Learning from Disaster
For a detailed walk-through of this project, read up ExposingModelAsAPI
Here are a few other packages in R that help in exposing R models through API development:
- DeployR - It is Microsoft's integration platform for R analytics inside web, mobile, desktop, dashboard as well as backend applications
- OpenCPU - Provides reliable and interoperable HTTP APIs for data analysis based on R. One of the likely one to choose for production
- Shiny - It is an R package that helps build interactive web applications from R
- rApache - It is a project supporting web application development using the R