Concepts

The galactic.concepts module contains several classes for exploring lattices using context:

  • Concept class is used to represent collections of objects that share a set of predicates;

  • Descriptors class is used to represent descriptors of a concept;

  • Individuals is used to represent the individuals that belong to a concept;

class galactic.concepts.Descriptors(values: Mapping[galactic.descriptions.Description, Iterable[galactic.descriptions.Predicate]] = None)

Bases: typing.Mapping, collections.abc.Callable, collections.abc.Hashable

The Descriptors class is used to represent each description by a collection of predicates.

__init__(values: Mapping[galactic.descriptions.Description, Iterable[galactic.descriptions.Predicate]] = None)

Initialise a Descriptors instance.

Keyword Arguments

values (Mapping) – A mapping from descriptions to an iterable of predicates.

Raises

TypeError – If the values argument is not an instance of Mapping.

__call__(individual) → bool

Call each predicate on the individual.

Returns

True if the individual verify all predicates.

Return type

bool

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

Get an iterator over the predicates.

Returns

Return type

Iterator[Predicate]

class galactic.concepts.Individuals(concept: Optional[galactic.concepts.Concept] = None)

Bases: typing.Mapping

The Individuals class is used to represent the individuals hold by a concept.

__init__(concept: Optional[galactic.concepts.Concept] = None)

Initialise an Individuals instance.

Parameters

concept (Concept) – The underlying concept.

Raises

TypeError – If the concept argument is not an instance of Concept.

class galactic.concepts.Concept(population: galactic.population.Population = None, descriptions: Iterable[galactic.descriptions.Description] = None)

Bases: galactic.algebras.lattice.elements.Element

The Concept class is used to represent a collection of individuals that verify an Iterable of Predicate instances.

__init__(population: galactic.population.Population = None, descriptions: Iterable[galactic.descriptions.Description] = None)

Initialise a Concept instance.

Keyword Arguments
  • population (Population) – The context population

  • descriptions (Iterable[Description]) – An iterable of Description instances.

Raises
  • TypeError – If the population is not an instance of Population.

  • TypeError – If the descriptions is not an instance of Iterable

optimize()

The optimize() method optimize a concept by only keeping a set of necessary predicates.

Returns

self for chaining

Return type

Concept

compare(other, keys: Collection = None)

Compare the concept to the other using a collection of individuals.

Returns

  • int

    • Concept.EQUAL (0b00) if the concepts are equal.

    • Concept.INF (0b01) if the concept is lesser than the other

    • Concept.SUP (0b10) if the concept is greater than the other

    • Concept.INCOMPARABLE (0b11) if the concept is not comparable to the other

  • NotImplementedType – If the comparison is not implemented

__eq__(other)

Test if this element is equal to the other.

Parameters

other (Concept) – the other element

Returns

  • boolTrue if this element is equal to the other.

  • NotImplementedType – If the comparison is not implemented

__lt__(other)

Test if this element is lesser than the other.

Parameters

other (Concept) – the other element

Returns

  • boolTrue if this element is lesser than the other.

  • NotImplementedType – If the comparison is not implemented

__le__(other)

Test if this element is lesser than or equal to the other.

Parameters

other (Concept) – the other element

Returns

  • boolTrue if this element is lesser than or equal to the other.

  • NotImplementedType – If the comparison is not implemented

__gt__(other)

Test if this element is greater than the other.

Parameters

other (Concept) – the other element

Returns

  • boolTrue if this element is greater than the other.

  • NotImplementedType – If the comparison is not implemented

__ge__(other)

Test if this element is greater than or equal to the other.

Parameters

other (Concept) – the other element

Returns

  • boolTrue if this element is greater than or equal to the other.

  • NotImplementedType – If the comparison is not implemented

is_comparable(other)

Test if this element is comparable to the other.

Parameters

other (Concept) – the other element

Returns

  • boolTrue if this element is either:

    • lesser than or equal to the other;

    • greater than or equal to the other.

    False otherwise.

  • NotImplementedType – If the comparison is not implemented

__and__(other)

Return the meet of this element and the other.

Parameters

other (Concept) – the other element

Returns

  • Concept – the meet of this element and the other

  • NotImplementedTypeNotImplemented if the other concept is either not a concept or either not constructed with the same population.

__or__(other)

Return the join of this element and the other.

Parameters

other (Concept) – the other element

Returns

  • Concept – the join of this element and the other

  • NotImplementedTypeNotImplemented if the other concept is either not a concept or either not constructed with the same population.

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

Get the predicates.

Returns

The predicates.

Return type

Iterator[Predicate]

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

Get the selectors.

Returns

The selectors.

Return type

Iterator[Predicate]

descriptors() → galactic.concepts.Descriptors

Get the descriptors.

Returns

The descriptors.

Return type

Descriptors

individuals() → galactic.concepts.Individuals

Get the individuals.

Returns

The individuals.

Return type

Individuals

population() → galactic.population.Population

Get the population.

Returns

The population.

Return type

Population

property support

Get the concept support.

Returns

The concept support.

Return type

float