source: orange/Orange/doc/ofb/disc3.py @ 9671:a7b056375472

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

Moved orange to Orange (part 2)

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.