glob_knn_vis {viralx} | R Documentation |
Global Visualization of SHAP Values for K-Nearest Neighbor Model
Description
This function generates a visualization for the global feature importance of a K-Nearest Neighbors (KNN) model trained on HIV data with specified hyperparameters.
Usage
glob_knn_vis(vip_featured, hiv_data, knn_hyperparameters, vip_train, v_train)
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:
|
vip_train |
The dataset used for training the KNN model. |
v_train |
The response variable used for training the KNN model. |
Value
A visualization of global feature importance for the KNN model.
Examples
library(dplyr)
set.seed(123)
hiv_data <- train2
knn_hyperparameters <- list(neighbors = 5, weight_func = "optimal", dist_power = 0.3304783)
vip_featured <- c("cd_2022")
vip_features <- c("cd_2019", "vl_2019", "cd_2021", "vl_2021", "vl_2022")
vip_train <- train2 |>
dplyr::select(rsample::all_of(vip_features))
v_train <- train2 |>
dplyr::select(rsample::all_of(vip_featured))
glob_knn_vis(vip_featured, hiv_data, knn_hyperparameters, vip_train, v_train)
[Package viralx version 1.3.0 Index]