source: orange/orange/doc/Orange/rst/code/lookup-table.py @ 7763:bc3b43d45a45

Revision 7763:bc3b43d45a45, 1.1 KB checked in by lanz <lan.zagar@…>, 3 years ago (diff)

Updated code example.

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.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.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.sorted_examples[: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.sorted_examples:
35    print i, i.getclass().svalue
Note: See TracBrowser for help on using the repository browser.