source: orange/docs/reference/rst/code/classifier-from-var-example.py @ 10123:5965da1f088b

Revision 10123:5965da1f088b, 644 bytes checked in by lanumek, 2 years ago (diff)

Added ClassifierFromVar

Line 
1import Orange
2
3monks = Orange.data.Table("monks-1")
4e = monks.domain["e"]
5e1 = Orange.feature.Discrete("e1", values = ["1", "not 1"])
6
7def eTransformer(value):
8    if int(value) == 0:
9        return 0
10    else:
11        return 1
12
13e1.getValueFrom = Orange.classification.ClassifierFromVar()
14e1.getValueFrom.whichVar = e
15e1.getValueFrom.transformer = eTransformer
16
17monks2 = monks.select(["a", "b", "e", e1, "y"])
18for i in monks2:
19    print i
20
21e1.getValueFrom = Orange.classification.ClassifierFromVarFD()
22e1.getValueFrom.domain = monks.domain
23e1.getValueFrom.position = monks.domain.attributes.index(e)
24e1.getValueFrom.transformer = eTransformer
25
Note: See TracBrowser for help on using the repository browser.