Ticket #1161: pca.diff

File pca.diff, 629 bytes (added by lanz, 2 years ago)
  • Orange/projection/linear.py

    diff --git a/Orange/projection/linear.py b/Orange/projection/linear.py
    a b  
    13741374    def _perform_pca(self, dataset, Xd, Xg): 
    13751375        n, m = Xd.shape 
    13761376        if n < m: 
    1377             C = numpy.dot(Xg.T, Xd.T) / (m - self.ddof) 
    1378             V, D, T = numpy.linalg.svd(C) 
    1379             U = numpy.dot(V.T, Xd) / numpy.sqrt(D.reshape(-1, 1) * (m - self.ddof)) 
     1377            _, D, U = numpy.linalg.svd(Xd, full_matrices=0) 
     1378            D **= 2 
    13801379        else: 
    13811380            C = numpy.dot(Xg, Xd) / (n - self.ddof) 
    13821381            U, D, T = numpy.linalg.svd(C)