I am performing PCA analysis by using Sklearn and GPflow. I noticed that the output returned by both the libraries doesn't match.
Please see below the sample code snippet-
import numpy as np
from gpflow.models import PCA_reduce
from sklearn.decomposition import PCA
X = np.random.random((100, 10))
for n in range(1, 6):
X1 = PCA(n_components=n).fit_transform(X)
X2 = PCA_reduce(X, n)
print('[n=%d] allclose=%s' % (n, np.allclose(X1, X2)))
Below is the output-
[n=1] allclose=True
[n=2] allclose=False
[n=3] allclose=False
[n=4] allclose=False
[n=5] allclose=False
It matches only when the number of principal components is 1. Why such behavior?