LDA: Linear Discriminant Analysis

Description Usage Arguments Value Methods (by class) Examples

View source: R/tidy.R

Description

Linear Discriminant Analysis finds directions in high-dimensional space that maximize the ratio of inter-class variance / within-class variance.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
LDA(X, ...)

## S3 method for class 'data.frame'
LDA(X, y, lambda = 0.1, ...)

## S3 method for class 'matrix'
LDA(X, y, lambda = 0.1, ...)

## S3 method for class 'formula'
LDA(formula, data, lambda = 0.1, ...)

Arguments

X

matrix or data.frame, where each row is a sample and each column is a feature.

...

further arguments passed to or from other methods

y

a vector of class labels with length equal to the number of rows in X. If X is a data.frame, y can also be an index (integer) or name (character) of the column to be used as labels.

lambda

regularization parameter. Higher values lead to less overfitting and the cost of poorer separation between the classes. (Default: 0.1)

formula

an alternative way to specify the LDA model. See below for examples.

data

a data.frame associated with the formula-based model specification.

Value

An object of class LDA that contains variance quotients in $d and LDA component loadings in $v. See tidy.LDA, glance.LDA and augment.LDA for tidy downstream usage of the LDA object.

Methods (by class)

Examples

1
2
3
4
5
6
7
## All of the following are equivalent ways to train an LDA model on the built-in iris dataset
model1 <- LDA( iris, "Species" )
model2 <- LDA( iris, 5 )
model3 <- LDA( iris[,1:4], iris[,5] )
model4 <- LDA( as.matrix( iris[,1:4] ), iris[,5] )
model5 <- LDA( Species ~ ., iris )
model6 <- LDA( Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width, iris )

ArtemSokolov/linproj documentation built on May 7, 2019, 1:22 p.m.