Library Presentation

Galactic library contains tools for formal concept analysis. The main tool we will present here is the construction of a lattice from the data introduced by the user.

The library needs two files to work with. A data file contains the set of objects with their characteristics, and an explorer file, contains basicly which characteristics to take into count in the generation of lattice, it can also contain further information such as maximum or minimum objects in each node of the lattice.

The data file can be in two formats, yaml or csv format, the explorer file must be in yaml format.

The library takes the data file and construct the population.

Population

The Population class is used to handle collection of individuals with their characteristics, it’s the data that the library use to produce the lattice.

It used the id python function to manage the uniqueness of individuals.

Example

>>> from galactic.population import Population
>>> data = [{"x": 1}, {}, {"x": 1}]
>>> population = Population(data)
>>> len(population)
3
>>> list(population)
[{'x': 1}, {}, {'x': 1}]
>>> "0" in population
True
>>> "2" in population
False
>>> population.key(data[0])
"0"
>>> data = {"i1": {"x": 1}, "i2": {}, "i3": {"x": 1}}
>>> population = Population(data)
>>> len(population)
3
>>> list(population)
["i1", "i2", "i3"]
>>> "i1" in population
True
>>> population.key(data["i1"])
'i1'

Individuals has characteristics, that’s why there is a module for handling characteristics of different type.

Characteristics

Characteristics is a module defines essential classes for representing characteristics.

A characteristic can be called on an individual. It returns a data of this individual. There is a special case of characteristic called predicates that return a boolean value.

Characteristics module handle many type of characteristics, Valued for data characteristics, Named for named characteristics, Key for characteristics whose calls to an individual will be retrieved by a key access, Property for characteristics whose calls to an individual will be retrieved by a property access, Member for characteristics whose calls to an individual will be retrieved by a membership test access and other type detailled in the characteristics reference.

Strategies

The explorer file defines strategies used in the analysis.

The strategies module produces, for a collection of individuals, a collection of candidate predicates.

We will use the Boolean case in this first part.

The Boolean strategy is the classical exploration strategy used in formal concept analysis. A call to the strategy generates 0 or 1 predicate depending on the number of individuals checking the predicate (0 if all individuals check the predicate).

Example

>>> from galactic.strategies.logical import Boolean
>>> from galactic.characteristics import Key
>>> strategy = Boolean(Key(name="x"))
>>> [str(p) for p in strategy([{"x": 1}, {"x": 0}, {"x": 1}])]
['x']
>>> [str(p) for p in
strategy.description([{"x": 1}, {"x": 0}, {"x": 1}])]
[]
>>> [str(p) for p in strategy.description([{"x": 1}, {"x": 0}])]
[]
>>> [str(p) for p in strategy.description([{"x": 1}])]
['x']
>>> [str(p) for p in strategy.description([{"x": 1}, {}])]
[]
>>>

There is other types of strategy, that will be discussed in further releases.

Descriptions

The description module defines the abstract Description class used to represent description spaces.

Concepts

The concepts module contains several classes for exploring lattice using context.

Concept class used to represent collections of objects that share a set of predicates.