source: orange/Orange/testing/regression/tests_20/reference_contingency2.py @ 9952:986e9cd806f4

Revision 9952:986e9cd806f4, 861 bytes checked in by Miha Stajdohar <miha.stajdohar@…>, 2 years ago (diff)

Tests moved and renamed from orange 20.

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.