Changeset 10196:5d3b38cb3478 in orange
 Timestamp:
 02/13/12 16:28:31 (2 years ago)
 Branch:
 default
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Orange/evaluation/scoring.py
r10195 r10196 12 12 HAS_MATPLOTLIB = True 13 13 except ImportError: 14 matplotlib = None 14 15 HAS_MATPLOTLIB = False 15 16 … … 602 603 603 604 return statistics_by_folds(ISs, foldN, report_se, False) 604 605 606 def Friedman(res, statistics, **argkw):607 sums = None608 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 = ranks614 k = len(sums)615 N = res.number_of_iterations616 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, k1)620 605 621 606 … … 659 644 :rtype: list of :obj:`ConfusionMatrix` 660 645 """ 661 tfpns = [ConfusionMatrix() for iin range(test_results.number_of_learners)]646 tfpns = [ConfusionMatrix() for _ in range(test_results.number_of_learners)] 662 647 663 648 if class_index<0: … … 1147 1132 def TC_vertical_average_ROC(roc_curves, samples = 10): 1148 1133 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: 1150 1135 raise ValueError, "assumptions for interpolation are not met: P1 = %f,%f P2 = %f,%f X = %f" % (P1x, P1y, P2x, P2y, X) 1151 1136 dx = float(P2x)  float(P1x) … … 1263 1248 stdevH.append(TPstdH) 1264 1249 1265 return (average, stdevV, stdevH)1250 return average, stdevV, stdevH 1266 1251 1267 1252 ## Calibration Curve … … 1446 1431 usefulClassPairs = 0. 1447 1432 1448 if method in [0, 2]: 1433 prob = None 1434 if method in [self.ByWeightedPairs, self.WeightedOneAgainstAll]: 1449 1435 prob = class_probabilities_from_res(res) 1450 1436 1451 if method <= 1:1437 if method in [self.ByWeightedPairs, self.ByPairs]: 1452 1438 for classIndex1 in range(numberOfClasses): 1453 1439 for classIndex2 in range(classIndex1): … … 1740 1726 if stat==Brier_score: # reverse ranks for Brier_score (lower better) 1741 1727 ranks = [k+1x 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) 1745 1731 sums = [x/N for x in sums] 1746 1732
Note: See TracChangeset
for help on using the changeset viewer.