Strategies¶
The galactic.strategies
module defines
the
galactic.strategies.Strategy
class which is the super-class of all strategies classes;the
galactic.strategies.Strategies
class for representing list of strategies;the
galactic.strategies.BasicStrategy
class which must be inherited to implement a new strategy;the
galactic.strategies.AbsurdStrategy
class which generates no predecessors;the
galactic.strategies.MetaStrategy
class which is the base class for all the meta strategies (strategies that use other strategies);the
galactic.strategies.LimitFilter
class which is the a meta strategy which limits the predecessors using a threshold measure;the
galactic.strategies.SelectionFilter
class which is the a meta strategy which keeps the predecessors having the best (or the worst) measure;the
galactic.strategies.Measure
class which is the base class for all measures. A measure can be called on a set of individuals and must a return a comparable value;the
galactic.strategies.Cardinality
which measures the cardinality of a concept;the
galactic.strategies.PredecessorCardinality
which measures the cardinality of the predecessor;the
galactic.strategies.Support
which measures the support of an concept;the
galactic.strategies.PredecessorSupport
which measures the support of the predecessor;the
galactic.strategies.Confidence
which measures the ratio between the confidence of a concept.
-
class
galactic.strategies.
Strategy
¶ Bases:
collections.abc.Hashable
The
Strategy
class produces, for a collection of individuals, a collection of candidate predicates.-
descriptions
¶ An iterator over the description spaces linked to this strategy.
-
selection
(concept: galactic.concepts.Concept) → Iterator[galactic.descriptions.Predicate]¶ Compute an iterator over the selectors of a collection of individuals.
- Parameters
individuals (
Collection
) – A collection of individuals.- Returns
An iterator over a collection of selectors.
- Return type
-
abstract
selectors
(concept: galactic.concepts.Concept) → Iterator[galactic.descriptions.Predicate]¶ The
selectors()
method must return an iterator or selectors.- Parameters
concept (
Concept
) – The concept whose selectors are requested.- Returns
- Return type
-
abstract
descriptions
() → Iterator[galactic.descriptions.Description] Get an iterator over the descriptions.
- Returns
- Return type
-
-
class
galactic.strategies.
Strategies
¶ Bases:
typing.List
pass
-
classmethod
from_file
(file: io.TextIOBase) → galactic.strategies.Strategies¶ Create a list of strategies from a readable opened file.
- Keyword Arguments
file (
TextIOBase
) – File to read- Returns
A new list of strategies
- Return type
-
classmethod
-
class
galactic.strategies.
BasicStrategy
¶ Bases:
galactic.strategies.Strategy
The
BasicStrategy
class is used for classical strategies. This class is designed for sub-classing. Sub-classes must set the_description
slot in their constructor.-
descriptions
¶ An iterator over the description spaces linked to this strategy. This iterator iterate over one value.
-
description
¶ The description owned by this strategy.
- Type
Description
-
space
¶ The description space of this strategy. This is a proxy to
self.description.space
.- Type
Tuple[Characteristic]
-
descriptions
() → Iterator[galactic.descriptions.Description] Get an iterator over the descriptions.
- Returns
- Return type
-
abstract
selectors
(concept: galactic.concepts.Concept) → Iterator[galactic.descriptions.Predicate]¶ The
selectors()
method must return an iterator or selectors.- Parameters
concept (
Concept
) – The concept whose selectors are requested.- Returns
- Return type
-
-
class
galactic.strategies.
AbsurdStrategy
(*args)¶ Bases:
galactic.strategies.Strategy
The
AbsurdStrategy
has been designed to describe individuals using predicates that must not be used for producing concepts.-
__init__
(*args)¶ Initialize an
AbsurdStrategy
instance.- Keyword Arguments
*args (
Collection[Description]
) – A collection of description spaces
-
selectors
(concept: galactic.concepts.Concept) → Iterator[galactic.descriptions.Predicate]¶ The
selectors()
method must return an iterator or selectors.- Parameters
concept (
Concept
) – The concept whose selectors are requested.- Returns
- Return type
-
descriptions
() → Iterator[galactic.descriptions.Description]¶ Get an iterator over the descriptions.
- Returns
- Return type
-
-
class
galactic.strategies.
MetaStrategy
(*args)¶ Bases:
galactic.strategies.Strategy
The
MetaStrategy
class is used for strategy that own their proper inner strategies.-
descriptions
¶ An iterator over the description spaces linked to this strategy.
-
strategies
¶ The tuple of strategies owned by this meta-strategy.
- Type
Tuple[Strategy]
-
__init__
(*args)¶ Initialise a
MetaStrategy
instance.
-
descriptions
() → Iterator[galactic.descriptions.Description] Get an iterator over the descriptions.
- Returns
- Return type
-
selectors
(concept: galactic.concepts.Concept) → Iterator[galactic.descriptions.Predicate]¶ The
selectors()
method must return an iterator or selectors.- Parameters
concept (
Concept
) – The concept whose selectors are requested.- Returns
- Return type
-
-
class
galactic.strategies.
Measure
¶ Bases:
collections.abc.Callable
The
Measure
class is an abstract class. Its subclasses must implement the__call__()
method.-
abstract
__call__
(concept: galactic.concepts.Concept, predicate: galactic.descriptions.Predicate = None) → float¶ The
__call__()
method evaluate the individuals present in the concept whose call to predicate is true.- Parameters
concept (
Concept
) – The concept for which individuals will be tested.- Keyword Arguments
predicate (
Predicate
) – The predicate to be tested.- Returns
The computed measure.
- Return type
-
abstract
-
class
galactic.strategies.
Filter
(*args, measure: galactic.strategies.Measure = None, **kwargs)¶ Bases:
galactic.strategies.MetaStrategy
The
Filter
class is a meta-strategy whose goal is to filter possible predecessor using a measure on the concept and its predecessor.
-
class
galactic.strategies.
LimitFilter
(*args, limit: SupportsFloat = 0.0, strict: bool = False, lower: bool = True, **kwargs)¶ Bases:
galactic.strategies.Filter
The
LimitFilter
class limits the possible predecessors by choosing those whose measure is greater (or less than a threshold).-
__init__
(*args, limit: SupportsFloat = 0.0, strict: bool = False, lower: bool = True, **kwargs)¶ Initialize a
LimitFilter
class.- Keyword Arguments
limit (
SupportsFloat
) – The limit valuestrict (
bool
) – Is the limit strict?lower (
bool
) – Is it a lower limit?
-
selectors
(concept: galactic.concepts.Concept) → Iterator[galactic.descriptions.Predicate]¶ The
selectors()
method must return an iterator or selectors.- Parameters
concept (
Concept
) – The concept whose selectors are requested.- Returns
- Return type
-
-
class
galactic.strategies.
SelectionFilter
(*args, keep: SupportsInt = 1, maximize: bool = True, decrease: bool = True, strict: bool = False, rate: SupportsFloat = 1.0, **kwargs)¶ Bases:
galactic.strategies.Filter
The
SelectionFilter
class limits the possible predecessors by choosing those whose measure is among the greatest (or smallest).- Keyword Arguments
keep (
SupportsInt
) – The number of group having the same value kept by this strategymaximize (
bool
) – Does this measure keep the maximum or the minimum predecessors?decrease (
bool
) – Does this strategy have to decrease the measure value between a concept and its predecessors.strict (
bool
) – Is the comparison strict between the concept and its predecessors.rate (:
SupportsFloat
) – The rate applied to the concept measure that the predecessors have to be lesser or greater than.
-
selectors
(concept: galactic.concepts.Concept) → Iterator[galactic.descriptions.Predicate]¶ The
selectors()
method must return an iterator or selectors.- Parameters
concept (
Concept
) – The concept whose selectors are requested.- Returns
- Return type
-
class
galactic.strategies.
Cardinality
¶ Bases:
galactic.strategies.Measure
The
Cardinality
class computes the cardinality of the predecessor.
-
class
galactic.strategies.
Support
¶ Bases:
galactic.strategies.Measure
The
Support
class computes the support of the predecessor.
-
class
galactic.strategies.
PredecessorCardinality
¶ Bases:
galactic.strategies.Measure
The
PredecessorCardinality
class computes the cardinality of the predecessor.
-
class
galactic.strategies.
PredecessorSupport
¶ Bases:
galactic.strategies.Measure
The
PredecessorSupport
class computes the support of the predecessor.
-
class
galactic.strategies.
Confidence
¶ Bases:
galactic.strategies.Measure
The
Confidence
class computes the cardinality ratio between the predecessor and the successor.