source: orange/docs/reference/rst/code/logreg-stepwise.py @ 9372:aef193695ea9

Revision 9372:aef193695ea9, 1.0 KB checked in by mitar, 2 years ago (diff)

Moved documentation to the separate directory.

Line 
1import Orange
2
3ionosphere = Orange.data.Table("ionosphere.tab")
4
5lr = Orange.classification.logreg.LogRegLearner(removeSingular=1)
6learners = (
7  Orange.classification.logreg.LogRegLearner(name='logistic', removeSingular=1),
8  Orange.feature.selection.FilteredLearner(lr,
9     filter=Orange.classification.logreg.StepWiseFSSFilter(addCrit=0.05, deleteCrit=0.9),
10     name='filtered')
11)
12results = Orange.evaluation.testing.cross_validation(learners, ionosphere, store_classifiers=1)
13
14# output the results
15print "Learner      CA"
16for i in range(len(learners)):
17    print "%-12s %5.3f" % (learners[i].name, Orange.evaluation.scoring.CA(results)[i])
18
19# find out which features were retained by filtering
20
21print "\nNumber of times features were used in cross-validation:"
22featuresUsed = {}
23for i in range(10):
24    for a in results.classifiers[i][1].atts():
25        if a.name in featuresUsed.keys():
26            featuresUsed[a.name] += 1
27        else:
28            featuresUsed[a.name] = 1
29for k in featuresUsed:
30    print "%2d x %s" % (featuresUsed[k], k)
Note: See TracBrowser for help on using the repository browser.