Ignore:
Timestamp:
08/02/13 15:35:07 (9 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Fixed 'top_rated' function (actually use the 'highest_best' parameter).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/feature/selection.py

    r10709 r11645  
    66 
    77from Orange.feature.scoring import score_all 
     8 
    89 
    910def top_rated(scores, n, highest_best=True): 
    1011    """Return n top-rated features from the list of scores. 
    1112 
    12     :param scores: a list such as the one returned by 
    13       :obj:`~Orange.feature.scoring.score_all` 
    14     :type scores: list 
    15     :param n: number of features to select. 
    16     :type n: int 
     13    :param list scores: 
     14        A list such as the one returned by :func:`.score_all` 
     15    :param int n: Number of features to select. 
     16    :param bool highest_best: 
     17        If true, the features that are scored higher are preferred. 
    1718    :rtype: :obj:`list` 
    18     :param highest_best: if true, the features that are scored higher are preferred 
    19     :type highest_best: bool 
    20     """ 
    21     return [x[0] for x in \ 
    22             sorted(scores, key=itemgetter(1), reverse=True)[:n] 
    23             ] 
     19 
     20    """ 
     21    return [f for f, score in 
     22            sorted(scores, key=itemgetter(1), reverse=highest_best)[:n]] 
    2423 
    2524bestNAtts = top_rated 
     25 
    2626 
    2727def above_threshold(scores, threshold=0.0): 
Note: See TracChangeset for help on using the changeset viewer.