source: orange/docs/reference/rst/code/statistics-contingency7.py @ 9823:7f9c3f3c6474

Revision 9823:7f9c3f3c6474, 954 bytes checked in by lanumek, 2 years ago (diff)

Changed names of data sets (table replaced with data or name of the data set).

Line 
1import Orange
2
3iris = Orange.data.Table("iris")
4cont = Orange.statistics.contingency.ClassVar("sepal length", iris)
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
18print "Estimated for e=5.5"
19for val in cont.class_var:
20    print "  f(%s|%s) = %5.3f" % (5.5, val.native(), cont.p_attr(5.5, val))
21print
22
23cont = Orange.statistics.contingency.ClassVar(iris.domain["sepal length"], 
24                                              iris.domain.class_var)
25for ins in iris:
26    cont.add_var_class(ins["sepal length"], ins.get_class())
27
28print "Distributions from a matrix computed manually:"
29for val in cont.class_var:
30    print "  p(.|%s) = %s" % (val.native(), cont.p_attr(val))
31print
Note: See TracBrowser for help on using the repository browser.