Ignore:
Timestamp:
03/21/12 18:36:55 (2 years ago)
Author:
Lan Zagar <lan.zagar@…>
Branch:
default
rebase_source:
9d5ef63413e4b9281221b551d5a2dcbe12b366ca
Message:

Dont regularize the intercept and avoid div by zero.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/regression/linear.py

    r10599 r10605  
    246246         
    247247        if self.ridge_lambda: 
    248             cov += self.ridge_lambda * numpy.eye(m + self.intercept) 
     248            stride = cov.shape[0] + 1 
     249            cov.flat[self.intercept * stride::stride] += self.ridge_lambda 
    249250 
    250251        # adds some robustness by computing the pseudo inverse; 
     
    257258        if m > 0: 
    258259            cov_x = numpy.cov(X, rowvar=0) 
    259  
    260260            # standardized coefficients 
    261261            std_coefficients = sqrt(cov_x.diagonal()) / sigma_y * coefficients 
     
    284284        r2 = ssr / sst 
    285285        r2adj = 1 - (1 - r2) * (n - 1) / (n - m - 1) 
    286         F = (ssr / m) / (sst - ssr / (n - m - 1)) 
     286        F = (ssr / m) / (sst - ssr / (n - m - 1)) if m else None 
    287287        df = n - 2 
    288288        sigma_square = sse / (n - m - 1) 
Note: See TracChangeset for help on using the changeset viewer.