From 97db2a5bd7e5c5339319e366cc34980c99b537e6 Mon Sep 17 00:00:00 2001 From: Neil Lawrence Date: Tue, 2 Apr 2013 16:53:42 +0200 Subject: [PATCH] Edit to linalg.py PCA function to stop it changing data matrix. --- GPy/util/linalg.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GPy/util/linalg.py b/GPy/util/linalg.py index 45644b41..59f598f9 100644 --- a/GPy/util/linalg.py +++ b/GPy/util/linalg.py @@ -146,9 +146,9 @@ def PCA(Y, Q): if not np.allclose(Y.mean(axis=0), 0.0): print "Y is not zero mean, centering it locally (GPy.util.linalg.PCA)" - Y -= Y.mean(axis=0) + #Y -= Y.mean(axis=0) - Z = linalg.svd(Y, full_matrices = False) + Z = linalg.svd(Y-Y.mean(axis=0), full_matrices = False) [X, W] = [Z[0][:,0:Q], np.dot(np.diag(Z[1]), Z[2]).T[:,0:Q]] v = X.std(axis=0) X /= v;