Learn R Programming

dann (version 1.0.2)

predict.sub_dann: Discriminant Adaptive Nearest Neighbor With Subspace Reduction

Description

Discriminant Adaptive Nearest Neighbor With Subspace Reduction

Usage

# S3 method for sub_dann
predict(object, new_data, type = "class", ...)

Value

A data frame containing either class or class probabilities. Adheres to tidy models standards.

Arguments

object

of class inheriting from "sub_dann"

new_data

A data frame.

type

Type of prediction. (class, prob)

...

unused

Details

An implementation of Hastie and Tibshirani's sub-dann in section 4.1 of Discriminant Adaptive Nearest Neighbor Classification publication..

dann's performance suffers when noise variables are included in the model. Simulations show sub_dann will generally be more performant in this scenario.

Examples

Run this code
library(dann)
library(mlbench)
library(magrittr)
library(dplyr)

set.seed(1)
train <- mlbench.circle(300, 2) %>%
  tibble::as_tibble()
colnames(train) <- c("X1", "X2", "Y")

test <- mlbench.circle(300, 2) %>%
  tibble::as_tibble()
colnames(test) <- c("X1", "X2", "Y")

model <- sub_dann(Y ~ X1 + X2, train)
predict(model, test, "class")

predict(model, test, "prob")

Run the code above in your browser using DataLab