viralx_knn_vis {viralx}R Documentation

Visualize SHAP Values for K-Nearest Neighbor Model

Description

Visualizes SHAP (Shapley Additive Explanations) values for a KNN (K-Nearest Neighbor) model by employing the DALEXtra and DALEX packages to provide visual insights into the impact of a specified variable on the model's predictions.

Usage

viralx_knn_vis(
  vip_featured,
  hiv_data,
  knn_hyperparameters,
  vip_train,
  vip_new,
  orderings
)

Arguments

vip_featured

The name of the response variable to explain.

hiv_data

The training dataset containing predictor variables and the response variable.

knn_hyperparameters

A list of hyperparameters for the KNN model, including:

  • neighbors: The number of neighbors to consider.

  • weight_func: The weight function to use.

  • dist_power: The distance power parameter.

vip_train

The dataset used for training the KNN model.

vip_new

The dataset for which SHAP values are calculated.

orderings

The number of orderings for SHAP value calculations.

Value

A list of SHAP values for each observation in vip_new.

Examples

## Not run: 
set.seed(123)
hiv_data <- train2
knn_hyperparameters <- list(neighbors = 5, weight_func = "optimal", dist_power = 0.3304783)
vip_featured <- c("cd_2022")
vip_train <- hiv_data
vip_new <- vip_train[1,]
orderings <- 20
viralx_knn_vis(vip_featured, hiv_data, knn_hyperparameters, vip_train, vip_new, orderings)

## End(Not run)

[Package viralx version 1.3.0 Index]