source: orange/orange/doc/modules/ensemble3.py @ 1762:b6910a7aabf2

Revision 1762:b6910a7aabf2, 889 bytes checked in by blaz <blaz.zupan@…>, 9 years ago (diff)

example file used with orngEnsemble.htm

Line 
1# Description: Defines a tree learner (trunks of depth less than 5) and uses them in forest tree, prints out the number of nodes in each tree
2# Category:    classification, ensembles
3# Classes:     RandomForestLearner
4# Uses:        bupa.tab
5# Referenced:  orngEnsemble.htm
6
7import orange, orngTree, orngEnsemble
8
9data = orange.ExampleTable('bupa.tab')
10
11tree = orngTree.TreeLearner(storeNodeClassifier = 0, storeContingencies=0, \
12  storeDistributions=1, minExamples=5, ).instance()
13gini = orange.MeasureAttribute_gini()
14tree.split.discreteSplitConstructor.measure = \
15  tree.split.continuousSplitConstructor.measure = gini
16tree.maxDepth = 5
17tree.split = orngEnsemble.SplitConstructor_AttributeSubset(tree.split, 3)
18
19forestLearner = orngEnsemble.RandomForestLearner(learner=tree, trees=50)
20forest = forestLearner(data)
21
22for c in forest.classifiers:
23    print orngTree.countNodes(c),
24print
Note: See TracBrowser for help on using the repository browser.