CSci574 / AI 520 Machine Learning: Classroom Session 11/24/2026
Overview
Derek Harter explains principal component analysis (PCA) as a way to rotate data into ordered, orthogonal axes that preserve as much variance as possible, then reduce dimensions by keeping the most informative components. He demonstrates scikit-learn PCA, whitening, projection and reconstruction, and the assignment’s hands-on workflow using centered data, a covariance matrix, and singular value decomposition (SVD), followed by examples with handwritten digits and noise reduction.
Key takeaways
- PCA orders orthogonal directions by explained variance, allowing a lower-dimensional representation to retain the strongest patterns in the original data.
- In scikit-learn, `components_` contains principal-axis directions and `explained_variance_` reports the variance captured by each direction.
- Whitening rescales PCA-transformed features to unit variance; it changes the projected values without changing the fitted principal axes.
- The Assignment 7 workflow described by Derek Harter is to center features, compute a covariance matrix, apply SVD, project onto the requested leading components, and reconstruct in the original space.
- Cumulative explained-variance ratios provide a practical way to choose a component count, such as retaining enough dimensions to reach a 90% target.
- PCA can reduce noise in image data by discarding low-variance components, but a two-dimensional projection of 64-feature digits necessarily loses information.
Chapters
- Derek Harter says Assignment 7 is available and due Sunday at the end of the week.
- He notes that the PCA notebook was updated, so students should pull the latest class repository changes.
- The session focuses on PCA after the previous class covered K-means clustering.
- PCA is introduced as a widely used unsupervised dimensionality-reduction and projection technique.
- For 3D-to-2D projection, the selected plane aims to preserve variance and minimize squared projection distances.
- Principal components are ordered by captured variance, and each later component is orthogonal to earlier components.
- A synthetic 2D dataset illustrates a strong linear relationship and a dominant direction of variation.
- The scikit-learn PCA object can retain both components to reorient the axes without reducing dimensionality.
- The fitted object exposes component directions and explained variance, ordered from most to least important.
- Each row of scikit-learn's `components_` represents a principal-component axis in the original feature space.
- The `explained_variance_` values indicate how much variance each component captures.
- Harter plots component vectors from the data mean and scales their displayed lengths to illustrate relative importance.
- Calling `transform` expresses the same observations in the principal-component coordinate system.
- With two components retained, the data are rotated so the leading variation aligns with the first new axis.
- Whitening rescales transformed components to have unit variance; Harter notes that it changes projected outputs, not the PCA axes.
- Harter introduces SVD as the mathematical technique used by scikit-learn PCA.
- The assignment requires students to perform SVD by hand rather than relying only on NumPy's implementation.
- The notebook centers data by subtracting each feature mean before applying the decomposition.
- Setting PCA to retain one component projects the 2D dataset into a single dimension.
- The reduced representation keeps the leading component and discards variation along the less important axis.
- An inverse transform maps the 1D points back into the original 2D space, showing the resulting projection and lost information.
- The assignment workflow begins by centering each feature using the mean returned by feature normalization.
- Harter instructs students to form a covariance matrix from the centered data and apply SVD to it.
- He says this covariance-matrix approach produces results closer to scikit-learn PCA than applying SVD directly to centered observations.
- The notebook compares manual decomposition outputs with scikit-learn's component directions and variance values.
- A principal-component vector may point in the opposite direction while representing the same axis, so sign flips are not substantive differences.
- Manual projection multiplies centered data by the component directions; whitening additionally rescales the projected dimensions.
- Students reuse feature normalization to obtain centered data, feature means, and standard deviations.
- The PCA implementation computes the covariance matrix, performs SVD, and retains the requested number of components for projection.
- Recovered data are produced by projecting the reduced representation back into the original feature space.
- The scikit-learn digits dataset contains 1,797 examples represented as 8-by-8 images, or 64 features per image.
- Projecting the 64-dimensional examples to two components makes a 2D scatterplot possible, but discards information from the other 62 components.
- Some digit groups appear more clearly separated than others, illustrating both the value and limits of a two-dimensional view.
- PCA components act as basis directions for representing and reconstructing 8-by-8 digit images.
- The notebook reconstructs a sample digit using its leading components rather than simply selecting the most important individual pixels.
- Keeping the highest-variance components preserves more of the dataset's structure than keeping an arbitrary subset of features.
- Explained-variance ratios are normalized so their sum across all 64 components equals one.
- A cumulative sum of those ratios estimates the share of total variance retained as components are added.
- The plot helps select a component count for a target such as 90% explained variance; Harter estimates roughly 20 to 25 components may reach that range in the example.
- The notebook adds random noise to digit images and shows how retaining a chosen variance share can produce cleaner reconstructions.
- PCA can suppress low-variance noise, though the usefulness of discarded information depends on the dataset and task.
- Harter mentions eigenfaces as another PCA application, then reminds students that Assignment 7 is due Sunday, the next class will cover Test 2, and the final project is due during finals week.
Transcript excerpt
0:08 Okay. Um, hello. Welcome. Hopefully my audio is good here. I'm going to get started. Um, so yeah, I don't have too many people on at the moment. We'll see if some more join us here. Uh, let me know if you have any questions. Today might be a little bit short. Um, I did get up the assignment seven invitation link. Um, so that should be available. Hopefully everybody is seeing that is working on it. So we only do have kind of uh half week this week and then one more full week of classes. Uh, but yeah, that assignment seven is coming up. Um, um uh so so yeah, I did keep it uh to be um due
0:57 at the end of this uh week on Sunday. So um yeah, hopefully everybody get a chance to go off and take a break, but do keep in mind that I um that we do have that assignment. So you know, if you're still working on it, let me know. You might want to try to get some work in on on it today or tomorrow. So [laughter] um my plan today is I was going to talk about principal component analysis basically. So I tried talking about that a week ago and I had some problems and things. Um, last time we met last Thursday I did cover I think K-means uh K-clustering uh sorry pretty adequately. So we did talk about that last time. So anyway, let's jump
1:45 into principal component analysis. I just wanted to um there's a couple of things I think would be useful when you're working on that part of the assignment. So um um I actually there were a couple that needed to be fixed in this notebook on the PCA as well. So I did actually just
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Derek Harter.