Skip to main content

FCA basic algorithms

Project description

build

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.

API Reference

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

By intent

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])
.
.
.

By pair

from fca.api_models import IncLattice

l = IncLattice()
l.add_pair('o1', 'a')
l.add_pair('o2', 'b')
l.add_pair('o2', 'a')
.
.
.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fca_algorithms-1.1.5.tar.gz (31.0 kB view details)

Uploaded Source

Built Distribution

fca_algorithms-1.1.5-py3-none-any.whl (37.0 kB view details)

Uploaded Python 3

File details

Details for the file fca_algorithms-1.1.5.tar.gz.

File metadata

  • Download URL: fca_algorithms-1.1.5.tar.gz
  • Upload date:
  • Size: 31.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for fca_algorithms-1.1.5.tar.gz
Algorithm Hash digest
SHA256 1b33e0b262e3b1e223ddb70f1e65b9a21312a8567359eac95350930522fc0b67
MD5 eb72e8b548f178e8854bf8fd3a5e7d1d
BLAKE2b-256 873f8b871a591ed43e495199a3847c7e3c336ebdbfdfc9144bbde1d1b8d244cd

See more details on using hashes here.

File details

Details for the file fca_algorithms-1.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for fca_algorithms-1.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 21ab8abe5f6dd7656d47479bdd851196a687452e7fec175592df89e5f7f61551
MD5 c721fbcca07f2a721b016b1e6bfc72be
BLAKE2b-256 bb48588c7608c7843d1dd951430ac831896975db7b1499c234ec4d88bc2b9b7d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page