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

Revision 9372:aef193695ea9, 1.1 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.VarClass("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 "Feature:      ", cont.variable.name
11print
12
13print "Distributions:"
14for val in cont.variable:
15    print "  p(.|%s) = %s" % (val.native(), cont.p_class(val))
16print
17
18first_class = Orange.data.Value(cont.class_var, 1)
19first_native = first_class.native()
20print "Probabilities of class '%s'" % first_native
21for val in cont.variable:
22    print "  p(%s|%s) = %5.3f" % (first_native, val.native(), 
23                                  cont.p_class(val, first_class))
24print
25
26cont = Orange.statistics.contingency.VarClass(table.domain["e"],
27                                              table.domain.class_var)
28for ins in table:
29    cont.add_var_class(ins["e"], ins.getclass())
30
31print "Distributions from a matrix computed manually:"
32for val in cont.variable:
33    print "  p(.|%s) = %s" % (val.native(), cont.p_class(val))
34print
Note: See TracBrowser for help on using the repository browser.