View source: R/viralx_knn_vis.R
| viralx_knn_vis | R Documentation | 
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.
viralx_knn_vis(
  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_vis(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.