Changeset 10900:a07531c84486 in orange for Orange/evaluation/scoring.py
 Timestamp:
 06/04/12 15:44:23 (23 months ago)
 Branch:
 default
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Orange/evaluation/scoring.py
r10857 r10900 1484 1484 return wrapped 1485 1485 1486 def replace_discrete_probabilities_with_list(method=False): 1487 if environ.orange_no_deprecated_members: 1488 return fun 1489 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 None 1495 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.Discrete 1501 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 = old 1506 return result 1507 return wrapped 1508 return decorator 1509 1486 1510 class AUC(list): 1487 1511 """ … … 1539 1563 self[:] = self.__call__(test_results) 1540 1564 1565 @replace_discrete_probabilities_with_list(method=True) 1541 1566 def __call__(self, test_results): 1542 1567 if len(test_results.class_values) < 2: … … 1722 1747 super(AUC_for_single_class, self).__init__(test_results, ignore_weights=ignore_weights) 1723 1748 1749 @replace_discrete_probabilities_with_list(method=True) 1724 1750 def __call__(self, test_results): 1725 1751 return self._compute_for_single_class(test_results, self.class_index) … … 1737 1763 super(AUC_for_pair_of_classes, self).__init__(test_results, ignore_weights=ignore_weights) 1738 1764 1765 @replace_discrete_probabilities_with_list(method=True) 1739 1766 def __call__(self, test_results): 1740 1767 return self._compute_for_pair_of_classes(test_results, self.class_index1, self.class_index2) … … 1748 1775 """ 1749 1776 1777 @replace_discrete_probabilities_with_list(method=True) 1750 1778 def __call__(self, test_results): 1751 1779 numberOfClasses = len(test_results.class_values) … … 1773 1801 #Backward compatibility 1774 1802 @replace_use_weights 1803 @replace_discrete_probabilities_with_list 1775 1804 def AUC_binary(res, ignore_weights=False): 1776 1805 auc = deprecated_function_name(AUC)(ignore_weights=ignore_weights) … … 1779 1808 1780 1809 @replace_use_weights 1810 @replace_discrete_probabilities_with_list 1781 1811 def AUC_multi(res, ignore_weights=False, method=0): 1782 1812 auc = deprecated_function_name(AUC)(ignore_weights=ignore_weights, … … 1827 1857 1828 1858 @deprecated_keywords({"unweighted": "ignore_weights"}) 1859 @replace_discrete_probabilities_with_list 1829 1860 def McNemar(res, ignore_weights=False, **argkw): 1830 1861 """ … … 1874 1905 return mcm 1875 1906 1876 1907 @replace_discrete_probabilities_with_list 1877 1908 def McNemar_of_two(res, lrn1, lrn2, ignore_weights=False): 1878 1909 """ … … 1904 1935 return 0 1905 1936 1906 1937 @replace_discrete_probabilities_with_list 1907 1938 def Friedman(res, stat=CA): 1908 1939 """ … … 1929 1960 return F, statc.chisqprob(F, k  1), sums 1930 1961 1931 1962 @replace_discrete_probabilities_with_list 1932 1963 def Wilcoxon_pairs(res, avgranks, stat=CA): 1933 1964 """
Note: See TracChangeset
for help on using the changeset viewer.