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

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

Tests moved and renamed from orange 20.

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.