viralx_knn {viralx}R Documentation

Explain K-Nearest Neighbors Model

Description

Explains the predictions of a K-Nearest Neighbors (KNN) model for CD4 and viral load data using the DALEX and DALEXtra packages. It provides insights into the specified variable's impact on the KNN model's predictions.

Usage

viralx_knn(vip_featured, hiv_data, knn_hyperparameters, vip_train, vip_new)

Arguments

vip_featured

The name of the variable to be explained.

hiv_data

The data frame containing the CD4 and viral load data.

knn_hyperparameters

A list of hyperparameters to be tuned for the KNN model.

vip_train

The training data used for creating the explainer object.

vip_new

A new observation for which to generate explanations.

Value

A data frame containing explanations for the specified variable.

Examples

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,]
viralx_knn(vip_featured, hiv_data, knn_hyperparameters, vip_train, vip_new)

[Package viralx version 1.3.0 Index]