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

Revision 9671:a7b056375472, 825 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("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.