Last chance! 50% off unlimited learning
Sale ends in
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
)
A list of SHAP values for each observation in vip_new
.
The name of the response variable to explain.
The training dataset containing predictor variables and the response variable.
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.
The dataset used for training the KNN model.
The dataset for which SHAP values are calculated.
The number of orderings for SHAP value calculations.
if (FALSE) {
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)
}
Run the code above in your browser using DataLab