mrInteractions: Calculate and visualize feature interactions

View source: R/mrInteractions.R

mrInteractionsR Documentation

Calculate and visualize feature interactions

Description

This function calculates and visualizes interactions in the model using bootstrapping. It provides overall, one-way, and two-way interactions for specified features.

Usage

mrInteractions(yhats, X, Y, num_bootstrap = 1, feature = feature, top.int = 10)

Arguments

yhats

A list of model predictions.

X

The predictor data.

Y

The response data.

num_bootstrap

The number of bootstrap samples to generate (default: 1).

feature

The feature for which interactions need to be calculated.

top.int

The number of top interactions to display (default: 10).

Value

A list containing the visualizations for overall, one-way, and two-way interactions, as well as the interaction dataframes.

Examples

## Not run: 
# Example usage:
#set up analysis
Y <- dplyr::select(Bird.parasites, -scale.prop.zos)%>% 
dplyr::select(sort(names(.)))#response variables eg. SNPs, pathogens, species....
X <- dplyr::select(Bird.parasites, scale.prop.zos) # feature set
X1 <- Y %>%
dplyr::select(sort(names(.)))
model_rf <- 
rand_forest(trees = 100, mode = "classification", mtry = tune(), min_n = tune()) %>% #100 trees are set for brevity. Aim to start with 1000
set_engine("randomForest")
yhats_rf <- mrIMLpredicts(X=X, Y=Y,
X1=X1,'Model=model_rf , 
balance_data='no',mode='classification',
tune_grid_size=5,seed = sample.int(1e8, 1),'morans=F,
prop=0.7, k=5, racing=T) 
int_ <- mrInteractions(yhats=yhats_rf, X, Y, num_bootstrap=10,
feature = 'Microfilaria', top.int=10)
int_[[1]] # overall plot
int_[[2]] # individual plot for the response of choice 
int_[[3]] #two way plot# 
## End(Not run)

nfj1380/mrIML documentation built on May 17, 2024, 7:41 a.m.