Strategies

The galactic.strategies module defines

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.

Type

Iterator[Description]

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

Iterator[Predicate]

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

Iterator[Predicate]

abstract descriptions() → Iterator[galactic.descriptions.Description]

Get an iterator over the descriptions.

Returns

Return type

Iterator[Description]

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

Strategies

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.

Type

Iterator[Description]

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

Iterator[Description]

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

Iterator[Predicate]

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

Iterator[Predicate]

descriptions() → Iterator[galactic.descriptions.Description]

Get an iterator over the descriptions.

Returns

Return type

Iterator[Description]

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.

Type

Iterator[Description]

strategies

The tuple of strategies owned by this meta-strategy.

Type

Tuple[Strategy]

__init__(*args)

Initialise a MetaStrategy instance.

Raises

TypeError – If an argument is not an instance of Strategy

descriptions() → Iterator[galactic.descriptions.Description]

Get an iterator over the descriptions.

Returns

Return type

Iterator[Description]

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

Iterator[Predicate]

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

float

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 value

  • strict (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

Iterator[Predicate]

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 strategy

  • maximize (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

Iterator[Predicate]

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.

galactic.strategies.get_classes()

Get all classes defined in this module.

Returns

dict – A mapping from names to classes.

Return type

dict