View source: R/viralx_knn_shap.R
| viralx_knn_shap | R Documentation | 
This function calculates SHAP (SHapley Additive exPlanations) values for a K-Nearest Neighbors (KNN) model trained on HIV data with specified hyperparameters.
viralx_knn_shap(
  vip_featured,
  hiv_data,
  knn_hyperparameters,
  vip_train,
  vip_new,
  orderings
)
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.  | 
vip_new | 
 The dataset for which SHAP values are calculated.  | 
orderings | 
 The number of orderings for SHAP value calculations.  | 
A list of SHAP values for each observation in vip_new.
## Not run: 
set.seed(123)
hiv_data <- train2
knn_hyperparameters <- list(neighbors = 5, weight_func = "optimal", dist_power = 0.3304783)
vip_featured <- "cd_2022"
vip_train <- hiv_data
vip_new <- vip_train[1, ]
orderings <- 20
viralx_knn_shap(vip_featured, hiv_data, knn_hyperparameters, vip_train, vip_new, orderings)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.