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

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

Moved orange to Orange (part 2)

Line 
1# Description: Manual categorization of continuous attributes.
2# Category:    preprocessing
3# Uses:        iris
4# Classes:     ClassifierFromVar, IntervalDiscretizer, getValueFrom
5# Referenced:  o_categorization.htm
6
7import orange
8
9def printexamples(data, inxs, msg="First %i examples"):
10  print msg % len(inxs)
11  for i in inxs:
12    print data[i]
13  print
14
15iris = orange.ExampleTable("iris")
16pl = orange.EnumVariable("pl")
17
18getValue = orange.ClassifierFromVar()
19getValue.whichVar = iris.domain["petal length"]
20getValue.classVar = pl
21getValue.transformer = orange.IntervalDiscretizer()
22getValue.transformer.points = [2.0, 4.0]
23
24pl.getValueFrom = getValue
25pl.values = ['low', 'medium', 'high']
26d_iris = iris.select(["petal length", pl, iris.domain.classVar])
27printexamples(d_iris, [0, 15, 35, 50, 98], "%i examples after discretization")
Note: See TracBrowser for help on using the repository browser.