View source: R/nano_interaction.R
nano_interaction | R Documentation |
Calculated pair-wise variable interaction in a predictive model.
nano_interaction(nano, model_no = nano$n_model, vars, plot = FALSE)
nano |
object containing models to calculate interactions from. |
model_no |
the positions of each model in the list of models in the nano object for which the interactions should be calculated. If not entered, the last model is taken by default. |
vars |
a character vector of variables to calculate pair-wise interactions for. |
plot |
a logical specifying whether plots of the interactions should be created. |
The interactions are calculated by the Friedman's H-statistic (square root of the H
-squared test statistic) and takes on values between 0 (no interaction) to 1 (100% of standard
deviation of f(x) du to interaction). This package uses the Interaction
function from
the iml
package to calculate the H-statistic. Please see their manual for more details.
For the variables specified in the vars
argument, this funtion calculates the interaction
for each pair-wise interaction of that variable with every other variable used as a predictor
for the specified model.
nano object with interactions of specified models calculated. Also returns a
plot if plot = TRUE
.
## 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)
obj <- create_nano(grid = list(grid_1),
data = list(property_prices),
) # since model is not entered, will take best model from grids
# calculate all pair-wise interactions for the variable "lot_size"
nano <- nano_interaction(nano, 1, "lot_size", FALSE)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.