source: orange/Orange/doc/ofb/accuracy.py @ 9671:a7b056375472

Revision 9671:a7b056375472, 461 bytes checked in by anze <anze.staric@…>, 2 years ago (diff)

Moved orange to Orange (part 2)

Line 
1# Description: Learn a naive Bayesian classifier, and measure classification accuracy on the same data set
2# Category:    evaluation
3# Uses:        voting.tab
4# Referenced:  c_performance.htm
5
6import orange
7data = orange.ExampleTable("voting")
8classifier = orange.BayesLearner(data)
9
10# compute classification accuracy
11correct = 0.0
12for ex in data:
13    if classifier(ex) == ex.getclass():
14        correct += 1
15print "Classification accuracy:", correct/len(data)
Note: See TracBrowser for help on using the repository browser.