nearest_neighbor_adaptive {tidydann}R Documentation

Discriminant Adaptive Nearest Neighbor Classification

Description

Discriminant Adaptive Nearest Neighbor Classification

Usage

nearest_neighbor_adaptive(
  mode = "classification",
  neighbors = NULL,
  neighborhood = NULL,
  matrix_diagonal = NULL,
  weighted = NULL,
  sphere = NULL,
  num_comp = NULL
)

Arguments

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 fpc::ncoord() for details. Only sub_dann engine.

sphere

One of "mcd", "mve", "classical", or "none" See fpc::ncoord() for details. Only sub_dann engine.

num_comp

Dimension of subspace used by dann. See fpc::ncoord() for details. Only sub_dann engine.

Details

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.

Value

An S3 class of type nearest_neighbor_adaptive.

Examples


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)


[Package tidydann version 1.0.0 Index]