source: orange/orange/doc/ofb/disc3.py @ 6538:a5f65d7f0b2c

Revision 6538:a5f65d7f0b2c, 1.1 KB checked in by Mitar <Mitar@…>, 4 years ago (diff)

Made XPM version of the icon 32x32.

Line 
1# Description: Attribute-based discretization. Shows how different attributes may be discretized with different categorization methods and how the default attribute values names used by these methods may be simply replaced by the list of user-defined names.
2# Category:    preprocessing
3# Uses:        iris
4# Classes:     EquiNDiscretization, EntropyDiscretization
5# Referenced:  o_categorization.htm
6
7def printexamples(data, inxs, msg="%i examples"):
8  print msg % len(inxs)
9  for i in inxs:
10    print i, data[i]
11  print
12
13import orange
14iris = orange.ExampleTable("iris")
15
16equiN = orange.EquiNDiscretization(numberOfIntervals=4)
17entropy = orange.EntropyDiscretization()
18
19pl = equiN("petal length", iris)
20sl = equiN("sepal length", iris)
21pl.values = sl.values = ["very low", "low", "high", "very high"]
22sl_ent = entropy("sepal length", iris)
23
24inxs = [0, 15, 35, 50, 98]
25d_iris = iris.select(["sepal width", pl, "sepal length",sl, sl_ent, iris.domain.classVar])
26printexamples(iris, inxs, "%i examples before discretization")
27printexamples(d_iris, inxs, "%i examples before discretization")
Note: See TracBrowser for help on using the repository browser.