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

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

Made XPM version of the icon 32x32.

Line 
1# Description: Uses cross-validation to compare regression tree and k-nearest neighbors
2# Category:    modelling, evaluation
3# Uses:        housing
4# Classes:     orngStat.MSE, orngTest.crossValidation, MajorityLearner, orngTree.TreeLearner, orange.kNNLearner
5# Referenced:  regression.htm
6
7import orange, orngTree, orngTest, orngStat
8
9data = orange.ExampleTable("../datasets/housing.tab")
10
11maj = orange.MajorityLearner()
12maj.name = "default"
13rt = orngTree.TreeLearner(measure="retis", mForPruning=2, minExamples=20)
14rt.name = "regression tree"
15k = 5
16knn = orange.kNNLearner(k=k)
17knn.name = "k-NN (k=%i)" % k
18learners = [maj, rt, knn]
19
20data = orange.ExampleTable("../datasets/housing.tab")
21results = orngTest.crossValidation(learners, data, folds=10)
22mse = orngStat.MSE(results)
23
24print "Learner        MSE"
25for i in range(len(learners)):
26  print "%-15s %5.3f" % (learners[i].name, mse[i])
Note: See TracBrowser for help on using the repository browser.