Changeset 10196:5d3b38cb3478 in orange


Ignore:
Timestamp:
02/13/12 16:28:31 (2 years ago)
Author:
anzeh <anze.staric@…>
Branch:
default
Message:

Removed a duplicated function and fixed some warnings.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/evaluation/scoring.py

    r10195 r10196  
    1212    HAS_MATPLOTLIB = True 
    1313except ImportError: 
     14    matplotlib = None 
    1415    HAS_MATPLOTLIB = False 
    1516 
     
    602603 
    603604    return statistics_by_folds(ISs, foldN, report_se, False) 
    604  
    605  
    606 def Friedman(res, statistics, **argkw): 
    607     sums = None 
    608     for ri in split_by_iterations(res): 
    609         ranks = statc.rankdata(apply(statistics, (ri,), argkw)) 
    610         if sums: 
    611             sums = sums and [ranks[i]+sums[i] for i in range(k)] # TODO: What is k? 
    612         else: 
    613             sums = ranks 
    614             k = len(sums) 
    615     N = res.number_of_iterations 
    616     k = len(sums) 
    617     T = sum([x*x for x in sums]) 
    618     F = 12.0 / (N*k*(k+1)) * T  - 3 * N * (k+1) 
    619     return F, statc.chisqprob(F, k-1) 
    620605     
    621606 
     
    659644    :rtype: list of :obj:`ConfusionMatrix` 
    660645    """ 
    661     tfpns = [ConfusionMatrix() for i in range(test_results.number_of_learners)] 
     646    tfpns = [ConfusionMatrix() for _ in range(test_results.number_of_learners)] 
    662647     
    663648    if class_index<0: 
     
    11471132def TC_vertical_average_ROC(roc_curves, samples = 10): 
    11481133    def INTERPOLATE((P1x, P1y, P1fscore), (P2x, P2y, P2fscore), X): 
    1149         if (P1x == P2x) or ((X > P1x) and (X > P2x)) or ((X < P1x) and (X < P2x)): 
     1134        if (P1x == P2x) or P1x < X > P2x or P1x > X < P2x: 
    11501135            raise ValueError, "assumptions for interpolation are not met: P1 = %f,%f P2 = %f,%f X = %f" % (P1x, P1y, P2x, P2y, X) 
    11511136        dx = float(P2x) - float(P1x) 
     
    12631248        stdevH.append(TPstdH) 
    12641249 
    1265     return (average, stdevV, stdevH) 
     1250    return average, stdevV, stdevH 
    12661251 
    12671252## Calibration Curve 
     
    14461431        usefulClassPairs = 0. 
    14471432 
    1448         if method in [0, 2]: 
     1433        prob = None 
     1434        if method in [self.ByWeightedPairs, self.WeightedOneAgainstAll]: 
    14491435            prob = class_probabilities_from_res(res) 
    14501436 
    1451         if method <= 1: 
     1437        if method in [self.ByWeightedPairs, self.ByPairs]: 
    14521438            for classIndex1 in range(numberOfClasses): 
    14531439                for classIndex2 in range(classIndex1): 
     
    17401726        if stat==Brier_score: # reverse ranks for Brier_score (lower better) 
    17411727            ranks = [k+1-x for x in ranks] 
    1742         sums = [ranks[i]+sums[i] for i in range(k)] 
    1743  
    1744     T = sum([x*x for x in sums]) 
     1728        sums = map(add, ranks, sums) 
     1729 
     1730    T = sum(x*x for x in sums) 
    17451731    sums = [x/N for x in sums] 
    17461732 
Note: See TracChangeset for help on using the changeset viewer.