Changeset 9119:998805a03104 in orange


Ignore:
Timestamp:
10/18/11 19:51:15 (2 years ago)
Author:
mocnik <mocnik@…>
Branch:
default
Convert:
c7e1e3f9b25be88f534b808c7db73de59a165412
Message:

Fixed division by zero when standars deviation was zero.
Fixed error with singular matrix.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/regression/pls.py

    r9114 r9119  
    6161from Orange.regression.earth import data_label_mask 
    6262from numpy import dot, zeros 
    63 from numpy.linalg import svd, inv 
     63from numpy.linalg import svd, pinv 
    6464 
    6565def normalize_matrix(X): 
     
    7474    """ 
    7575    muX, sigmaX = numpy.mean(X, axis=0), numpy.std(X, axis=0) 
     76    sigmaX[sigmaX == 0] = 1. 
    7677    return (X-muX)/sigmaX, muX, sigmaX 
    7778 
     
    383384        # U = Y C(Q'C)^-1 = YC* (W* : q x k matrix) 
    384385        self.xRotations = dot(self.W, 
    385             inv(dot(self.P.T, self.W))) 
     386            pinv(dot(self.P.T, self.W))) 
    386387        if Y.shape[1] > 1: 
    387388            self.yRotations = dot(self.C, 
    388                 inv(dot(self.Q.T, self.C))) 
     389                pinv(dot(self.Q.T, self.C))) 
    389390        else: 
    390391            self.yRotations = numpy.ones(1) 
Note: See TracChangeset for help on using the changeset viewer.