Title: | Discriminant Adaptive Nearest Neighbor Classification |
---|---|
Description: | Discriminant Adaptive Nearest Neighbor Classification is a variation of k nearest neighbors where the shape of the neighborhood is data driven. This package implements dann and sub_dann from Hastie (1996) <https://web.stanford.edu/~hastie/Papers/dann_IEEE.pdf>. |
Authors: | Greg McMahan |
Maintainer: | Greg McMahan <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.1 |
Built: | 2024-10-31 04:05:31 UTC |
Source: | https://github.com/gmcmacran/dann |
Discriminant Adaptive Nearest Neighbor Classification
dann(x, ..., k = 5, neighborhood_size = max(floor(nrow(x)/5), 50), epsilon = 1)
dann(x, ..., k = 5, neighborhood_size = max(floor(nrow(x)/5), 50), epsilon = 1)
x |
A matrix or a dataframe. |
... |
Additional parameters passed to methods. |
k |
The number of data points used for final classification. |
neighborhood_size |
The number of data points used to calculate between and within class covariance. |
epsilon |
Diagonal elements of a diagonal matrix. 1 is the identity matrix. |
This is an implementation of Hastie and Tibshirani's Discriminant Adaptive Nearest Neighbor Classification publication..
An S3 class of type dann.
Discriminant Adaptive Nearest Neighbor Classification
## S3 method for class 'data.frame' dann( x, y, k = 5, neighborhood_size = max(floor(nrow(x)/5), 50), epsilon = 1, ... )
## S3 method for class 'data.frame' dann( x, y, k = 5, neighborhood_size = max(floor(nrow(x)/5), 50), epsilon = 1, ... )
x |
A data frame. |
y |
A vector. |
k |
The number of data points used for final classification. |
neighborhood_size |
The number of data points used to calculate between and within class covariance. |
epsilon |
Diagonal elements of a diagonal matrix. 1 is the identity matrix. |
... |
Additional parameters passed to methods. |
This is an implementation of Hastie and Tibshirani's Discriminant Adaptive Nearest Neighbor Classification publication..
An S3 class of type dann.
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") y <- train$Y x <- train[, 1:2] dann(x, y)
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") y <- train$Y x <- train[, 1:2] dann(x, y)
Discriminant Adaptive Nearest Neighbor Classification
## Default S3 method: dann(x, k = 5, neighborhood_size = max(floor(nrow(x)/5), 50), epsilon = 1, ...)
## Default S3 method: dann(x, k = 5, neighborhood_size = max(floor(nrow(x)/5), 50), epsilon = 1, ...)
x |
A data frame. |
k |
The number of data points used for final classification. |
neighborhood_size |
The number of data points used to calculate between and within class covariance. |
epsilon |
Diagonal elements of a diagonal matrix. 1 is the identity matrix. |
... |
Additional parameters passed to methods. |
This is an implementation of Hastie and Tibshirani's Discriminant Adaptive Nearest Neighbor Classification publication..
An S3 class of type dann.
Discriminant Adaptive Nearest Neighbor Classification
## S3 method for class 'formula' dann( formula, data, k = 5, neighborhood_size = max(floor(nrow(data)/5), 50), epsilon = 1, ... )
## S3 method for class 'formula' dann( formula, data, k = 5, neighborhood_size = max(floor(nrow(data)/5), 50), epsilon = 1, ... )
formula |
A formula. Y ~ X1 + X2 |
data |
A data frame. |
k |
The number of data points used for final classification. |
neighborhood_size |
The number of data points used to calculate between and within class covariance. |
epsilon |
Diagonal elements of a diagonal matrix. 1 is the identity matrix. |
... |
Additional parameters passed to methods. |
This is an implementation of Hastie and Tibshirani's Discriminant Adaptive Nearest Neighbor Classification publication..
An S3 class of type dann.
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") dann(Y ~ X1 + X2, train)
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") dann(Y ~ X1 + X2, train)
Discriminant Adaptive Nearest Neighbor Classification
## S3 method for class 'matrix' dann( x, y, k = 5, neighborhood_size = max(floor(nrow(x)/5), 50), epsilon = 1, ... )
## S3 method for class 'matrix' dann( x, y, k = 5, neighborhood_size = max(floor(nrow(x)/5), 50), epsilon = 1, ... )
x |
A matrix. |
y |
A vector. |
k |
The number of data points used for final classification. |
neighborhood_size |
The number of data points used to calculate between and within class covariance. |
epsilon |
Diagonal elements of a diagonal matrix. 1 is the identity matrix. |
... |
Additional parameters passed to methods. |
This is an implementation of Hastie and Tibshirani's Discriminant Adaptive Nearest Neighbor Classification publication..
An S3 class of type dann.
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") y <- as.numeric(train$Y) x <- cbind(train$X1, train$X2) dann(x, y)
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") y <- as.numeric(train$Y) x <- cbind(train$X1, train$X2) dann(x, y)
Discriminant Adaptive Nearest Neighbor Classification
## S3 method for class 'recipe' dann( x, data, k = 5, neighborhood_size = max(floor(nrow(data)/5), 50), epsilon = 1, ... )
## S3 method for class 'recipe' dann( x, data, k = 5, neighborhood_size = max(floor(nrow(data)/5), 50), epsilon = 1, ... )
x |
A recipe from recipes library. |
data |
A data frame. |
k |
The number of data points used for final classification. |
neighborhood_size |
The number of data points used to calculate between and within class covariance. |
epsilon |
Diagonal elements of a diagonal matrix. 1 is the identity matrix. |
... |
Additional parameters passed to methods. |
This is an implementation of Hastie and Tibshirani's Discriminant Adaptive Nearest Neighbor Classification publication..
An S3 class of type dann.
library(dann) library(mlbench) library(magrittr) library(dplyr) library(recipes) set.seed(1) train <- mlbench.circle(300, 2) %>% tibble::as_tibble() colnames(train) <- c("X1", "X2", "Y") rec_obj <- recipe(Y ~ X1 + X2, data = train) dann(rec_obj, train)
library(dann) library(mlbench) library(magrittr) library(dplyr) library(recipes) set.seed(1) train <- mlbench.circle(300, 2) %>% tibble::as_tibble() colnames(train) <- c("X1", "X2", "Y") rec_obj <- recipe(Y ~ X1 + X2, data = train) dann(rec_obj, train)
A helper for sub_dann
graph_eigenvalues( x, ..., neighborhood_size = max(floor(nrow(x)/5), 50), weighted = FALSE, sphere = "mcd" )
graph_eigenvalues( x, ..., neighborhood_size = max(floor(nrow(x)/5), 50), weighted = FALSE, sphere = "mcd" )
x |
A matrix or a dataframe. |
... |
Additional parameters passed to methods. |
neighborhood_size |
The number of data points used to calculate between and within class covariance. |
weighted |
weighted argument to ncoord. See |
sphere |
One of "mcd", "mve", "classical", or "none" See |
This function plots the eigenvalues found by fpc::ncoord()
. The user
should make a judgement call on how many eigenvalues are large and set sub_dann's
numDim to that number.
A ggplot2 graph.
A helper for sub_dann
## S3 method for class 'data.frame' graph_eigenvalues( x, y, neighborhood_size = max(floor(nrow(x)/5), 50), weighted = FALSE, sphere = "mcd", ... )
## S3 method for class 'data.frame' graph_eigenvalues( x, y, neighborhood_size = max(floor(nrow(x)/5), 50), weighted = FALSE, sphere = "mcd", ... )
x |
A data frame. |
y |
A vector. |
neighborhood_size |
The number of data points used to calculate between and within class covariance. |
weighted |
weighted argument to ncoord. See |
sphere |
One of "mcd", "mve", "classical", or "none" See |
... |
Additional parameters passed to methods. |
This function plots the eigenvalues found by fpc::ncoord()
. The user
should make a judgement call on how many eigenvalues are large and set sub_dann's
numDim to that number.
A ggplot2 graph.
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") #' # Add 5 unrelated variables train <- train %>% mutate( U1 = runif(300, -1, 1), U2 = runif(300, -1, 1), U3 = runif(300, -1, 1), U4 = runif(300, -1, 1), U5 = runif(300, -1, 1) ) y <- train$Y x <- cbind(train[, 1:2], train[, 4:8]) graph_eigenvalues(x, y)
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") #' # Add 5 unrelated variables train <- train %>% mutate( U1 = runif(300, -1, 1), U2 = runif(300, -1, 1), U3 = runif(300, -1, 1), U4 = runif(300, -1, 1), U5 = runif(300, -1, 1) ) y <- train$Y x <- cbind(train[, 1:2], train[, 4:8]) graph_eigenvalues(x, y)
A helper for sub_dann
## Default S3 method: graph_eigenvalues( x, neighborhood_size = max(floor(nrow(x)/5), 50), weighted = FALSE, sphere = "mcd", ... )
## Default S3 method: graph_eigenvalues( x, neighborhood_size = max(floor(nrow(x)/5), 50), weighted = FALSE, sphere = "mcd", ... )
x |
A data frame. |
neighborhood_size |
The number of data points used to calculate between and within class covariance. |
weighted |
weighted argument to ncoord. See |
sphere |
One of "mcd", "mve", "classical", or "none" See |
... |
Additional parameters passed to methods. |
This function plots the eigenvalues found by fpc::ncoord()
. The user
should make a judgement call on how many eigenvalues are large and set sub_dann's
numDim to that number.
A ggplot2 graph.
A helper for sub_dann
## S3 method for class 'formula' graph_eigenvalues( formula, data, neighborhood_size = max(floor(nrow(data)/5), 50), weighted = FALSE, sphere = "mcd", ... )
## S3 method for class 'formula' graph_eigenvalues( formula, data, neighborhood_size = max(floor(nrow(data)/5), 50), weighted = FALSE, sphere = "mcd", ... )
formula |
A formula. Y ~ X1 + X1 |
data |
A data frame. |
neighborhood_size |
The number of data points used to calculate between and within class covariance. |
weighted |
weighted argument to ncoord. See |
sphere |
One of "mcd", "mve", "classical", or "none" See |
... |
Additional parameters passed to methods. |
This function plots the eigenvalues found by fpc::ncoord()
. The user
should make a judgement call on how many eigenvalues are large and set sub_dann's
numDim to that number.
A ggplot2 graph.
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") # Add 5 unrelated variables train <- train %>% mutate( U1 = runif(300, -1, 1), U2 = runif(300, -1, 1), U3 = runif(300, -1, 1), U4 = runif(300, -1, 1), U5 = runif(300, -1, 1) ) graph_eigenvalues(Y ~ X1 + X2 + U1 + U2 + U3 + U4 + U5, train)
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") # Add 5 unrelated variables train <- train %>% mutate( U1 = runif(300, -1, 1), U2 = runif(300, -1, 1), U3 = runif(300, -1, 1), U4 = runif(300, -1, 1), U5 = runif(300, -1, 1) ) graph_eigenvalues(Y ~ X1 + X2 + U1 + U2 + U3 + U4 + U5, train)
A helper for sub_dann
## S3 method for class 'matrix' graph_eigenvalues( x, y, neighborhood_size = max(floor(nrow(x)/5), 50), weighted = FALSE, sphere = "mcd", ... )
## S3 method for class 'matrix' graph_eigenvalues( x, y, neighborhood_size = max(floor(nrow(x)/5), 50), weighted = FALSE, sphere = "mcd", ... )
x |
A matrix. |
y |
A vector. |
neighborhood_size |
The number of data points used to calculate between and within class covariance. |
weighted |
weighted argument to ncoord. See |
sphere |
One of "mcd", "mve", "classical", or "none" See |
... |
Additional parameters passed to methods. |
This function plots the eigenvalues found by fpc::ncoord()
. The user
should make a judgement call on how many eigenvalues are large and set sub_dann's
numDim to that number.
A ggplot2 graph.
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") # Add 5 unrelated variables train <- train %>% mutate( U1 = runif(300, -1, 1), U2 = runif(300, -1, 1), U3 = runif(300, -1, 1), U4 = runif(300, -1, 1), U5 = runif(300, -1, 1) ) y <- as.numeric(train$Y) x <- cbind(train$X1, train$X2, train$U1, train$U2, train$U3, train$U4, train$U5) graph_eigenvalues(x, y)
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") # Add 5 unrelated variables train <- train %>% mutate( U1 = runif(300, -1, 1), U2 = runif(300, -1, 1), U3 = runif(300, -1, 1), U4 = runif(300, -1, 1), U5 = runif(300, -1, 1) ) y <- as.numeric(train$Y) x <- cbind(train$X1, train$X2, train$U1, train$U2, train$U3, train$U4, train$U5) graph_eigenvalues(x, y)
A helper for sub_dann
## S3 method for class 'recipe' graph_eigenvalues( x, data, neighborhood_size = max(floor(nrow(data)/5), 50), weighted = FALSE, sphere = "mcd", ... )
## S3 method for class 'recipe' graph_eigenvalues( x, data, neighborhood_size = max(floor(nrow(data)/5), 50), weighted = FALSE, sphere = "mcd", ... )
x |
A recipe from recipes library. |
data |
A data frame. |
neighborhood_size |
The number of data points used to calculate between and within class covariance. |
weighted |
weighted argument to ncoord. See |
sphere |
One of "mcd", "mve", "classical", or "none" See |
... |
Additional parameters passed to methods. |
This function plots the eigenvalues found by fpc::ncoord()
. The user
should make a judgement call on how many eigenvalues are large and set sub_dann's
numDim to that number.
A ggplot2 graph.
library(dann) library(mlbench) library(magrittr) library(dplyr) library(recipes) set.seed(1) train <- mlbench.circle(300, 2) %>% tibble::as_tibble() colnames(train) <- c("X1", "X2", "Y") # Add 5 unrelated variables train <- train %>% mutate( U1 = runif(300, -1, 1), U2 = runif(300, -1, 1), U3 = runif(300, -1, 1), U4 = runif(300, -1, 1), U5 = runif(300, -1, 1) ) rec_obj <- recipe(Y ~ X1 + X2 + U1 + U2 + U3 + U4 + U5, data = train) graph_eigenvalues(rec_obj, train)
library(dann) library(mlbench) library(magrittr) library(dplyr) library(recipes) set.seed(1) train <- mlbench.circle(300, 2) %>% tibble::as_tibble() colnames(train) <- c("X1", "X2", "Y") # Add 5 unrelated variables train <- train %>% mutate( U1 = runif(300, -1, 1), U2 = runif(300, -1, 1), U3 = runif(300, -1, 1), U4 = runif(300, -1, 1), U5 = runif(300, -1, 1) ) rec_obj <- recipe(Y ~ X1 + X2 + U1 + U2 + U3 + U4 + U5, data = train) graph_eigenvalues(rec_obj, train)
Discriminant Adaptive Nearest Neighbor Classification
## S3 method for class 'dann' predict(object, new_data, type = "class", ...)
## S3 method for class 'dann' predict(object, new_data, type = "class", ...)
object |
of class inheriting from "dann" |
new_data |
A data frame. |
type |
Type of prediction. (class, prob) |
... |
unused |
This is an implementation of Hastie and Tibshirani's Discriminant Adaptive Nearest Neighbor Classification publication..
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 <- dann(Y ~ X1 + X2, train) predict(model, test, "class") predict(model, test, "prob")
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")
Discriminant Adaptive Nearest Neighbor With Subspace Reduction
## S3 method for class 'sub_dann' predict(object, new_data, type = "class", ...)
## 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")
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")
Print dann model
## S3 method for class 'dann' print(x, ...)
## S3 method for class 'dann' print(x, ...)
x |
a dann model. |
... |
arguments passed to other methods. |
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") model <- dann(Y ~ X1 + X2, train) print(model)
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") model <- dann(Y ~ X1 + X2, train) print(model)
Print dann model.
## S3 method for class 'sub_dann' print(x, ...)
## S3 method for class 'sub_dann' print(x, ...)
x |
a sub_dann model |
... |
arguments passed to other methods. |
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") model <- sub_dann(Y ~ X1 + X2, train) print(model)
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") model <- sub_dann(Y ~ X1 + X2, train) print(model)
Discriminant Adaptive Nearest Neighbor With Subspace Reduction
sub_dann( x, ..., k = 5, neighborhood_size = max(floor(nrow(x)/5), 50), epsilon = 1, weighted = FALSE, sphere = "mcd", numDim = ceiling(ncol(x)/2) )
sub_dann( x, ..., k = 5, neighborhood_size = max(floor(nrow(x)/5), 50), epsilon = 1, weighted = FALSE, sphere = "mcd", numDim = ceiling(ncol(x)/2) )
x |
A matrix or a dataframe. |
... |
Additional parameters passed to methods. |
k |
The number of data points used for final classification. |
neighborhood_size |
The number of data points used to calculate between and within class covariance. |
epsilon |
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 |
numDim |
Dimension of subspace used by dann. See |
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.
An S3 class of type sub_dann
Discriminant Adaptive Nearest Neighbor With Subspace Reduction
## S3 method for class 'data.frame' sub_dann( x, y, k = 5, neighborhood_size = max(floor(nrow(x)/5), 50), epsilon = 1, weighted = FALSE, sphere = "mcd", numDim = ceiling(ncol(x)/2), ... )
## S3 method for class 'data.frame' sub_dann( x, y, k = 5, neighborhood_size = max(floor(nrow(x)/5), 50), epsilon = 1, weighted = FALSE, sphere = "mcd", numDim = ceiling(ncol(x)/2), ... )
x |
A data frame. |
y |
A vector. |
k |
The number of data points used for final classification. |
neighborhood_size |
The number of data points used to calculate between and within class covariance. |
epsilon |
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 |
numDim |
Dimension of subspace used by dann. See |
... |
Additional parameters passed to methods. |
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.
An S3 class of type sub_dann
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") y <- train$Y x <- train[, 1:2] sub_dann(x, y)
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") y <- train$Y x <- train[, 1:2] sub_dann(x, y)
Discriminant Adaptive Nearest Neighbor With Subspace Reduction
## Default S3 method: sub_dann( x, k = 5, neighborhood_size = max(floor(nrow(x)/5), 50), epsilon = 1, weighted = FALSE, sphere = "mcd", numDim = ceiling(ncol(x)/2), ... )
## Default S3 method: sub_dann( x, k = 5, neighborhood_size = max(floor(nrow(x)/5), 50), epsilon = 1, weighted = FALSE, sphere = "mcd", numDim = ceiling(ncol(x)/2), ... )
x |
A data frame. |
k |
The number of data points used for final classification. |
neighborhood_size |
The number of data points used to calculate between and within class covariance. |
epsilon |
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 |
numDim |
Dimension of subspace used by dann. See |
... |
Additional parameters passed to methods. |
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.
An S3 class of type sub_dann
Discriminant Adaptive Nearest Neighbor With Subspace Reduction
## S3 method for class 'formula' sub_dann( formula, data, k = 5, neighborhood_size = max(floor(nrow(data)/5), 50), epsilon = 1, weighted = FALSE, sphere = "mcd", numDim = ceiling(ncol(data)/2), ... )
## S3 method for class 'formula' sub_dann( formula, data, k = 5, neighborhood_size = max(floor(nrow(data)/5), 50), epsilon = 1, weighted = FALSE, sphere = "mcd", numDim = ceiling(ncol(data)/2), ... )
formula |
A formula. Y ~ X1 + X2 |
data |
A data frame. |
k |
The number of data points used for final classification. |
neighborhood_size |
The number of data points used to calculate between and within class covariance. |
epsilon |
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 |
numDim |
Dimension of subspace used by dann. See |
... |
Additional parameters passed to methods. |
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.
An S3 class of type sub_dann
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") sub_dann(Y ~ X1 + X2, train)
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") sub_dann(Y ~ X1 + X2, train)
Discriminant Adaptive Nearest Neighbor With Subspace Reduction
## S3 method for class 'matrix' sub_dann( x, y, k = 5, neighborhood_size = max(floor(nrow(x)/5), 50), epsilon = 1, weighted = FALSE, sphere = "mcd", numDim = ceiling(ncol(x)/2), ... )
## S3 method for class 'matrix' sub_dann( x, y, k = 5, neighborhood_size = max(floor(nrow(x)/5), 50), epsilon = 1, weighted = FALSE, sphere = "mcd", numDim = ceiling(ncol(x)/2), ... )
x |
A matrix. |
y |
A vector. |
k |
The number of data points used for final classification. |
neighborhood_size |
The number of data points used to calculate between and within class covariance. |
epsilon |
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 |
numDim |
Dimension of subspace used by dann. See |
... |
Additional parameters passed to methods. |
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.
An S3 class of type sub_dann
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") y <- as.numeric(train$Y) x <- cbind(train$X1, train$X2) sub_dann(x, y)
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") y <- as.numeric(train$Y) x <- cbind(train$X1, train$X2) sub_dann(x, y)
Discriminant Adaptive Nearest Neighbor With Subspace Reduction
## S3 method for class 'recipe' sub_dann( x, data, k = 5, neighborhood_size = max(floor(nrow(data)/5), 50), epsilon = 1, weighted = FALSE, sphere = "mcd", numDim = ceiling(ncol(data)/2), ... )
## S3 method for class 'recipe' sub_dann( x, data, k = 5, neighborhood_size = max(floor(nrow(data)/5), 50), epsilon = 1, weighted = FALSE, sphere = "mcd", numDim = ceiling(ncol(data)/2), ... )
x |
A recipe from recipes library. |
data |
A data frame. |
k |
The number of data points used for final classification. |
neighborhood_size |
The number of data points used to calculate between and within class covariance. |
epsilon |
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 |
numDim |
Dimension of subspace used by dann. See |
... |
Additional parameters passed to methods. |
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.
An S3 class of type sub_dann
library(dann) library(mlbench) library(magrittr) library(dplyr) library(recipes) set.seed(1) train <- mlbench.circle(300, 2) %>% tibble::as_tibble() colnames(train) <- c("X1", "X2", "Y") rec_obj <- recipe(Y ~ X1 + X2, data = train) sub_dann(rec_obj, train)
library(dann) library(mlbench) library(magrittr) library(dplyr) library(recipes) set.seed(1) train <- mlbench.circle(300, 2) %>% tibble::as_tibble() colnames(train) <- c("X1", "X2", "Y") rec_obj <- recipe(Y ~ X1 + X2, data = train) sub_dann(rec_obj, train)