Session Ready
Exercise

PCA to the rescue

Extracting new features from the data could work wonders if your ML model does not look really promising.

You want to classify a soccer player as belonging to either the FC Barcelona or the Real Madrid club based on 34 performance indicators. You trained a linear Support Vector Machine (SVM) on the original data but, alas, its performance was quite poor. So you have decided to extract new features via Principal Component Analysis (PCA) and train your SVM on that data instead.

The 66 players in both teams have been evenly split into team_train (50) and team_test (16). Both sets have been centered and scaled. The 5-fold cross validation trainCtrl variable is available in your workspace. The caret and Metrics packages have been pre-loaded.

Instructions 1/4
undefined XP
  • 1
  • 2
  • 3
  • 4
  • Use caret's preProcess() function to create an object named pca that applies PCA to team_train (except the Club column).
  • Use the pca object to transform both team_train and team_test datasets. Save these versions as train_pca and test_pca.