nano_single_ice: Create ICE for a Single Model

nano_single_iceR Documentation

Create ICE for a Single Model

Description

Creates ICEs for variable(s) for a single h2o model.

Usage

nano_single_ice(
  model,
  data,
  vars,
  max_levels = 30,
  quantiles = seq(0, 1, 0.1),
  targets = NULL
)

Arguments

model

a h2o model.

data

a dataset. Dataset used to create model.

vars

vector of characters. Vector containing variables in data to create ICEs

max_levels

a numeric. Maximum number of unique levels to calculate ICE for each variable.

quantiles

a numeric vector of quantiles (numbers from 0 to 1) for each ICE to be calculated for.

targets

a character vector. Only applicable for classification models. Subset of levels of response variables which ICE should be calculated for.

Details

Creates a ICE for each variable specified in the vars argument given a h2o model.

For creating ICE, it is recommended to instead use the nano_ice function which is a wrapper for a series of functions which creates pdps. It is able to create ICEs directly from a nano object, for both single and multi models, and has the option to return plots of the ICEs.

Value

a data.tables containing pdps for each variable combined together.

Examples

## Not run: 
if(interactive()){
 library(h2o)
 library(nano)
 
 h2o.init()
 
 # import dataset
 data(property_prices)
 train <- as.h2o(property_prices)
 
 # set the response and predictors
 response <- "sale_price"
 var <- setdiff(colnames(property_prices), response)
 
 # build model
 grid <- h2o.grid(x               = var,
                  y               = response,
                  training_frame  = train,
                  algorithm       = "randomForest",
                  hyper_params    = list(ntrees = 1:2),
                  nfolds          = 3,
                  seed            = 628)
 model <- h2o.getModel(grid@model_ids[[1]])
 
 # calculate ICE
 nano_single_ice(model     = model, 
                 data      = property_prices, 
                 vars      = c("lot_size"), 
                 quantiles = seq(0, 1, 0.1))
 
 }

## End(Not run)

Nanoputian628/nano documentation built on Oct. 30, 2023, 3:28 p.m.