source: orange/docs/reference/rst/code/logreg-stepwise.py @ 9818:2ec8ecdb81e5

Revision 9818:2ec8ecdb81e5, 1.0 KB checked in by Matija Polajnar <matija.polajnar@…>, 2 years ago (diff)

Finish the logreg refactoring, along with documentation improvement.

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