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

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

Tests moved and renamed from orange 20.

Line
1# Description: Shows how to construct and use classifiers by lookup table to construct new features from the existing
2# Category:    classification, lookup classifiers, constructive induction, feature construction
3# Classes:     ClassifierByLookupTable, ClassifierByLookupTable1, ClassifierByLookupTable2, ClassifierByLookupTable3
4# Uses:        monk1
5# Referenced:  lookup.htm
6
7import orange
8
9data = orange.ExampleTable("monk1")
10
11a, b, e = data.domain["a"], data.domain["b"], data.domain["e"]
12
13ab = orange.EnumVariable("a==b", values = ["no", "yes"])
14ab.getValueFrom = orange.ClassifierByLookupTable(ab, a, b, ["yes", "no", "no",  "no", "yes", "no",  "no", "no", "yes"])
15
16e1 = orange.EnumVariable("e==1", values = ["no", "yes"])
17e1.getValueFrom = orange.ClassifierByLookupTable(e1, e, ["yes", "no", "no", "no", "?"])
18
19data2 = data.select([a, b, ab, e, e1, data.domain.classVar])
20
21for i in range(5):
22    print data2.randomexample()
23
24for i in range(5):
25    ex = data.randomexample()
26    print "%s: ab %i, e1 %i " % (ex, ab.getValueFrom.getindex(ex), e1.getValueFrom.getindex(ex))
27
28# What follows is only for testing Orange...
29
30ab_c = ab.getValueFrom
31print ab_c.variable1.name, ab_c.variable2.name, ab_c.classVar.name
32print ab_c.noOfValues1, ab_c.noOfValues2
33print [x.name for x in ab_c.variables]
34
35e1_c = e1.getValueFrom
36print e1_c.variable1.name, e1_c.classVar.name
37print [x.name for x in e1_c.variables]
Note: See TracBrowser for help on using the repository browser.