source: orange/docs/tutorial/rst/code/fss6.py @ 11054:eca373fb96a9

Revision 11054:eca373fb96a9, 788 bytes checked in by blaz <blaz.zupan@…>, 16 months ago (diff)

new tutorial (refresh after removal of old files)

Line 
1# Author:      B Zupan
2# Version:     1.0
3# Description: Same as fss5.py but uses FilterRelieff class from orngFSS
4# Category:    preprocessing
5# Uses:        adult_saple.tab
6# Referenced:  o_fss.htm
7
8import orngFSS
9import Orange
10data = Orange.data.Table("adult_sample.tab")
11
12def report_relevance(data):
13  m = Orange.feature.scoring.score_all(data)
14  for i in m:
15    print "%5.3f %s" % (i[1], i[0])
16
17print "Before feature subset selection (%d attributes):" % len(data.domain.attributes)
18report_relevance(data)
19data = Orange.data.Table("adult_sample.tab")
20
21marg = 0.01
22filter = Orange.feature.selection.FilterRelief(margin=marg)
23ndata = filter(data)
24print "\nAfter feature subset selection with margin %5.3f (%d attributes):" % (marg, len(ndata.domain.attributes))
25report_relevance(ndata)
Note: See TracBrowser for help on using the repository browser.