source: orange/Orange/testing/regression/tests_20/reference_subsetsgenerators.py @ 9952:986e9cd806f4

Revision 9952:986e9cd806f4, 1.4 KB checked in by Miha Stajdohar <miha.stajdohar@…>, 2 years ago (diff)

Tests moved and renamed from orange 20.

Line 
1# Description: Shows how to use classes that systematically generate subsets of attributes
2# Category:    feature subset selection, constructive induction
3# Classes:     SubsetsGenerator, SubsetsGenerator_constSize, SubsetsGenerator_minMaxSize, SubsetsGenerator_constant
4# Uses:        monk1
5# Referenced:  SubsetsGenerator.htm
6
7import orange
8
9data = orange.ExampleTable("monk1")
10
11print "\n\nAttributes by call-constructed subsets generator"
12gen1 = orange.SubsetsGenerator_constSize(data.domain.attributes, B=3)
13for attrs in gen1:
14  print attrs
15
16print "\n\nAttributes through list comprehension"
17print [ss for ss in gen1]
18
19print "\n\nSubsets by ordinary subsets generator"
20gen2 = orange.SubsetsGenerator_constSize(B=3)
21for attrs in gen2(data.domain.attributes):
22  print attrs
23
24def f(gen, data):
25  for attrs in gen(data.domain.attributes):
26    print attrs
27
28print "\n\nSubsets by pre-constructed bound set"
29gen3 = orange.SubsetsGenerator_constSize(B=3)
30f(gen3, data)
31
32print "\n\nSubsets by min-max generator"
33gen4 = orange.SubsetsGenerator_minMaxSize(min=1, max=3)
34for attrs in gen4(data.domain.attributes):
35  print attrs
36
37
38print "\n\nSubsets by constant generator"
39gen5 = orange.SubsetsGenerator_constant()
40gen5.constant = data.domain[:3]
41for attrs in gen5(data.domain.attributes):
42  print attrs
43
44print "\n\n... once more: subsets by constant generator"
45gen5 = orange.SubsetsGenerator_constant(data.domain.attributes)
46gen5.constant = data.domain[:3]
47for attrs in gen5:
48  print attrs
Note: See TracBrowser for help on using the repository browser.