source: orange/docs/reference/rst/code/ensemble-forest.py @ 10633:fb05a6f3a235

Revision 10633:fb05a6f3a235, 1.3 KB checked in by mstajdohar, 2 years ago (diff)

Changed obsolete names.

Line 
1# Description: Demonstrates the use of random forests from Orange.ensemble.forest module
2# Category:    classification, ensembles
3# Classes:     RandomForestLearner
4# Uses:        bupa.tab
5# Referenced:  orngEnsemble.htm
6
7import Orange
8
9forest = Orange.ensemble.forest.RandomForestLearner(trees=50, name="forest")
10tree = Orange.classification.tree.TreeLearner(min_instances=2, m_pruning=2, \
11                            same_majority_pruning=True, name='tree')
12learners = [tree, forest]
13
14print "Classification: bupa.tab"
15bupa = Orange.data.Table("bupa.tab")
16results = Orange.evaluation.testing.cross_validation(learners, bupa, folds=3)
17print "Learner  CA     Brier  AUC"
18for i in range(len(learners)):
19    print "%-8s %5.3f  %5.3f  %5.3f" % (learners[i].name, \
20        Orange.evaluation.scoring.CA(results)[i],
21        Orange.evaluation.scoring.Brier_score(results)[i],
22        Orange.evaluation.scoring.AUC(results)[i])
23
24print "Regression: housing.tab"
25bupa = Orange.data.Table("housing.tab")
26results = Orange.evaluation.testing.cross_validation(learners, bupa, folds=3)
27print "Learner  MSE    RSE    R2"
28for i in range(len(learners)):
29    print "%-8s %5.3f  %5.3f  %5.3f" % (learners[i].name, \
30        Orange.evaluation.scoring.MSE(results)[i],
31        Orange.evaluation.scoring.RSE(results)[i],
32        Orange.evaluation.scoring.R2(results)[i],)
Note: See TracBrowser for help on using the repository browser.