Linear discriminant analysis (LDA) attempts to fit a linear combination of features to predict an outcome variable. LDA is often used as a pre-processing step. We'll walk through both methods in this recipe.
Using LDA for classification
Getting ready
In this recipe, we will do the following:
- Grab stock data from Google.
- Rearrange it in a shape we're comfortable with.
- Create an LDA object to fit and predict the class labels.
- Give an example of how to use LDA for dimensionality reduction.
Before starting on step 1 and grabbing stock data from Google, install a version of pandas that supports the latest stock reader. Do so at an Anaconda command line by typing this:
conda install -c anaconda pandas-datareader
Note...