Practical exercises in dimensionality reduction
Wrapping up the chapter, you will engage in practical exercises that involve applying PCA, LDA, and t-SNE to various datasets. These hands-on activities will reinforce the understanding of when and how to use each dimensionality reduction technique to enhance model efficiency and effectiveness.
Example 1: PCA with logistic regression
In this example, we will analyze how applying PCA before training a logistic regression model affects performance on the Iris dataset. We realize we haven’t covered logistic regression, so this will be an exercise in pushing your boundaries!
Here are the implementation steps:
- Load the libraries.
- Split the data.
- Create a pipeline without PCA.
- Create a pipeline with PCA.
- Fit and evaluate both pipelines.
- Print the results.
Example 2: t-SNE for visualization
In this example, we will use t-SNE...