source: orange/docs/reference/rst/code/transformvalue-o2c.py @ 9986:c6ae4843d946

Revision 9986:c6ae4843d946, 879 bytes checked in by markotoplak, 2 years ago (diff)

Added value transfromers to the hierarchy.

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.data
8import Orange.feature
9
10data = Orange.data.Table("lenses")
11age = data.domain["age"]
12
13age_c = Orange.feature.Continuous("age_c")
14age_c.getValueFrom = Orange.core.ClassifierFromVar(whichVar = age)
15age_c.getValueFrom.transformer = Orange.data.utils.Ordinal2Continuous()
16
17age_cn = Orange.feature.Continuous("age_cn")
18age_cn.getValueFrom = Orange.core.ClassifierFromVar(whichVar = age)
19age_cn.getValueFrom.transformer = Orange.data.utils.Ordinal2Continuous()
20age_cn.getValueFrom.transformer.factor = 0.5
21
22newDomain = Orange.data.Domain([age, age_c, age_cn], data.domain.classVar)
23newData = Orange.data.Table(newDomain, data)
24for ex in newData:
25    print ex
26print "\n\n"
Note: See TracBrowser for help on using the repository browser.