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
# Using an explainer object, locally
# Load data and create model
model_data <- DALEX::titanic_imputed
titanic_glm <- glm(survived ~ gender + age + fare,
                       data = model_data, family = "binomial")
# Create DALEX explainer
explain_titanic_glm <- DALEX::explain(titanic_glm,
                           data = model_data,
                           y = model_data$survived,
                           label = "glm")
# Deploy the API
# If you want the API to deploy automatically, set deploy parameter to TRUE

# Locally
deploy_explainer(explain_titanic_glm, model_package = "stats",
  title = "Titanic", port = 8070, deploy=FALSE)

# To the cloud
## Not run: 
analogsea::droplets()
deploy_explainer(explain_titanic_glm, model_package = "stats",
  title = "Titanic", droplet = 136232162,
  port = 8080)

## End(Not run)

Adamoso/xai2cloud documentation built on April 16, 2020, 3:15 p.m.