source: orange/docs/reference/rst/code/statistics-contingency4.py @ 9372:aef193695ea9

Revision 9372:aef193695ea9, 1.0 KB checked in by mitar, 2 years ago (diff)

Moved documentation to the separate directory.

Line 
1import Orange.statistics.contingency
2
3table = Orange.data.Table("monks-1.tab")
4cont = Orange.statistics.contingency.ClassVar("e", table)
5
6print "Inner variable: ", cont.inner_variable.name
7print "Outer variable: ", cont.outer_variable.name
8print
9print "Class variable: ", cont.class_var.name
10print "Attribute:      ", cont.variable.name
11print
12
13print "Distributions:"
14for val in cont.class_var:
15    print "  p(.|%s) = %s" % (val.native(), cont.p_attr(val))
16print
17
18first_value = Orange.data.Value(cont.variable, 0)
19first_native = first_value.native()
20print "Probabilities for e='%s'" % first_native
21for val in cont.class_var:
22    print "  p(%s|%s) = %5.3f" % (first_native, val.native(), cont.p_attr(first_value, val))
23print
24
25cont = Orange.statistics.contingency.ClassVar(table.domain["e"], table.domain.class_var)
26for ins in table:
27    cont.add_var_class(ins["e"], ins.get_class())
28
29print "Distributions from a matrix computed manually:"
30for val in cont.class_var:
31    print "  p(.|%s) = %s" % (val.native(), cont.p_attr(val))
32print
Note: See TracBrowser for help on using the repository browser.