nano_single_pdp: Create PDP for a Single Model

nano_single_pdpR Documentation

Create PDP for a Single Model

Description

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

Usage

nano_single_pdp(model, data, vars, max_levels = 30, row_index = -1)

Arguments

model

a h2o model.

data

a dataset. Dataset used to create model.

vars

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

max_levels

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

row_index

a numeric vector of dataset rows numbers to be used to calculate PDPs. To use entire dataset, set to -1.

Details

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

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

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 pdp
 nano_single_pdp(model, property_prices, c("lot_size"))
 
 }

## End(Not run)

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