Foundations of feature extraction - principal components

Dimensionality Reduction in R

Matt Pickard

Owner, Pickard Predictives, LLC

Feature extraction review

Some of the six features combined to make four features

Dimensionality Reduction in R

Feature extraction review

Vegetable garden

Salad recipe

  • 1 head of lettuce
  • 3 carrots
  • 2 tomatoes
  • 1 cucumber

Do not use the whole plant, just the best parts

1 Image Source: Daderot, CC0, via Wikimedia Commons
Dimensionality Reduction in R

PCA plot

PCA plot showing two principal components and the features that load on them

Dimensionality Reduction in R

Principal component 1

PCA Plot - first principal component

Dimensionality Reduction in R

PC1: feature vectors

PCA Plot - features that load on the first principal component

Dimensionality Reduction in R

PC1: name

PCA Plot - naming the first principal component duration

Dimensionality Reduction in R

Principal component 2

PCA Plot - second principal component

Dimensionality Reduction in R

PC2: feature vectors

PCA Plot - features that load on the second principal component

Dimensionality Reduction in R

PC2: name

PCA Plot - naming the second principal component performance

Dimensionality Reduction in R

Code for a PCA plot

library(ggfortify)

pca_res <- prcomp(attrition_df %>% select(-Attrition), scale. = TRUE)
autoplot(pca_res,
data = attrition_df,
colour = "Attrition",
alpha = 0.7,
loadings = TRUE,
loadings.label = TRUE,
loadings.colour = "black",
loadings.label.colour = "black",
loadings.label.repel = TRUE)
Dimensionality Reduction in R

Let's practice!

Dimensionality Reduction in R

Preparing Video For Download...