source: orange/Orange/doc/reference/contingency2.py @ 9671:a7b056375472

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

Moved orange to Orange (part 2)

Line 
1# Description: Shows how to work with base class Contingency
2# Category:    statistics
3# Classes:     Contingency
4# Uses:        monk1
5# Referenced:  contingency.htm
6
7import orange
8data = orange.ExampleTable("monk1")
9
10cont = orange.Contingency(data.domain["e"], data.domain.classVar)
11for ex in data:
12    cont [ex["e"]] [ex.getclass()] += 1
13   
14print "Contingency items:"
15for val, dist in cont.items():
16    print val, dist
17print "Outer distribution: ", cont.outerDistribution
18print "Inner distribution: ", cont.outerDistribution
19print
20
21cont = orange.Contingency(data.domain["e"], data.domain.classVar)
22for ex in data:
23    cont.add(ex["e"], ex.getclass())
24   
25print "Contingency items (with add):"
26for val, dist in cont.items():
27    print val, dist
28print "Outer distribution: ", cont.outerDistribution
29print "Inner distribution: ", cont.outerDistribution
30print
Note: See TracBrowser for help on using the repository browser.