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

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

Tests moved and renamed from orange 20.

Line 
1# Description: Shows what the contingency matrix looks like and which are its common methods
2# Category:    statistics
3# Classes:     Contingency, ContingencyAttrClass
4# Uses:        monk1
5# Referenced:  contingency.htm
6
7import orange
8data = orange.ExampleTable("monk1")
9cont = orange.ContingencyAttrClass("e", data)
10
11print "Contingency items:"
12for val, dist in cont.items():
13    print val, dist
14print
15
16print "Contingency keys: ", cont.keys()
17print "Contingency values: ", cont.values()
18print "Contingency items: ", cont.items()
19print
20
21print "cont[0] =",cont[0]
22print 'cont[\"1\"] =', cont["1"]
23print 'cont[orange.Value(data.domain["e"], "1")] =', cont[orange.Value(data.domain["e"], "1")]
24print
25
26print "Iteration through contingency:"
27for i in cont:
28    print i
29print
30
31cont.normalize()
32print "Contingency items after normalization:"
33for val, dist in cont.items():
34    print val, dist
35print
Note: See TracBrowser for help on using the repository browser.