source: orange/Orange/testing/regression/tests_20/reference_classifierFromVar.py @ 9952:986e9cd806f4

Revision 9952:986e9cd806f4, 895 bytes checked in by Miha Stajdohar <miha.stajdohar@…>, 2 years ago (diff)

Tests moved and renamed from orange 20.

Line 
1# Description: Shows how to use ClassifierFromVar and transformers
2# Category:    sampling
3# Classes:     ClassifierFromVar, TransformValue
4# Uses:        monk1
5# Referenced:  RandomIndices.htm
6
7import orange
8
9data = orange.ExampleTable("monk1")
10e = data.domain["e"]
11
12def eTransformer(value):
13    if int(value) == 0:
14        return 0
15    else:
16        return 1
17
18
19e1 = orange.EnumVariable("e1", values = ["1", "not 1"])
20e1.getValueFrom = orange.ClassifierFromVar()
21e1.getValueFrom.whichVar = e
22e1.getValueFrom.transformer = eTransformer
23
24data2 = data.select(["a", "b", "e", e1, "y"])
25for i in data2[:5]:
26    print i
27print
28
29
30e1.getValueFrom = orange.ClassifierFromVarFD()
31e1.getValueFrom.domain = data.domain
32e1.getValueFrom.position = data.domain.attributes.index(e)
33e1.getValueFrom.transformer = eTransformer
34
35data2 = data.select(["a", "b", "e", e1, "y"])
36for i in data2[:5]:
37    print i
38print
39
Note: See TracBrowser for help on using the repository browser.