As far as I understand the sum(variances)
should always be equal to the sum(explained_variance_)
, however when I run:
data = [[1, 4], [5, 1], [1, 4], [6, 8], [7, 1], [2,3], [3, 4], [1, 5], [3, 9]]
model = PCA(2)
model.fit(data)
variances = np.var(data, axis=0)
print(sum(variances), sum(model.explained_variance_))
I get this output:
11.283950617283951 12.694444444444443
I'm probably making some silly mistake but I don't see where is the problem.