The xai2cloud package allows for simple deployment of an R model as a cloud service. Any predictive model from the local R console can be converted into a REST service available remotely in the DigitalOcean cloud. GET and POST methods are created automatically for elementary XAI methods such as Break Down and Ceteris Paribus. There will be more in the future.
For years, I have been suffering from the fact that R objects created in the R console cannot be easily governed, managed nor shared between computers. To work around this problem, from 2013 we are developing the archivist package together with Marcin Kosiński. It allows storing objects along with meta-data in a SQL database. Thanks to this you can easily search for objects created in the past.
But storing inactive copies of objects is not enough! How much better would it be to take a model we just trained in the console, and turn it into an independent component living autonomously in the cloud. It would be so easy to share a remote access to the predict function. Moreover, together with the model, the service should automatically create hooks for XAI methods.
Now you can do this easily with the xai2cloud package. See an example swagger for the Titanic Random Forest model. And here is a short technical introduction prepared by the maintainer.
Author: Adam Rydelek
The new R package, xai2cloud, makes cloud deployment of your model easy. Recently we can observe an increase in demand for interpretable models. Machine Learning has been widely used in many fields for some time now but the trends are changing. Nowadays an accurate black box is no longer enough.
The future is in the cloud
We use the DigitalOcean as Cloud Computing Service. It offers easy to use, easy to configure, and reasonably priced deployment for small and medium-sized projects.
xai2cloud creates a REST API running on the web which can be used in various ways. You can utilize the built-in Swagger as an easy to use, interactive interface containing all the crucial information about your model.
To use this package you need to first configure the cloud environment (just once). Then you can add models to the configured droplet.
Set up the environment
Setting up a whole new web application for your models has never been that easy. All you need to do in order to deploy a nearly unlimited number of explainers is to follow the four steps below:
- Create a new DigitalOcean account with $100 free starting credit (of course, you can also use another cloud provider).
- Create and deploy an SSH key to your DigitalOcean’s account.
- Install required R packages (full list).
- Setup your new droplet using just one R function.
do_setup(model_package = c(“packages that shall be preinstalled in the droplet”))
Deploy the model
Now you are all set to share your first model/explainer using xai2cloud. The first step is to create a model and an explainer for it. For example purposes the chunk below builds a random forest model on the titanic_imputed dataset from DALEX.
- Create a model
model <- ranger(survived~., data = titanic_imputed, classification = TRUE)
2. Create an explainer
explainer <- explain(model, data = titanic_imputed, y = titanic_imputed$survived)
3. Check your newly created droplet’s ID
4. Deploy a web application using xai2cloud.
deploy_explainer(explainer, model_package = “randomForest”,
That’s it. Your explainer is now available at your droplet’s IP address.
- Check the package’s GitHub website for a detailed setup guide and more examples.
- In case of problems scan through the deployment tutorial.
- Visit package’s GitHub repository for more information and leave a star to keep up to date with the changes.