Principal component calculation

As we have already seen, the PCA process can be described in two steps:

  1. Calculate the covariance matrix of the original data.
  2. Choose the eigenvalues to construct the projection matrix.

Let's remind ourselves how the covariance matrix is expressed. It is the multiplication of the difference between the data points and their mean value:

The mean of each dimension of the original data is provided by the mean operation:

const batch = xs.shape[0];const meanValues = xs.mean(0);

The argument of reduction operations, such as mean = axis, specifies the dimensions where the reduction happens. Axis=0 means the row-wise ...

Get Hands-On Machine Learning with TensorFlow.js now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.