nano_constructors: Creating Nano Object

new_nanoR Documentation

Creating Nano Object

Description

constructors for nano object

Usage

new_nano(
  x = list(grid = rep(list(NA), 10), model = rep(list(NA), 10), metric = rep(list(NA),
    10), data = rep(data.table(NA), 10), varimp = rep(list(NA), 10), pdp = rep(list(NA),
    10), ice = rep(list(NA), 10), interaction = rep(list(NA), 10), meta = rep(list(NA),
    10), n_model = as.integer(0))
)

validate_nano(x)

create_nano(
  grid = rep(list(NA), 10),
  model = rep(list(NA), 10),
  metric = rep(list(NA), 10),
  data = rep(data.table(NA), 10),
  varimp = rep(list(NA), 10),
  pdp = rep(list(NA), 10),
  ice = rep(list(NA), 10),
  interaction = rep(list(NA), 10),
  meta = rep(list(NA), 10),
  n_model = as.integer(length(grid) - sum(sapply(grid, typeof) == "logical"))
)

Arguments

x

list of lists with elements containing the below parameters.

grid

list of grids created by h2o.

model

list of models created by h2o, belonging to their respective grids.

data

list of datasets used to create each model.

varimp

list of datasets containing variable importance for each model.

pdp

list of datasets containing partial dependencies for each model.

ice

list of datasets containing initial conditional expectations for each model.

interaction

list of datasets containing interactions for each model.

meta

list of lists containing meta information for each model such as parameters, hyper-parameters and model type.

n_model

number of created models.

Details

Creates a nano objected which consists of a list of list. If no arguments are supplied, nano object is created with 10 elements initialised for each list. If supplying arguments, must supply arguments for grid and data. These must be in list format. If the underlying datasets for each grid are identical, then it is sufficient to only enter data as a list of a single dataset. If supplying the above arguments, it is optional to include 'model', 'varimp', 'pdp', ice, 'interaction' and 'meta⁠. In fact, it is recommended to not provide ⁠meta' since has a strict structure which other functions are dependent on, and will be calculated automatically if not provided.

If 'model' is not supplied, then by default, model' will be taken as the best model from 'grid'. If 'varimp', 'pdp', ice or interaction are not supplied, they will be initialised as NA. When supplying arguments, extra elements will be initialised so total number of elements for each list is 10.

Value

a nano object

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 grids
 grid_1 <- h2o.grid(x               = var,
                    y               = response,
                    training_frame  = train,
                    algorithm       = "randomForest",
                    hyper_params    = list(ntrees = 1:2),
                    nfolds          = 3,
                    seed            = 628)

 grid_2 <- h2o.grid(x               = var,
                    y               = response,
                    training_frame  = train,
                    algorithm       = "randomForest",
                    hyper_params    = list(ntrees = 3:4),
                    nfolds          = 3,
                    seed            = 628)

 
 obj <- create_nano(grid = list(grid_1, grid_2),
                    data = list(property_prices), # since underlying dataset is the same 
                    ) # since model is not entered, will take best model from grids
 }

## End(Not run)

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