Skip to main content

ConceptFlow

Python License Documentation Status

ConceptFlow is a Python library for Formal Concept Analysis (FCA) that fits into the scientific Python stack. Its machine-learning parts are proper scikit-learn estimators that pass scikit-learn's estimator checks.

pip install conceptflow

Requires Python 3.12 or newer.

Example

import conceptflow as cf
from conceptflow.algorithms import compute_canonical_basis

# Each object has either all three attributes or exactly one.
ctx = cf.FormalContext.from_array(
    [[1, 1, 1], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
    objects=["g1", "g2", "g3", "g4"],
    attributes=["a", "b", "c"],
)

lattice = cf.ConceptLattice.from_context(ctx)
print(lattice.n_concepts)  # 5

for implication in compute_canonical_basis(ctx):
    print(implication.premise_names(ctx), "->", implication.conclusion_names(ctx))
# ('a', 'b') -> ('c',)
# ('a', 'c') -> ('b',)
# ('b', 'c') -> ('a',)

fig = cf.plot_lattice(lattice, backend="matplotlib", layout="layered")
fig.savefig("lattice.png")  # backend="tikz" gives LaTeX code instead

Features

  • Formal contexts: building and editing, clarification and reduction, apposition, subposition, direct sum and product; .cxt, JSON (FCART/fcapy) and CSV files; incomplete (yes/no/unknown) contexts.
  • Concept lattices: NextClosure and Close-by-One on bitsets, iceberg lattices, navigation (join, meet, up-sets, object and attribute concepts), explicit opt-in limits for very large lattices.
  • Implications and rules: canonical (Duquenne-Guigues) basis with LinCbO, proper-premise basis, near-implications with exceptions (Luxenburger basis), minimal generators.
  • Measures: stability (exact and bounds), Δ-measure, entropy, information gain; lattice width, height, incomparable pairs, linearity and distributivity indices.
  • Scale-measures: coarser views of a context from attribute projections and conjunctions, their verification, and refinement pairs.
  • Conceptual scaling of many-valued data with seven scale types and explicit missing-value handling.
  • scikit-learn: scaling, concept and implication features, and an outlier detector that explains its decisions with implications.
  • Visualization: interactive HTML, DimFlux and layered layouts, matplotlib, Graphviz and TikZ/LaTeX export; Toscana-style nested line diagrams; 14 drawing quality metrics (crossings, layering, slopes, clearance).
  • Data quality: rule violations, redundant objects and attributes, explanations of objects and rules.
  • Factorization: Boolean matrix factorization (GreConD, ASSO) as scikit-learn transformers; ordinal two-factorization.
  • Datasets: the 20 contexts of the FCA repository (bundled), the UCI Mushroom data and random contexts.

Documentation

The documentation is at conceptflow.readthedocs.io:

The sources are in docs/.

To build the documentation site locally (with the API reference):

pip install -e ".[docs]"
mkdocs serve

Runnable examples, including a full case study, are in examples/.

Citing and contributing

If you use ConceptFlow in your research, please cite it; see CITATION.cff (or GitHub's "Cite this repository" button). Questions, bug reports and contributions are welcome; see CONTRIBUTING.md.

License

BSD 3-Clause; see LICENSE. Lattice layouts use DimFlux (the dim-flux package, CC BY 4.0), installed automatically.

Metadata

Release files for conceptflow 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for conceptflow 0.6.0
File Size Uploaded Provenance Actions
conceptflow-0.6.0.tar.gz 226.7 kB Without provenance Details for conceptflow-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for conceptflow 0.6.0
File Interpreter ABI Platform Actions
conceptflow-0.6.0-py3-none-any.whl Python 3 none any Details for conceptflow-0.6.0-py3-none-any.whl

Total release size: 413.4 kB

Release files / conceptflow-0.6.0.tar.gz

Download URL conceptflow-0.6.0.tar.gz
Size 226.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f80f9773406b5b8eebdfed90c5b43a3e185b0d6e622d1ad44c67c42ef6689397
BLAKE2b-256 checksum
How to use checksums
579d0ae4eac52140f8ec8d1872e769409a4dae60a5ae3b60f8aa0d652e2bb3fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / conceptflow-0.6.0-py3-none-any.whl

Download URL conceptflow-0.6.0-py3-none-any.whl
Size 186.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7acd9579a78c3528a954475af94eb8ff7f5af54768231cebfd3eb2cb4318c50d
BLAKE2b-256 checksum
How to use checksums
2e0dd52b0c29244fa85220f97508eae3ad7d6599222e364e5a385db68aea545c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for conceptflow 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page