source: orange/Orange/doc/reference/transformvalue-miv.py @ 9671:a7b056375472

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

Moved orange to Orange (part 2)

Line 
1# Description: Shows how to use value transformers
2# Category:    preprocessing
3# Classes:     TransformValue, Continuous2Discrete, Discrete2Continuous, MapIntValue
4# Uses:       
5# Referenced:
6
7import orange
8
9data = orange.ExampleTable("lenses")
10
11age = data.domain["age"]
12
13age_b = orange.EnumVariable("age_c", values = ['young', 'old'])
14age_b.getValueFrom = orange.ClassifierFromVar(whichVar = age)
15age_b.getValueFrom.transformer = orange.MapIntValue()
16age_b.getValueFrom.transformer.mapping = [0, 1, 1]
17
18newDomain = orange.Domain([age_b, age], data.domain.classVar)
19newData = orange.ExampleTable(newDomain, data)
20for ex in newData:
21    print ex
22print "\n\n"
Note: See TracBrowser for help on using the repository browser.