Rules

The galactic.rules module implements basic classes for dealing with basis of rules:

  • Rule basic class for representing implications;

class galactic.rules.Rule(premises: Collection[galactic.descriptions.Predicate], conclusions: Collection[galactic.descriptions.Predicate], support: SupportsFloat = 1.0, confidence: SupportsFloat = 1.0)

Bases: object

The Rule class is used to implement an implication between premises and conclusions.

The support of a rule A -> B is equal to the number of objects that match the rule divided by the total number of objects.

The confidence of a rule A -> B is equal to the support of A union B divided by the support of A.

premises() → Iterator[galactic.descriptions.Predicate]

Get an iterator over the premises.

Returns

An iterator over the premises.

Return type

Iterator[Predicate]

conclusions() → Iterator[galactic.descriptions.Predicate]

Get an iterator over the conclusions.

Returns

An iterator over the conclusions.

Return type

Iterator[Predicate]

class galactic.rules.Basis

Bases: typing.Collection, abc.ABC

The Basis class is the root of all implicational basis classes.

filter(support: Optional[SupportsFloat] = None, confidence: Optional[SupportsFloat] = None) → Iterator[galactic.rules.Rule]

Get the rules with a minimum support and minimum confidence.

Keyword Arguments
Returns

An iterator over the rules.

Return type

Iterator[Rule]

class galactic.rules.BasicBasis(rules: Collection[galactic.rules.Rule])

Bases: galactic.rules.Basis

The BasicBasis class is used to construct implicational basis from a collection of rules.

class galactic.rules.ConceptPredicate(*args, identifier: str, successors: Optional[Collection[galactic.descriptions.Predicate]] = None, **kwargs)

Bases: galactic.descriptions.Predicate

The ConceptPredicate class is used to represent the predicate associated to each concept.

successors() → Iterator[galactic.descriptions.Predicate]

Get an iterator over the successors.

Returns

An iterator over the successor predicates

Return type

Iterator[Predicate]

abstract generators() → Iterator[galactic.OrderedSet]

Get the generators for this predicate concept.

Returns

Get an iterator over the minimal generators.

Return type

Iterator[OrderedSet[Predicate]]

class galactic.rules.MeetPredicate(*args, identifier: str, successors: Optional[Collection[galactic.descriptions.Predicate]] = None, **kwargs)

Bases: galactic.rules.ConceptPredicate

The MeetPredicate class is used to define a predicate for each meet concept. The truth value is True when at least 2 successors are true.

generators() → Iterator[galactic.OrderedSet]

Get the generators for this predicate concept.

Returns

Get an iterator over the minimal generators.

Return type

Iterator[OrderedSet[Predicate]]

class galactic.rules.IrreduciblePredicate(*args, predicates: Optional[Collection[galactic.descriptions.Predicate]] = None, **kwargs)

Bases: galactic.rules.ConceptPredicate

The IrreduciblePredicate class is used to define a predicate for each meet irreducible concept.

predicates() → Iterator[galactic.descriptions.Predicate]

Get an iterator over the predicates

Returns

An iterator over the predicates.

Return type

Iterator[Predicate]

generators() → Iterator[galactic.OrderedSet]

Get the generators for this predicate concept.

Returns

Get an iterator over the minimal generators.

Return type

Iterator[OrderedSet[Predicate]]

class galactic.rules.GeneratedBasis(*args, lattice: galactic.concepts.lattice.Lattice, prefix: str = '$', **kwargs)

Bases: galactic.rules.Basis

The GeneratedBasis is the super class of all basis generated from a concept lattice.

filter(support: Optional[SupportsFloat] = None, confidence: Optional[SupportsFloat] = None) → Iterator[galactic.rules.Rule]

Get the rules with a minimum support and minimum confidence.

Keyword Arguments
Returns

An iterator over the rules.

Return type

Iterator[Rule]

class galactic.rules.HasseDiagramOrderedBasis(*args, lattice: galactic.concepts.lattice.Lattice, prefix: str = '$', **kwargs)

Bases: galactic.rules.GeneratedBasis

The HasseDiagramOrderedBasis class is used to construct implicational basis from a concept lattice using the links from the Hasse diagram.

class galactic.rules.CanonicalDirectBasis(*args, lattice: galactic.concepts.lattice.Lattice, prefix: str = '$', **kwargs)

Bases: galactic.rules.GeneratedBasis

The CanonicalDirectBasis is used to manage the canonical direct basis.

class galactic.rules.SimplifiedBasis(basis: galactic.rules.Basis, reduction: bool = False, generalization: bool = False, composition: bool = False)

Bases: galactic.rules.BasicBasis

The SimplifiedBasis class is used to manage simplified basis of rules using axioms from Malaga’s team.

class galactic.rules.Table(basis: galactic.rules.Basis, **options)

Bases: object

The Table class is used to represent lattice in jupyter notebooks.

__init__(basis: galactic.rules.Basis, **options)

Initialize a Table class.

Parameters
  • basis (Basis) – The implicational basis whose table representation is requested

  • options (dict <python.dict>`) –

    A collection of options

    • premise_width the premise width

    • conclusion_width the conclusion width

    • support_width the support width

    • confidence_width the confidence width

    • support the minimal support

    • confidence the minimal confidence

    The values of the given widths are compared with each other to allocate relative column sizes.

galactic.rules.register_classes()

Register all classes defined in this module.