source: orange/docs/reference/rst/code/ensemble-forest-measure.py @ 9372:aef193695ea9

Revision 9372:aef193695ea9, 1023 bytes checked in by mitar, 2 years ago (diff)

Moved documentation to the separate directory.

Line 
1# Description: Demonstrates the use of random forests from Orange.ensemble.forest module
2# Category:    classification, ensembles
3# Classes:     RandomForestLearner
4# Uses:        iris.tab
5# Referenced:  orngEnsemble.htm
6
7import Orange
8import random
9
10files = [ "iris.tab" ]
11
12for fn in files:
13    print "\nDATA:" + fn + "\n"
14    table = Orange.data.Table(fn)
15
16    measure = Orange.ensemble.forest.ScoreFeature(trees=100)
17
18    #call by attribute index
19    imp0 = measure(0, table) 
20    #call by orange.Variable
21    imp1 = measure(table.domain.attributes[1], table)
22    print "first: %0.2f, second: %0.2f\n" % (imp0, imp1)
23
24    print "different random seed"
25    measure = Orange.ensemble.forest.ScoreFeature(trees=100, 
26            rand=random.Random(10))
27
28    imp0 = measure(0, table)
29    imp1 = measure(table.domain.attributes[1], table)
30    print "first: %0.2f, second: %0.2f\n" % (imp0, imp1)
31
32    print "All importances:"
33    for at in table.domain.attributes:
34        print "%15s: %6.2f" % (at.name, measure(at, table))
Note: See TracBrowser for help on using the repository browser.