Changeset 9243:cc2ddc8cc69d in orange


Ignore:
Timestamp:
11/22/11 16:16:47 (2 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
75295d50e8106926336a4720b6b297d5c2833d13
Message:

Use statc for betai, fprob if scipy is not installed.
Fixed KeyboardInterupt handling in stepwise function.

File:
1 edited

Legend:

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

    r9242 r9243  
    5555from Orange.regression import base 
    5656import numpy 
    57 import scipy.stats 
     57 
     58try: 
     59    from scipy import stats 
     60except ImportError: 
     61    import statc as stats 
    5862 
    5963from numpy import dot, sqrt 
     
    222226        std_error = sqrt(sigma_square*pinv(dot(X.T, X)).diagonal()) 
    223227        t_scores = coefficients/std_error 
    224         p_vals = [scipy.stats.betai(df*0.5,0.5,df/(df + t*t)) \ 
     228        p_vals = [stats.betai(df*0.5,0.5,df/(df + t*t)) \ 
    225229                  for t in t_scores] 
    226230 
     
    459463        return 1.0 
    460464    F = ((RSS1-RSS2)/(p2-p1))/(RSS2/(n-p2)) 
    461     return scipy.stats.fprob(int(p2-p1), int(n-p2), F) 
     465    return stats.fprob(int(p2-p1), int(n-p2), F) 
    462466 
    463467 
     
    500504                reduced_model.append(LinearRegressionLearner(table, weight, 
    501505                        use_vars=inc_vars[:ati] + inc_vars[(ati + 1):])) 
    502             except: 
     506            except Exception: 
    503507                reduced_model.append(None) 
    504508         
     
    519523                extended_model.append(LinearRegressionLearner(table, 
    520524                        weight, use_vars=inc_vars + [not_inc_vars[ati]])) 
    521             except: 
     525            except Exception: 
    522526                extended_model.append(None) 
    523527              
Note: See TracChangeset for help on using the changeset viewer.