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

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

Moved orange to Orange (part 2)

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("bridges")
9cont = orange.ContingencyAttrAttr("SPAN", "MATERIAL", data)
10
11print "Distributions:"
12for val in cont.outerVariable:
13    print "  p(.|%s) = %s" % (val.native(), cont.p_attr(val))
14print
15
16cont.normalize()
17for val in cont.outerVariable:
18    print "%s:" % val.native()
19    for inval, p in cont[val].items():
20        if p:
21            print "   %s (%i%%)" % (inval, int(100*p+0.5))
22    print
23
24cont = orange.ContingencyAttrAttr(data.domain["SPAN"], data.domain["MATERIAL"])
25for ex in data:
26    cont.add(ex["SPAN"], ex["MATERIAL"])
27
28print "Distributions from a matrix computed manually:"
29for val in cont.outerVariable:
30    print "  p(.|%s) = %s" % (val.native(), cont.p_attr(val))
31print
Note: See TracBrowser for help on using the repository browser.