Subsets generators are classes that generate subsets of a given set of attributes. Their primary mission was to generate bound sets for function decomposition, although they can also be used for other purposes.
is an abstract class that defines the behaviour of derived classes.
Let sgen
be a generator that constructs pair of attributes from domain Monk 1 (the section below describes how to create such generator). You can use it in for sentences
or in list comprehensions
There is another way of using subset generators. You can reset generator by calling reset
and get a sequence of attribute subsets by calling next
until it returns None
. This is provided for compatibility with older versions of Orange and describe here for easier understanding of old code. Don't use it.
Before iterating through subsets, the generator needs to be given a set of attributes. You can specify the set at construction time, set it through varList
attribute, or specify it at for-clause. So, to construct the above generator, one can write
or
The third, somewhat ugly alternative, is providing the attribute set at call time.
def __call__(self, v): self.varList = v; return self
. Why is this dirt here at all? For compatibility with some stuff originating from before Python had the iterator protocol. And because it can come handy.
returns subsets of predefined size.
Attributes
Here is an example
part of subsetsgenerators.py (uses monk1.tab)
Output begins by
More often, however, the generator will be constructed in advance and then used to construct subsets of some given attribute set.
part of subsetsgenerators.py (uses monk1.tab)
returns subsets of sizes within given limits. Subsets are sorted by increasing cardinality.
Attributes
part of subsetsgenerators.py (uses monk1.tab)
The output begins by:
"generates" a single subset, prescribed by the user.
Attributes
The code below will always return a subset containing the first three attributes.
part of subsetsgenerators.py (uses monk1.tab)
Why the hell would you need such a generator? There are object that require a subsets generator as a component. In function decomposition, for instance, subsets generators are used to construct a list of candidate subsets. This is a way to force them into observing a single prescribed subset.
This is the most complex subsets generator. It uses a generator - one of the above generators - stored in a field subGenerator
to generate subsets, but it filters out all the subsets that do not comply to restrictions.
Attributes