Learn R Programming

dann (version 1.0.2)

predict.dann: Discriminant Adaptive Nearest Neighbor Classification

Description

Discriminant Adaptive Nearest Neighbor Classification

Usage

# S3 method for 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 "dann"

new_data

A data frame.

type

Type of prediction. (class, prob)

...

unused

Details

This is an implementation of Hastie and Tibshirani's Discriminant Adaptive Nearest Neighbor Classification publication..

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 <- dann(Y ~ X1 + X2, train)
predict(model, test, "class")

predict(model, test, "prob")

Run the code above in your browser using DataLab