graph_eigenvalues.recipe: A helper for sub_dann

View source: R/graph_eigenvalues.R

graph_eigenvalues.recipeR Documentation

A helper for sub_dann

Description

A helper for sub_dann

Usage

## S3 method for class 'recipe'
graph_eigenvalues(
  x,
  data,
  neighborhood_size = max(floor(nrow(data)/5), 50),
  weighted = FALSE,
  sphere = "mcd",
  ...
)

Arguments

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

sphere

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

...

Additional parameters passed to methods.

Details

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.

Value

A ggplot2 graph.

Examples

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)

dann documentation built on Sept. 23, 2023, 5:06 p.m.