source: orange/docs/tutorial/rst/code/disc2.py @ 9374:59bac7ddd8a2

Revision 9374:59bac7ddd8a2, 980 bytes checked in by mitar, 2 years ago (diff)

Tutorial documentation structure.

Line 
1# Description: Attribute-based discretization. Shows how different attributes may be discretized with different categorization methods. Also shows how the resulting domain is put together using orange.select.
2# Category:    preprocessing
3# Uses:        iris
4# Classes:     EquiNDiscretization, EntropyDiscretization
5# Referenced:  o_categorization.htm
6
7def printexamples(data, inxs, msg="First %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)
21sl_ent = entropy("sepal length", iris)
22
23inxs = [0, 15, 35, 50, 98]
24d_iris = iris.select(["sepal width", pl, "sepal length",sl, sl_ent, iris.domain.classVar])
25printexamples(iris, inxs, "%i examples before discretization")
26printexamples(d_iris, inxs, "%i examples before discretization")
Note: See TracBrowser for help on using the repository browser.