| dt_pca | R Documentation |
Principal Component Analysis (PCA) for unsupervised dimensionality reduction. Transforms correlated variables into orthogonal principal components ordered by explained variance.
dt_pca(attribute = NULL, components = NULL)
attribute |
target attribute to model building |
components |
number of components for PCA |
Fits PCA on (optionally) the numeric predictors only (excluding attribute when provided),
removes constant columns, and selects the number of components by an elbow rule (minimum curvature)
unless components is set explicitly.
returns an object of class dt_pca
Pearson, K. (1901). On lines and planes of closest fit to systems of points in space. Hotelling, H. (1933). Analysis of a complex of statistical variables into principal components.
mypca <- dt_pca("Species")
# Automatically fitting number of components
mypca <- fit(mypca, iris)
iris.pca <- transform(mypca, iris)
head(iris.pca)
head(mypca$pca.transf)
# Manual establishment of number of components
mypca <- dt_pca("Species", 3)
mypca <- fit(mypca, datasets::iris)
iris.pca <- transform(mypca, iris)
head(iris.pca)
head(mypca$pca.transf)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.