source: orange/Orange/doc/ofb/domain13.py @ 9671:a7b056375472

Revision 9671:a7b056375472, 1.0 KB checked in by anze <anze.staric@…>, 2 years ago (diff)

Moved orange to Orange (part 2)

Line 
1# Description: Adds two new numerical attributes to iris data set, and tests through cross validation if this helps in boosting classification accuracy
2# Category:    modelling
3# Uses:        iris
4# Classes:     Domain, FloatVariable, MakeRandomIndicesCV, orngTest.testWithIndices
5# Referenced:  domain.htm
6
7import orange, orngTest, orngStat, orngTree
8data = orange.ExampleTable('iris')
9
10sa = orange.FloatVariable("sepal area")
11sa.getValueFrom = lambda e, getWhat: e['sepal length'] * e['sepal width']
12pa = orange.FloatVariable("petal area")
13pa.getValueFrom = lambda e, getWhat: e['petal length'] * e['petal width']
14
15newdomain = orange.Domain(data.domain.attributes+[sa, pa, data.domain.classVar])
16newdata = data.select(newdomain)
17
18learners = [orngTree.TreeLearner(mForPruning=2.0)]
19
20indices = orange.MakeRandomIndicesCV(data, 10)
21res1 = orngTest.testWithIndices(learners, data, indices)
22res2 = orngTest.testWithIndices(learners, newdata, indices)
23
24print "original: %5.3f, new: %5.3f" % (orngStat.CA(res1)[0], orngStat.CA(res2)[0])
Note: See TracBrowser for help on using the repository browser.