Implicational system
[1]:
from galactic.rules import HasseDiagramOrderedBasis, CanonicalDirectBasis
from galactic.rules import RuleTable
from galactic.population import Population
from galactic.characteristics import Key
from galactic.examples.arithmetic import (
MultipleStrategy,
DivisorStrategy,
MultipleDescription,
DivisorDescription,
Integer,
)
individuals = [{"x": 48, "y": 15}, {"x": 36, "y": 3}, {"x": 64, "y": 10}]
population = Population(individuals)
strategies = [
MultipleStrategy(Integer(Key(name="x"))),
DivisorStrategy(Integer(Key(name="x"))),
MultipleStrategy(Integer(Key(name="y"))),
DivisorStrategy(Integer(Key(name="y"))),
]
descriptions = [
MultipleDescription(Integer(Key(name="x"))),
DivisorDescription(Integer(Key(name="x"))),
MultipleDescription(Integer(Key(name="y"))),
DivisorDescription(Integer(Key(name="y"))),
]
[2]:
from galactic.algebras.poset import HasseDiagram
from galactic.concepts import ConceptRenderer, ConceptLattice
lattice = ConceptLattice(population=population, descriptions=descriptions)
lattice.apply(strategies)
[3]:
HasseDiagram(lattice, domain_renderer=ConceptRenderer())
[3]:
[4]:
display(*lattice.domain)
Predicates:
M(x,4)
D(x,576)
D(y,30)
Individuals:
0
1
2
Predicates:
M(x,16)
D(x,192)
M(y,5)
D(y,30)
Individuals:
0
2
Predicates:
M(x,12)
D(x,144)
M(y,3)
D(y,15)
Individuals:
0
1
Predicates:
M(x,64)
D(x,64)
M(y,10)
D(y,10)
Individuals:
2
Predicates:
M(x,48)
D(x,48)
M(y,15)
D(y,15)
Individuals:
0
Predicates:
M(x,36)
D(x,36)
M(y,3)
D(y,3)
Individuals:
1
Predicates:
M(x,0)
D(x,1)
M(y,0)
D(y,1)
Individuals:
[5]:
RuleTable(HasseDiagramOrderedBasis(lattice=lattice), support=0.0)
[5]:
Premises |
Conclusions |
Support |
Confidence |
---|---|---|---|
|
1 |
1 |
|
|
|
1 |
1 |
|
|
0.666667 |
1 |
|
|
0.666667 |
1 |
|
|
0.666667 |
1 |
|
|
0.666667 |
1 |
|
|
0.666667 |
1 |
|
|
0.666667 |
1 |
|
|
0.666667 |
1 |
|
|
0.666667 |
1 |
|
|
0.666667 |
1 |
|
|
0.333333 |
1 |
|
|
0.333333 |
1 |
|
|
0.333333 |
1 |
|
|
0.333333 |
1 |
|
|
0.333333 |
1 |
|
|
0.333333 |
1 |
|
|
0.333333 |
1 |
|
|
0.333333 |
1 |
|
|
0.333333 |
1 |
|
|
0.333333 |
1 |
|
|
0.333333 |
1 |
[6]:
RuleTable(CanonicalDirectBasis(lattice=lattice), support=0.0)
[6]:
Premises |
Conclusions |
Support |
Confidence |
---|---|---|---|
|
1 |
1 |
|
|
|
0.666667 |
1 |
|
|
0.666667 |
1 |
|
|
0.666667 |
1 |
|
|
0.666667 |
1 |
|
|
0.666667 |
1 |
|
|
0.666667 |
1 |
|
|
0.666667 |
1 |
|
|
0.333333 |
1 |
|
|
0.333333 |
1 |
|
|
0.333333 |
1 |
|
|
0.333333 |
1 |
|
|
0.333333 |
1 |
|
|
0.333333 |
1 |
|
|
0.333333 |
1 |