source:orange/docs/reference/rst/code/ensemble-forest.py@9638:eb3af38491f2

Revision 9638:eb3af38491f2, 1.3 KB checked in by umek@…, 2 years ago (diff)

Changed table to data or name of the data set.

table = Orange.data.Table("housing")

is changed to

housing = Orange.data.Table("housing")

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(minExamples=2, mForPrunning=2, \
11                            sameMajorityPruning=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.