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

Revision 822:80bf64dfc34a, 1.6 KB 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
8print
9
10def printExample(ex):
11    for val in ex:
12        print "%16s: %s" % (val.variable.name, val)
13
14data = orange.ExampleTable("bridges")
15
16for attr in data.domain:
17    if attr.varType == orange.VarTypes.Continuous:
18        print "%20s: continuous" % attr.name
19    else:
20        print "%20s: %s" % (attr.name, attr.values)
21
22print
23print "Original 15th example:"
24printExample(data[15])
25
26continuizer = orange.DomainContinuizer()
27
28continuizer.multinomialTreatment = continuizer.LowestIsBase
29domain0 = continuizer(data)
30data0 = data.translate(domain0)
31print
32print "Lowest is base"
33printExample(data0[15])
34
35continuizer.multinomialTreatment = continuizer.FrequentIsBase
36domain0 = continuizer(data)
37data0 = data.translate(domain0)
38print
39print "Frequent is base"
40printExample(data0[15])
41
42
43continuizer.multinomialTreatment = continuizer.NValues
44domain0 = continuizer(data)
45data0 = data.translate(domain0)
46print
47print "NValues"
48printExample(data0[15])
49
50
51continuizer.multinomialTreatment = continuizer.Ignore
52domain0 = continuizer(data)
53data0 = data.translate(domain0)
54print
55print "Ignore"
56printExample(data0[15])
57
58
59continuizer.multinomialTreatment = continuizer.AsOrdinal
60domain0 = continuizer(data)
61data0 = data.translate(domain0)
62print
63print "As ordinal"
64printExample(data0[15])
65
66
67continuizer.multinomialTreatment = continuizer.AsNormalizedOrdinal
68domain0 = continuizer(data)
69data0 = data.translate(domain0)
70print
71print "As normalized ordinal"
72printExample(data0[15])
73
74
Note: See TracBrowser for help on using the repository browser.