LoslegenKostenlos loslegen

Using PCA as an alternative to nearZeroVar()

An alternative to removing low-variance predictors is to run PCA on your dataset. This is sometimes preferable because it does not throw out all of your data: many different low variance predictors may end up combined into one high variance PCA variable, which might have a positive impact on your model's accuracy.

This is an especially good trick for linear models: the pca option in the preProcess argument will center and scale your data, combine low variance variables, and ensure that all of your predictors are orthogonal. This creates an ideal dataset for linear regression modeling, and can often improve the accuracy of your models.

Diese Übung ist Teil des Kurses

Machine Learning with caret in R

Kurs anzeigen

Anleitung zur Übung

bloodbrain_x and bloodbrain_y are loaded in your workspace.

  • Fit a glm model to the full blood-brain dataset using the "pca" option to preProcess.
  • Print the model to the console and inspect the result.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Fit glm model using PCA: model
model <- train(
  x = ___, 
  y = ___,
  method = ___, 
  preProcess = ___
)

# Print model to console
Code bearbeiten und ausführen