galactic.algebras.convex.measures.core#
galactic.algebras.convex.measures.core module
Defines core measures in convex algebras.
Measure: Base class for measures in convex algebrasSupport: Measure the support of a conceptNormalisedSupport: Measure the normalised support of a conceptRelativeSupport: Measure the relative support of a concept
- class Measure(**data)#
Bases:
Resource,ABCMeasure the quality of the concept relatively to its super-concept.
- abstractmethod __call__(pred, succ)#
Measure the quality of the concept pred relative to succ.
- Parameters:
- Returns:
The measure of the quality of pred relative to succ
- Return type:
Notes
The measure should be negative when the concept cannot be retained, and should be zero when pred is a very poor concept.
- class Support(**data)#
Bases:
MeasureMeasure the support of a concept.
The support of a concept is the cardinality of its extent. It measures how many items are described by the concept.
Examples
>>> from galactic.algebras.concept.core import ItemUniverse >>> from galactic.algebras.convex.characteristics.core import Integer, Component >>> from galactic.algebras.convex.descriptions.core import ( ... PredicateUniverse, ... Context, ... GaloisConnection, ... Concept, ... ) >>> from galactic.algebras.convex.descriptions.examples.arithmetic.core import ( ... DivisorDescription, ... MultipleDescription, ... ) >>> from galactic.algebras.convex.measures.core import Support >>> from galactic.algebras.convex.strategies.core import NaiveStrategy >>> characteristic = Integer(components=(Component(),)) >>> descriptions = ( ... DivisorDescription(space=(characteristic,)), ... MultipleDescription(space=(characteristic,)), ... ) >>> dataset = [36, 48, 16, 32] >>> domain = ItemUniverse(dataset) >>> co_domain = PredicateUniverse(descriptions=descriptions) >>> context = Context(domain, co_domain) >>> connection = GaloisConnection(context) >>> top = Concept(connection) >>> strategy = NaiveStrategy(descriptions=descriptions) >>> concepts = list(strategy(top)) >>> support = Support() >>> [support(sub, top) for sub in concepts] [3.0, 3.0]
Configuration
If you want to specify a support measure in a TOML file, you can use the following syntax:
[measures.my_measure] "$type" = "core.measure.Support"
Notes
In this measure, the
succargument is not used.- __call__(pred, succ)#
Measure the support of a concept.
The support of a concept is the cardinality of its extent.
- class NormalisedSupport(**data)#
Bases:
MeasureMeasure the normalised support of the concept pred.
- ALIAS#
The alias of the type in the resource registry.
- Type:
ClassVar[str] = “core.measure.NormalisedSupport”
Examples
>>> from galactic.algebras.concept.core import ItemUniverse >>> from galactic.algebras.convex.characteristics.core import Integer, Component >>> from galactic.algebras.convex.descriptions.core import ( ... PredicateUniverse, ... Context, ... GaloisConnection, ... Concept, ... ) >>> from galactic.algebras.convex.descriptions.examples.arithmetic.core import ( ... DivisorDescription, ... MultipleDescription, ... ) >>> from galactic.algebras.convex.measures.core import NormalisedSupport >>> from galactic.algebras.convex.strategies.core import NaiveStrategy >>> characteristic = Integer(components=(Component(),)) >>> descriptions = ( ... DivisorDescription(space=(characteristic,)), ... MultipleDescription(space=(characteristic,)), ... ) >>> dataset = [36, 48, 16, 32] >>> domain = ItemUniverse(dataset) >>> co_domain = PredicateUniverse(descriptions=descriptions) >>> context = Context(domain, co_domain) >>> connection = GaloisConnection(context) >>> top = Concept(connection) >>> strategy = NaiveStrategy(descriptions=descriptions) >>> concepts = list(strategy(top)) >>> support = NormalisedSupport() >>> [support(sub, top) for sub in concepts] [0.75, 0.75]
Configuration
If you want to specify a normalised support measure in a TOML file, you can use the following syntax:
[measures.my_measure] "$type" = "core.measure.NormalisedSupport"
Notes
In this measure, the
succargument is not used.- __call__(pred, succ)#
Measure the normalised support of the concept pred.
- class RelativeSupport(**data)#
Bases:
MeasureMeasure the relative support of the concept pred relatively to succ.
- ALIAS#
The alias of the type in the resource registry.
- Type:
ClassVar[str] = “core.measure.RelativeSupport”
Examples
>>> from galactic.algebras.concept.core import ItemUniverse >>> from galactic.algebras.convex.characteristics.core import Integer, Component >>> from galactic.algebras.convex.descriptions.core import ( ... PredicateUniverse, ... Context, ... GaloisConnection, ... Concept, ... ) >>> from galactic.algebras.convex.descriptions.examples.arithmetic.core import ( ... DivisorDescription, ... MultipleDescription, ... ) >>> from galactic.algebras.convex.measures.core import NormalisedSupport >>> from galactic.algebras.convex.strategies.core import NaiveStrategy >>> characteristic = Integer(components=(Component(),)) >>> descriptions = ( ... DivisorDescription(space=(characteristic,)), ... MultipleDescription(space=(characteristic,)), ... ) >>> dataset = [36, 48, 16, 32] >>> domain = ItemUniverse(dataset) >>> co_domain = PredicateUniverse(descriptions=descriptions) >>> context = Context(domain, co_domain) >>> connection = GaloisConnection(context) >>> top = Concept(connection) >>> strategy = NaiveStrategy(descriptions=descriptions) >>> concepts = list(strategy(top)) >>> support = RelativeSupport() >>> [support(sub, top) for sub in concepts] [0.75, 0.75]
Configuration
If you want to specify a relative support measure in a TOML file, you can use the following syntax:
[measures.my_measure] "$type" = "core.measure.RelativeSupport"
Notes
In this measure, the
succargument is not used.- __call__(pred, succ)#
Measure the relative support of the concept pred relatively to succ.