source: orange/orange/doc/ofb/ensemble3.py @ 6538:a5f65d7f0b2c

Revision 6538:a5f65d7f0b2c, 932 bytes checked in by Mitar <Mitar@…>, 4 years ago (diff)

Made XPM version of the icon 32x32.

Line 
1# Description: Bagging and boosting with k-nearest neighbors
2# Category:    modelling
3# Uses:        promoters.tab
4# Classes:     orngTest.crossValidation, orngEnsemble.BaggedLearner, orngEnsemble.BoostedLearner
5# Referenced:  o_ensemble.htm
6
7import orange, orngTest, orngStat, orngEnsemble
8data = orange.ExampleTable("promoters")
9
10majority = orange.MajorityLearner()
11majority.name = "default"
12knn = orange.kNNLearner(k=11)
13knn.name = "k-NN (k=11)"
14
15bagged_knn = orngEnsemble.BaggedLearner(knn, t=10)
16bagged_knn.name = "bagged k-NN"
17boosted_knn = orngEnsemble.BoostedLearner(knn, t=10)
18boosted_knn.name = "boosted k-NN"
19
20learners = [majority, knn, bagged_knn, boosted_knn]
21results = orngTest.crossValidation(learners, data, folds=10)
22print "        Learner   CA     Brier Score"
23for i in range(len(learners)):
24    print ("%15s%5.3f  %5.3f") % (learners[i].name,
25        orngStat.CA(results)[i], orngStat.BrierScore(results)[i])
26
Note: See TracBrowser for help on using the repository browser.