📘 Formal convex concepts#
Formal convex concepts are the building blocks of formal concept analysis (FCA),
representing the relationships between a set of items and their patterns.
In the GALACTIC framework, formal convex concepts are implemented using the
Concept class of the
galactic.algebras.convex.descriptions.core module, which allows for the creation,
manipulation, and analysis of these concepts within a given antitone Galois connection.
Creating convex concepts#
The constructor of the Concept
class takes an instance of the
GaloisConnection class as input,
which defines the context in which the concepts are formed and optionally an iterable
of items or attributes to initialise the concept. When neither items nor attributes
are provided, the concept is initialised as the top concept (with full extent and
smallest intent).
from galactic.algebras.concept.core import ItemUniverse
from galactic.algebras.convex.characteristics.core import Component, Integer
from galactic.algebras.convex.descriptions.core import (
Concept,
Context,
GaloisConnection,
PredicateUniverse,
)
from galactic.algebras.convex.descriptions.examples.arithmetic.core import (
MultipleDescription,
)
characteristic = Integer(components=(Component(),))
description = MultipleDescription(space=(characteristic,))
dataset = [36, 48, 16, 32]
domain = ItemUniverse(dataset)
co_domain = PredicateUniverse(description)
context = Context(domain, co_domain)
connection = GaloisConnection(context)
top = Concept(connection)
top
bottom = Concept(connection, items=[])
bottom
<galactic.algebras.convex.descriptions.core.Concept object at 0x7182191bc690>
The extent and intent of the concept can be accessed using the
extent and
intent attributes,
respectively. They are closed sets of items and attributes within the context of the
antitone Galois connection.
<galactic.algebras.convex.descriptions.core.Extent object at 0x71821919c540>
[Item(key=0, value=36),
Item(key=1, value=48),
Item(key=2, value=16),
Item(key=3, value=32)]
<galactic.algebras.convex.descriptions.core.Intent object at 0x71821919cb80>
['M(int(@),4)']
<galactic.algebras.convex.descriptions.core.Extent object at 0x7182191b63c0>
[]
<galactic.algebras.convex.descriptions.core.Intent object at 0x7182191b41c0>
['⊥']
Operating on concepts#
The Concept class implements the
Element protocol of the
galactic.algebras.lattice.core module, which
also provides methods to create concepts using the join (\(\vee\)) or
meet (\(\wedge\)) operators.
concept_1 = Concept(
connection,
items=[context.domain[1], context.domain[2]],
)
concept_2 = Concept(
connection,
items=[context.domain[0]],
)
join = concept_1 | concept_2
meet = concept_1 & concept_2
display(concept_1.extent, list(concept_1.extent))
display(concept_1.intent, [str(attr) for attr in concept_1.intent])
display(concept_2.extent, list(concept_2.extent))
display(concept_2.intent, [str(attr) for attr in concept_2.intent])
display(concept_2.intent, [str(attr) for attr in concept_2.intent.convexes[0]])
display(meet.extent, list(meet.extent))
display(meet.intent, [str(attr) for attr in meet.intent])
display(join.extent, list(join.extent))
display(join.intent, [str(attr) for attr in join.intent])
display(meet <= join, meet.extent <= join.extent, meet.intent >= join.intent)
<galactic.algebras.convex.descriptions.core.Extent object at 0x7182191d9d00>
[Item(key=1, value=48), Item(key=2, value=16), Item(key=3, value=32)]
<galactic.algebras.convex.descriptions.core.Intent object at 0x7182191d6440>
['M(int(@),16)']
<galactic.algebras.convex.descriptions.core.Extent object at 0x7182191b6140>
[Item(key=0, value=36)]
<galactic.algebras.convex.descriptions.core.Intent object at 0x7182191d7ec0>
['M(int(@),4)', 'M(int(@),9)']
<galactic.algebras.convex.descriptions.core.Intent object at 0x7182191d7ec0>
['M(int(@),4)', 'M(int(@),9)']
<galactic.algebras.convex.descriptions.core.Extent object at 0x7182191de840>
[]
<galactic.algebras.convex.descriptions.core.Intent object at 0x7182191ded40>
['⊥']
<galactic.algebras.convex.descriptions.core.Extent object at 0x7182191b6240>
[Item(key=0, value=36),
Item(key=1, value=48),
Item(key=2, value=16),
Item(key=3, value=32)]
<galactic.algebras.convex.descriptions.core.Intent object at 0x7182191de200>
['M(int(@),4)']
True
True
True