What happens to the first principal component if you forget to centre your data before PCA?

Quick Overview

Asks what goes wrong with the first principal component when PCA is run on data that was never mean-centred. It tests whether you can relate the uncentred second-moment matrix to the covariance and explain the effect on explained variance and the later components.

What happens to the first principal component if you forget to centre your data before PCA?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

You run PCA by taking the SVD of a data matrix $X$ directly, without subtracting the column means first. What happens to the first principal component if you forget to centre your data before PCA? ```hint Expand the matrix Write the uncentred matrix $X^\top X / n$ in terms of the data's mean vector and its covariance. ``` ```hint Picture it Imagine a cloud of points that sits far from the origin and is stretched along one axis. Ask which direction from the origin carries the most squared length. ``` ### What a Strong Answer Covers - Which matrix PCA decomposes when the data is not centred, and how it relates to the covariance. - Where the first component points when the mean is large compared with the spread. - What happens to the explained-variance figures and to the later components. - When skipping centring is harmless or deliberate, and which tools centre for you. ### Follow-up Questions - Should you also scale features to unit variance before PCA, and when does that change the components? - When you apply a PCA fitted on training data to new data, which mean do you subtract? - Why does `TruncatedSVD` skip centring on sparse TF-IDF matrices, and what do you give up? - How could you tell, after the fact, that a PCA was run on uncentred data?

Overview: Asks what goes wrong with the first principal component when PCA is run on data that was never mean-centred. It tests whether you can relate the uncentred second-moment matrix to the covariance and explain the effect on explained variance and the later components.

General logo
General
Nov 25, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

You run PCA by taking the SVD of a data matrix XX directly, without subtracting the column means first. What happens to the first principal component if you forget to centre your data before PCA?

What a Strong Answer Covers Guidance

  • Which matrix PCA decomposes when the data is not centred, and how it relates to the covariance.
  • Where the first component points when the mean is large compared with the spread.
  • What happens to the explained-variance figures and to the later components.
  • When skipping centring is harmless or deliberate, and which tools centre for you.

Follow-up Questions Guidance

  • Should you also scale features to unit variance before PCA, and when does that change the components?
  • When you apply a PCA fitted on training data to new data, which mean do you subtract?
  • Why does TruncatedSVD skip centring on sparse TF-IDF matrices, and what do you give up?
  • How could you tell, after the fact, that a PCA was run on uncentred data?