Changeset 10902:393ef8a8dd2d in orange
 Timestamp:
 06/04/12 16:52:41 (23 months ago)
 Branch:
 default
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Orange/evaluation/scoring.py
r10901 r10902 43 43 raise ValueError, "Cannot compute the score: no examples." 44 44 45 # Backward compatibility 46 def replace_use_weights(fun): 47 if environ.orange_no_deprecated_members: 48 return fun 49 50 @functools.wraps(fun) 51 def wrapped(*args, **kwargs): 52 use_weights = kwargs.pop("useWeights", None) 53 if use_weights is not None: 54 deprecation_warning("useWeights", "ignore_weights") 55 kwargs["ignore_weights"] = not use_weights 56 return fun(*args, **kwargs) 57 return wrapped 58 59 def replace_discrete_probabilities_with_list(method): 60 if environ.orange_no_deprecated_members: 61 return lambda fun: fun 62 63 def decorator(fun): 64 @functools.wraps(fun) 65 def wrapped(*args, **kwargs): 66 res = args[method] if len(args)>method else kwargs.get("res", kwargs.get("test_results", None)) 67 convert = res is not None 68 69 if convert: 70 old_probs = [] 71 for r in res.results: 72 old_probs.append(r.probabilities) 73 r.probabilities = [list(p) if type(p) is Orange.statistics.distribution.Discrete 74 else p for p in r.probabilities] 75 result = fun(*args, **kwargs) 76 if convert: 77 for r, old in zip(res.results, old_probs): 78 r.probabilities = old 79 return result 80 return wrapped 81 return decorator 45 82 46 83 def split_by_iterations(res): … … 998 1035 @deprecated_keywords({"classIndex": "class_index", 999 1036 "unweighted": "ignore_weights"}) 1037 @replace_discrete_probabilities_with_list(False) 1000 1038 def AUCWilcoxon(res, class_index= 1, ignore_weights=False, **argkw): 1001 1039 """Compute the area under ROC (AUC) and its standard error using … … 1041 1079 @deprecated_keywords({"classIndex": "class_index", 1042 1080 "unweighted": "ignore_weights"}) 1081 @replace_discrete_probabilities_with_list(False) 1043 1082 def compare_2_AUCs(res, lrn1, lrn2, class_index= 1, 1044 1083 ignore_weights=False, **argkw): … … 1051 1090 1052 1091 @deprecated_keywords({"classIndex": "class_index"}) 1092 @replace_discrete_probabilities_with_list(False) 1053 1093 def compute_ROC(res, class_index= 1): 1054 1094 """Compute a ROC curve as a list of (x, y) tuples, where x is … … 1110 1150 @deprecated_keywords({"classIndex": "class_index", 1111 1151 "keepConcavities": "keep_concavities"}) 1152 @replace_discrete_probabilities_with_list(False) 1112 1153 def TC_compute_ROC(res, class_index= 1, keep_concavities=1): 1113 1154 problists, tots = corn.computeROCCumulative(res, class_index) … … 1338 1379 ##  noClassRugPoints is an array of (x, 0) points 1339 1380 @deprecated_keywords({"classIndex": "class_index"}) 1381 @replace_discrete_probabilities_with_list(False) 1340 1382 def compute_calibration_curve(res, class_index= 1): 1341 1383 ## merge multiple iterations into one … … 1404 1446 ## on the Lift Curve 1405 1447 @deprecated_keywords({"classIndex": "class_index"}) 1448 @replace_discrete_probabilities_with_list(False) 1406 1449 def compute_lift_curve(res, class_index= 1): 1407 1450 ## merge multiple iterations into one … … 1442 1485 @deprecated_keywords({"classIndex": "class_index", 1443 1486 "unweighted": "ignore_weights"}) 1487 @replace_discrete_probabilities_with_list(False) 1444 1488 def compute_CDT(res, class_index= 1, ignore_weights=False, **argkw): 1445 1489 """Obsolete, don't use.""" … … 1469 1513 else: 1470 1514 return corn.computeCDT(res, class_index, useweights) 1471 1472 # Backward compatibility1473 def replace_use_weights(fun):1474 if environ.orange_no_deprecated_members:1475 return fun1476 1477 @functools.wraps(fun)1478 def wrapped(*args, **kwargs):1479 use_weights = kwargs.pop("useWeights", None)1480 if use_weights is not None:1481 deprecation_warning("useWeights", "ignore_weights")1482 kwargs["ignore_weights"] = not use_weights1483 return fun(*args, **kwargs)1484 return wrapped1485 1486 def replace_discrete_probabilities_with_list(method=False):1487 if environ.orange_no_deprecated_members:1488 return lambda fun: fun1489 1490 def decorator(fun):1491 @functools.wraps(fun)1492 def wrapped(*args, **kwargs):1493 res = args[method] if len(args)>method else kwargs.get("res", kwargs.get("test_results", None))1494 convert = res is not None1495 1496 if convert:1497 old_probs = []1498 for r in res.results:1499 old_probs.append(r.probabilities)1500 r.probabilities = [list(p) if type(p) is Orange.statistics.distribution.Discrete1501 else p for p in r.probabilities]1502 result = fun(*args, **kwargs)1503 if convert:1504 for r, old in zip(res.results, old_probs):1505 r.probabilities = old1506 return result1507 return wrapped1508 return decorator1509 1515 1510 1516 class AUC(list): … … 1801 1807 #Backward compatibility 1802 1808 @replace_use_weights 1803 @replace_discrete_probabilities_with_list 1809 @replace_discrete_probabilities_with_list(False) 1804 1810 def AUC_binary(res, ignore_weights=False): 1805 1811 auc = deprecated_function_name(AUC)(ignore_weights=ignore_weights) … … 1808 1814 1809 1815 @replace_use_weights 1810 @replace_discrete_probabilities_with_list 1816 @replace_discrete_probabilities_with_list(False) 1811 1817 def AUC_multi(res, ignore_weights=False, method=0): 1812 1818 auc = deprecated_function_name(AUC)(ignore_weights=ignore_weights, … … 1857 1863 1858 1864 @deprecated_keywords({"unweighted": "ignore_weights"}) 1859 @replace_discrete_probabilities_with_list 1865 @replace_discrete_probabilities_with_list(False) 1860 1866 def McNemar(res, ignore_weights=False, **argkw): 1861 1867 """ … … 1905 1911 return mcm 1906 1912 1907 @replace_discrete_probabilities_with_list 1913 @replace_discrete_probabilities_with_list(False) 1908 1914 def McNemar_of_two(res, lrn1, lrn2, ignore_weights=False): 1909 1915 """ … … 1935 1941 return 0 1936 1942 1937 @replace_discrete_probabilities_with_list 1943 @replace_discrete_probabilities_with_list(False) 1938 1944 def Friedman(res, stat=CA): 1939 1945 """ … … 1960 1966 return F, statc.chisqprob(F, k  1), sums 1961 1967 1962 @replace_discrete_probabilities_with_list 1968 @replace_discrete_probabilities_with_list(False) 1963 1969 def Wilcoxon_pairs(res, avgranks, stat=CA): 1964 1970 """
Note: See TracChangeset
for help on using the changeset viewer.