source: orange/docs/reference/rst/code/scoring-all.py @ 9823:7f9c3f3c6474

Revision 9823:7f9c3f3c6474, 768 bytes checked in by lanumek, 2 years ago (diff)

Changed names of data sets (table replaced with data or name of the data set).

Line 
1# Description: Scoring and selection of best N features
2# Category:    feature scoring
3# Uses:        voting
4# Referenced:  Orange.feature.scoring
5# Classes:     Orange.feature.scoring.score_all, Orange.feature.scoring.Relief
6
7import Orange
8voting = Orange.data.Table("voting")
9
10def print_best_3(ma):
11    for m in ma[:3]:
12        print "%5.3f %s" % (m[1], m[0])
13
14print 'Feature scores for best three features (with score_all):'
15ma = Orange.feature.scoring.score_all(voting)
16print_best_3(ma)
17
18print
19
20print 'Feature scores for best three features (scored individually):'
21meas = Orange.feature.scoring.Relief(k=20, m=50)
22mr = [ (a.name, meas(a, voting)) for a in voting.domain.attributes]
23mr.sort(key=lambda x: -x[1]) #sort decreasingly by the score
24print_best_3(mr)
25
26
27
28
Note: See TracBrowser for help on using the repository browser.