nearest_neighbor_adaptive {tidydann} | R Documentation |
Discriminant Adaptive Nearest Neighbor Classification
nearest_neighbor_adaptive(
mode = "classification",
neighbors = NULL,
neighborhood = NULL,
matrix_diagonal = NULL,
weighted = NULL,
sphere = NULL,
num_comp = NULL
)
mode |
A single character string for the type of model. The only possible value for this model is "classification". |
neighbors |
The number of data points used for final classification. |
neighborhood |
The number of data points used to calculate between and within class covariance. |
matrix_diagonal |
Diagonal elements of a diagonal matrix. 1 is the identity matrix. |
weighted |
weighted argument to ncoord. See |
sphere |
One of "mcd", "mve", "classical", or "none" See |
num_comp |
Dimension of subspace used by dann. See |
Discriminant Adaptive Nearest Neighbor (dann) is a variation of k nearest neighbors where the shape of the neighborhood is data driven. The neighborhood is elongated along class boundaries and shrunk in the orthogonal direction.
This function has engines dann and sub_dann.
An S3 class of type nearest_neighbor_adaptive.
library(parsnip)
library(tidydann)
data("two_class_dat", package = "modeldata")
model <- nearest_neighbor_adaptive(neighbors = 2) |>
set_engine("dann") |>
fit(formula = Class ~ A + B, data = two_class_dat)
model |>
predict(new_data = two_class_dat)