Understanding Principal Component Analysis in PyTorch

Built-in function vs. numerical methods

Nikolaus Correll
Towards Data Science
8 min readFeb 18, 2024

--

PCA is an important tool for dimensionality reduction in data science and to compute grasp poses for robotic manipulation from point cloud data. PCA can also directly used within a larger machine learning framework as it is differentiable. Using the two principal components of a point cloud for robotic grasping as an example, we will derive a numerical implementation of the PCA, which will help to understand what PCA is and what it does.

Principal Component Analysis (PCA) is widely used in data analysis and machine learning to reduce the dimensionality of a dataset. The goal is to find a set of linearly uncorrelated (orthogonal) variables, called principal components, that capture the maximum variance in the data. The first principal component represents the direction of maximum variance, the second principal component is orthogonal to the first and represents the direction of the next highest variance, and so on. PCA is also used in robotic manipulation to find the principal axis of a point cloud, which can then be used to orient a gripper.

Pointcloud of a soda can on a table. Grasping the soda can will require aligning a gripper with the principal axes of the soda can. Image by the author.

Mathematically, the orthogonality of principal components is achieved by finding the eigenvectors of the covariance matrix of the original data. These eigenvectors form a set of orthogonal basis…

--

--

Nikolaus is a Professor of Computer Science and Robotics at the University of Colorado Boulder, robotics entrepreneur, and consultant.