deploy_explainer: Deploy An Explainer

Description Usage Arguments Examples

View source: R/deploy_explainer.R

Description

This function deploys an explainer as an REST API with an corresponding swagger. A new folder will be created in your working directory containing a plumber R file and an .rda file of the explainer. Deployment can be done either locally or directly to the DigitalOcean's droplet. Full guide on setting up DigitalOcean's droplet and deploying to the cloud can be found on package's GitHub page.

Usage

1
2
3
4
5
6
7
8
deploy_explainer(
  exp_name,
  model_package,
  droplet = NA,
  port = 8088,
  deploy = TRUE,
  title = "xai2cloud"
)

Arguments

exp_name

DALEX explainer object or an .rda filename in your working directory containing the explainer

model_package

Name of package used to build the model, eg: "randomForest", "gbm".

droplet

If you want to deploy the API locally leave the value as NA. If you want to deploy to DigitalOcean, use the droplet's ID which can be checked by using analogsea::droplets()

port

Port on which you want your API to be deployed

deploy

Boolean telling whether the plumber file is run on set port

title

Title to be seen in Swagger

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Create a model
library("ranger")
library("DALEX")
model <- ranger(survived~., data = titanic_imputed)

# Create DALEX explainer
explainer <- explain(model,
                     data = titanic_imputed[,-8],
                     y = titanic_imputed$survived)

# Deploy the API
# If you want the API to deploy automatically, set deploy parameter to TRUE

# Locally
deploy_explainer(explainer, model_package = "ranger",
  port = 8070, deploy=FALSE, title = "Local Example")

# To the cloud
## Not run: 
my_droplets <- analogsea::droplets()

# Choose the correct droplets name - xai2cloudExamples in this case
specific_droplet <- my_droplets$xai2cloudExamples
droplet_id <- specific_droplet$id

deploy_explainer(explainer, model_package = "ranger",
                 droplet = droplet_id, port = 8070,
                 title = "Titanic Example")

## End(Not run)

ModelOriented/xai2cloud documentation built on June 18, 2020, 6:46 p.m.