source: orange/orange/doc/reference/transformvalue-nc.py @ 822:80bf64dfc34a

Revision 822:80bf64dfc34a, 825 bytes checked in by janezd <janez.demsar@…>, 10 years ago (diff)

* empty log message *

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("iris")
10
11domstat = orange.DomainBasicAttrStat(data)
12newattrs = []
13for attr in data.domain.attributes:
14    attr_c = orange.FloatVariable(attr.name+"_n")
15    attr_c.getValueFrom = orange.ClassifierFromVar(whichVar = attr)
16    transformer = orange.NormalizeContinuous()
17    attr_c.getValueFrom.transformer = transformer
18    transformer.average = domstat[attr].avg
19    transformer.span = domstat[attr].dev/2
20    newattrs.append(attr_c)
21
22newDomain = orange.Domain(newattrs, data.domain.classVar)
23newData = orange.ExampleTable(newDomain, data)
24for ex in newData[:5]:
25    print ex
26print "\n\n"
Note: See TracBrowser for help on using the repository browser.