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

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

Tests moved and renamed from orange 20.

Line
1# Description: Demonstrates the use of ContingencyAttrClass
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 "Inner variable: ", cont.innerVariable.name
12print "Outer variable: ", cont.outerVariable.name
13print
14print "Class variable: ", cont.classVar.name
15print "Attribute:      ", cont.variable.name
16print
17
18print "Distributions:"
19for val in cont.variable:
20    print "  p(.|%s) = %s" % (val.native(), cont.p_class(val))
21print
22
23firstclass = orange.Value(cont.classVar, 1)
24firstnative = firstclass.native()
25print "Probabilities of class '%s'" % firstnative
26for val in cont.variable:
27    print "  p(%s|%s) = %5.3f" % (firstnative, val.native(), cont.p_class(val, firstclass))
28print
29
30cont = orange.ContingencyAttrClass(data.domain["e"], data.domain.classVar)
31for ex in data: