graph_eigenvalues.matrix: A helper for sub_dann

View source: R/graph_eigenvalues.R

graph_eigenvalues.matrixR Documentation

A helper for sub_dann

Description

A helper for sub_dann

Usage

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

Arguments

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 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)

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)

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