0

"Given an Nx2 dataset get the first principle component then it's slope."I'm working through how to get the slope of the first principal component in PCA using Numpy

import numpy as np

U, S,V = np.linalg.SVD(data, full_matrices=False)
pc_1 = V.T[0]
slope = np.linalg.norm(pc_1)

So as you can see I have the first principle component retrieved from SVD, but I realized my interpretation of "getting the slope of the first principal component" is probably not what the question is expecting since all principle components are unit vectors, which means their slope is 1. I think I could be interpreting this question incorrectly and would like some guidance.

user8714896
  • 640
  • 2
  • 12
  • My post at https://stats.stackexchange.com/a/71303/919 fully explains this. Start at the bottom to read about its application to PCA, then study the figures from top to bottom. – whuber Jul 13 '21 at 14:38

0 Answers0