source: orange/Orange/testing/regression/tests_20/modules_logreg3.py @ 9952:986e9cd806f4

Revision 9952:986e9cd806f4, 1.1 KB checked in by Miha Stajdohar <miha.stajdohar@…>, 2 years ago (diff)

Tests moved and renamed from orange 20.

Line 
1# Description: Demonstrates the use of logistic regression
2# Category:    classification, logistic regression
3# Classes:     LogRegLearner, StepWiseFSS_Filter
4# Uses:        ionosphere.tab
5
6import orange
7import orngFSS, orngTest, orngStat, orngLR
8
9data = orange.ExampleTable("../datasets/ionosphere.tab")
10
11lr = orngLR.LogRegLearner(removeSingular=1) 
12
13learners = [orngLR.LogRegLearner(name='logistic', removeSingular=1),
14            orngFSS.FilteredLearner(lr, filter=orngLR.StepWiseFSS_Filter(addCrit=0.05, deleteCrit=0.9),
15                                    name='filtered')
16            ]
17
18results = orngTest.crossValidation(learners, data, storeClassifiers=1)
19
20print "Learner      CA"
21for i in range(len(learners)):
22    print "%-12s %5.3f" % (learners[i].name, orngStat.CA(results)[i]) 
23
24
25print "\nNumber of times attributes were used in cross-validation:" 
26
27attsUsed = {}
28for i in range(10):
29    for a in results.classifiers[i][1].atts():
30        if a.name in attsUsed.keys():
31            attsUsed[a.name] += 1
32        else:
33            attsUsed[a.name] = 1
34           
35for k in attsUsed.keys():
36    print "%2d x %s" % (attsUsed[k], k) 
Note: See TracBrowser for help on using the repository browser.