source: orange/orange/doc/Orange/rst/code/lookup-table.py @ 7660:5f432be7cddc

Revision 7660:5f432be7cddc, 1.1 KB checked in by janezd <janez.demsar@…>, 3 years ago (diff)

Renamed Orange.data.feature to Orange.data.variable

Line 
1# Description: Shows how to construct an orange.ClassifierFromExampleTable
2# Category:    classification, lookup classifiers, constructive induction, feature construction
3# Classes:     ClassifierByExampleTable, LookupLearner
4# Uses:        monk1
5# Referenced:  lookup.htm
6
7import Orange
8
9table = Orange.data.Table("monks-1")
10a, b, e = table.domain["a"], table.domain["b"], table.domain["e"]
11
12table_s = table.select([a, b, e, table.domain.classVar])
13abe = Orange.classification.lookup.LookupLearner(table_s)
14
15print len(table_s)
16print len(abe.sortedExamples)
17
18for i in abe.sortedExamples[:10]:
19    print i
20print
21
22for i in abe.sortedExamples[:10]:
23    print i, i.getclass().svalue
24print
25
26y2 = Orange.data.variable.Discrete("y2", values = ["0", "1"])
27abe2 = Orange.classification.lookup.LookupLearner(y2, [a, b, e], table)
28for i in abe2.sortedExamples[:10]:
29    print i, i.getclass().svalue
30print
31
32y2 = Orange.data.variable.Discrete("y2", values = ["0", "1"])
33abe2 = Orange.classification.lookup.LookupLearner(y2, [a, b], table)
34for i in abe2.sortedExamples:
35    print i, i.getclass().svalue
Note: See TracBrowser for help on using the repository browser.