FCA basic algorithms
Project description
FCA algorithms
This is a module providing a set of commonly used algorithms in FCA, RCA, and some of its variants. Its general intention is to provide an easy to use API so that it's easier to create other programs using these algorithms. The main algorithm that calculates formal concepts is inclose
, and, in this version, it is implemented in C++. Considering this, the API is expected to behave somewhat acceptably.
CLI
FCA
Plot a hasse diagram from a context
fca_cli -c input.csv --show_hasse
The context is expected to be a csv
with the following format
name | attr1 | attr2 |
---|---|---|
obj1 | x | |
obj2 | x | |
obj3 | x | x |
obj4 |
Output files
fca_cli -c input.csv --show_hasse --output_dir path/to/folder/
Will create two files, one representing the hasse graph, the other one with a concept for each line. The line is the index in the hasse graph.
RCA
To plot the hasse diagrams of the contexts 1 and 2 after applying RCA with exists
fca_cli -k context_1.csv context_2.csv -r relation_1_2.csv relation_2_1.csv --show_hasse
to specify operator
fca_cli -k context_1.csv context_2.csv -r relation_1_2.csv relation_2_1.csv --show_hasse -o forall
FCA utils
Module for FCA basics such as retrieving concepts, drawing a hasse diagram, etc
Getting formal concepts
In batch
from fca.api_models import Context, Concept
c = Context(O : List[str], A : List[str], I : List[List[int]])
concepts = c.get_concepts(c) List[Concept]
Incrementally
from fca.api_models import IncLattice
l = IncLattice(attributes=['a', 'b', 'c', 'd'])
l.add_intent('o1', [0, 2]) # numbers are the indices of the attributes
l.add_intent('o2', [1, 2])
.
.
.
Getting association rules
from fca.api_models import Context
c = Context(O, A, I)
c.get_association_rules(min_support=0.4, min_confidence=1)
Drawing hasse diagram
from fca.plot.plot import plot_from_hasse
from fca.api_models import Context
k = Context(O, A, I)
k.get_lattice().plot()
# plot receives a number of kwargs such as print_latex=True|False
l = IncLattice(attributes=['a', 'b', 'c', 'd'])
l.add_intent('o1', [0, 2]) # numbers are the indices of the attributes
l.add_intent('o2', [1, 2])
.
.
.
l.plot()
Contributors
- Ramshell (Nicolas Leutwyler)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fca-algorithms-1.0.3.tar.gz
.
File metadata
- Download URL: fca-algorithms-1.0.3.tar.gz
- Upload date:
- Size: 24.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b300982fe04f0bf5e577a0aebb8844b27b0a89a8efbdfe86dd067eabd282fcd4 |
|
MD5 | 0806523d4f906d6e093f3b41d8407f14 |
|
BLAKE2b-256 | 1fa6010c225f2fc03bf1b9d49e2645be4879d1a2efedb386675deab6abbfc905 |
File details
Details for the file fca_algorithms-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: fca_algorithms-1.0.3-py3-none-any.whl
- Upload date:
- Size: 29.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35076bb659a2952d868f6cfdd9c760a4b9ecd427482fcbe5a1e67851fe3f213c |
|
MD5 | 86eea823ba190022446ac86756aad351 |
|
BLAKE2b-256 | 91ca5ffa895a0ce54d79a12f7ae412fa174a951afd7fde82a7d41100c2fe1727 |