predict.sub_dann | R Documentation |
Discriminant Adaptive Nearest Neighbor With Subspace Reduction
## S3 method for class 'sub_dann'
predict(object, new_data, type = "class", ...)
object |
of class inheriting from "sub_dann" |
new_data |
A data frame. |
type |
Type of prediction. (class, prob) |
... |
unused |
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.
A data frame containing either class or class probabilities. Adheres to tidy models standards.
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.