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

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

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

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.3.1
File Size Uploaded Provenance Actions
conceptflow-0.3.1.tar.gz 150.9 kB Without provenance Details for conceptflow-0.3.1.tar.gz

Built distribution (wheel)

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

Total release size: 281.4 kB

Release files / conceptflow-0.3.1.tar.gz

Download URL conceptflow-0.3.1.tar.gz
Size 150.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7fa28683607565f193600a68f306ce49bf54d7c50fe53028ec45fa97bc742e42
BLAKE2b-256 checksum
How to use checksums
d20ada0a092d8d1f723a4f0441a25a4bc2ed0da1bb5ca9f8224cdcc744eb29e6
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.3.1-py3-none-any.whl

Download URL conceptflow-0.3.1-py3-none-any.whl
Size 130.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d1361428fea863c720fb367e845b6cab6dd5b69ff0ed82f789c4ea67637ed8ee
BLAKE2b-256 checksum
How to use checksums
f98155bed125974e34b0a92604fcb21153eb22012064faed3b06429f6bbffb28
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.3.1

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