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',)

cf.plot_lattice(lattice, backend="tikz", layout="layered").write("lattice.pdf")

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, linearity and distributivity indices.
  • 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.
  • 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.4.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.4.0
File Size Uploaded Provenance Actions
conceptflow-0.4.0.tar.gz 182.5 kB Without provenance Details for conceptflow-0.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 343.8 kB

Release files / conceptflow-0.4.0.tar.gz

Download URL conceptflow-0.4.0.tar.gz
Size 182.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6d30903436141f0f1bd27884b8688bb1eee42faaf150dd2abde7d9e2f74f5104
BLAKE2b-256 checksum
How to use checksums
315adb67266b78793c95916d0aedaafcd7ea9dedb2fab7210eab254be0fa827e
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.4.0-py3-none-any.whl

Download URL conceptflow-0.4.0-py3-none-any.whl
Size 161.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2cc2fdcddb69372f4433999af8ba09d5f16b21a8ac638cb38f701e620da5c53b
BLAKE2b-256 checksum
How to use checksums
37908a9c8494cb43e899decfc269d83bf55e3fba731aaf03f177f99381e2bcc9
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.4.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