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

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.2
File Size Uploaded Provenance Actions
conceptflow-0.6.2.tar.gz 241.6 kB Without provenance Details for conceptflow-0.6.2.tar.gz

Built distribution (wheel)

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

Total release size: 435.3 kB

Release files / conceptflow-0.6.2.tar.gz

Download URL conceptflow-0.6.2.tar.gz
Size 241.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c85a8790fe33653efedc997e6e1952192f8bed901f287b884c53cb975a620ace
BLAKE2b-256 checksum
How to use checksums
94c79c41a3de093183a6a3162e6cccf53bb5aafb5cccfc112735b01a15ee9844
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

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

Download URL conceptflow-0.6.2-py3-none-any.whl
Size 193.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9dd87946e2de3351a9170aeab86bf8be984b29604504b16e8987bbfa4317a581
BLAKE2b-256 checksum
How to use checksums
f8470678bb6de9a7cbbc936edde14a7d6ad436b40f0321a77656a46405236b90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for conceptflow 0.6.2

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