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.3

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.3
File Size Uploaded Provenance Actions
conceptflow-0.6.3.tar.gz 284.9 kB Without provenance Details for conceptflow-0.6.3.tar.gz

Built distribution (wheel)

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

Total release size: 479.4 kB

Release files / conceptflow-0.6.3.tar.gz

Download URL conceptflow-0.6.3.tar.gz
Size 284.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9235cb4a19f4ac7df7b84295f2715e3405bae59970be8378dd7ad0b053b04349
BLAKE2b-256 checksum
How to use checksums
eb72e3059442d8a0fa45ab6ff7d802e128432d3a898626391385be7acefb6875
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

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

Download URL conceptflow-0.6.3-py3-none-any.whl
Size 194.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc8c80ca55ff1abcc788658d46a6448ac5bdfccd92d16c6fd818a2f4314962cd
BLAKE2b-256 checksum
How to use checksums
d5b0700cb9bc636feced5e4462dc11462d02f9f69ac0051d83831f51a7a846bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Security for conceptflow 0.6.3

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