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

Revision 9952:986e9cd806f4, 1.0 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 ContingencyClassAttr
2# Category:    statistics
3# Classes:     Contingency, ContingencyClassAttr
4# Uses:        monk1
5# Referenced:  contingency.htm
6
7import orange
8data = orange.ExampleTable("iris")
9cont = orange.ContingencyClassAttr("sepal length", 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.classVar:
20    print "  p(.|%s) = %s" % (val.native(), cont.p_attr(val))
21print
22
23print "Probabilities for e=5.5"
24for val in cont.classVar:
25    print "  p(%s|%s) = %5.3f" % (5.5, val.native(), cont.p_attr(5.5, val))
26print
27
28cont = orange.ContingencyClassAttr(data.domain["sepal length"], data.domain.classVar)
29for ex in data:
30    cont.add_attrclass(ex["sepal length"], ex.getclass())
31
32print "Distributions from a matrix computed manually:"
33for val in cont.classVar:
34    print "  p(.|%s) = %s" % (val.native(), cont.p_attr(val))
35print
Note: See TracBrowser for help on using the repository browser.