source: orange/Orange/doc/reference/unusedValues.py @ 9671:a7b056375472

Revision 9671:a7b056375472, 1.1 KB checked in by anze <anze.staric@…>, 2 years ago (diff)

Moved orange to Orange (part 2)

Line 
1import orange
2data = orange.ExampleTable("unusedValues")
3
4newattrs = [orange.RemoveUnusedValues(attr, data) for attr in data.domain.variables]
5
6print
7for attr in range(len(data.domain)):
8    print data.domain[attr],
9    if newattrs[attr] == data.domain[attr]:
10        print "retained as is"
11    elif newattrs[attr]:
12        print "reduced, new values are", newattrs[attr].values
13    else:
14        print "removed"
15
16filteredattrs = filter(bool, newattrs)
17newdata = orange.ExampleTable(orange.Domain(filteredattrs), data)
18
19print "\nOriginal example table"
20for ex in data:
21    print ex
22
23print "\nReduced example table"
24for ex in newdata:
25    print ex
26
27
28print "\nRemoval with 'removedOneValued=true'"
29reducer = orange.RemoveUnusedValues(removeOneValued = 1)
30newattrs = [reducer(attr, data) for attr in data.domain.variables]
31
32print
33for attr in range(len(data.domain)):
34    print data.domain[attr],
35    if newattrs[attr] == data.domain[attr]:
36        print "retained as is"
37    elif newattrs[attr]:
38        print "reduced, new values are", newattrs[attr].values
39    else:
40        print "removed"
41
Note: See TracBrowser for help on using the repository browser.