source: orange/docs/reference/rst/code/lookup-table.py @ 9927:d6ca7b346864

Revision 9927:d6ca7b346864, 1.1 KB checked in by markotoplak, 2 years ago (diff)

data.variable -> feature.

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.class_var])
13abe = Orange.classification.lookup.LookupLearner(table_s)
14
15print len(table_s)
16print len(abe.sorted_examples)
17
18for i in abe.sorted_examples[:10]:
19    print i
20print
21
22for i in abe.sorted_examples[:10]:
23    print i, i.get_class().svalue
24print
25
26y2 = Orange.feature.Discrete("y2", values = ["0", "1"])
27abe2 = Orange.classification.lookup.LookupLearner(y2, [a, b, e], table)
28for i in abe2.sorted_examples[:10]:
29    print i, i.get_class().svalue
30print
31
32y2 = Orange.feature.Discrete("y2", values = ["0", "1"])
33abe2 = Orange.classification.lookup.LookupLearner(y2, [a, b], table)
34for i in abe2.sorted_examples:
35    print i, i.get_class().svalue
Note: See TracBrowser for help on using the repository browser.