| viralx_knn_glob {viralx} | R Documentation | 
Global Explainers for K-Nearest Neighbor Models
Description
This function calculates global feature importance for a K-Nearest Neighbors (KNN) model trained on HIV data with specified hyperparameters.
Usage
viralx_knn_glob(
  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 list of global feature importance measures for each predictor variable.
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))
viralx_knn_glob(vip_featured, hiv_data, knn_hyperparameters, vip_train, v_train)
[Package viralx version 1.3.0 Index]