conceptflow 0.2.0__tar.gz → 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- conceptflow-0.3.1/PKG-INFO +168 -0
- conceptflow-0.3.1/README.md +101 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/pyproject.toml +5 -0
- conceptflow-0.3.1/src/conceptflow/_version.py +1 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/algorithms/__init__.py +10 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/algorithms/_registry.py +1 -1
- conceptflow-0.3.1/src/conceptflow/algorithms/enumeration.py +368 -0
- conceptflow-0.3.1/src/conceptflow/algorithms/generators.py +77 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/algorithms/hasse.py +14 -1
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/algorithms/implications.py +63 -3
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/algorithms/reduction.py +83 -1
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/cluster/concept_lattice.py +87 -4
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/core/__init__.py +14 -0
- conceptflow-0.3.1/src/conceptflow/core/context.py +437 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/core/incomplete_context.py +12 -3
- conceptflow-0.3.1/src/conceptflow/core/lattice.py +326 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/core/many_valued_context.py +13 -0
- conceptflow-0.3.1/src/conceptflow/core/operations.py +160 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/decomposition/ordinal_factorization.py +75 -102
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/exploration/__init__.py +6 -1
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/exploration/combinations.py +54 -1
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/feature_extraction/concept_encoder.py +5 -0
- conceptflow-0.3.1/src/conceptflow/io/__init__.py +20 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/io/cxt.py +24 -1
- conceptflow-0.3.1/src/conceptflow/io/formats.py +174 -0
- conceptflow-0.3.1/src/conceptflow/metrics/__init__.py +29 -0
- conceptflow-0.3.1/src/conceptflow/metrics/measures.py +347 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/metrics/rules.py +11 -4
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/preprocessing/conceptual_scaler.py +13 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/preprocessing/scales.py +21 -18
- conceptflow-0.3.1/src/conceptflow/quality.py +377 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/rules/__init__.py +2 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/rules/implication_basis.py +18 -2
- conceptflow-0.3.1/src/conceptflow/rules/outlier_detector.py +231 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/validation/input.py +50 -1
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/visualization/__init__.py +16 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/visualization/d3_backend.py +33 -17
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/visualization/dimflux_layout.py +10 -2
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/visualization/graph_data.py +50 -1
- conceptflow-0.3.1/src/conceptflow/visualization/graphviz.py +153 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/visualization/html_figure.py +9 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/visualization/lattice_plot.py +30 -8
- conceptflow-0.3.1/src/conceptflow/visualization/layered_layout.py +199 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/visualization/nested.py +47 -13
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/visualization/static.py +122 -107
- conceptflow-0.3.1/src/conceptflow/visualization/tikz.py +301 -0
- conceptflow-0.3.1/src/conceptflow.egg-info/PKG-INFO +168 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow.egg-info/SOURCES.txt +20 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow.egg-info/requires.txt +4 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_check_estimator.py +21 -2
- conceptflow-0.3.1/tests/test_context_handling.py +105 -0
- conceptflow-0.3.1/tests/test_context_operations.py +109 -0
- conceptflow-0.3.1/tests/test_docs_examples.py +78 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_enumeration.py +5 -1
- conceptflow-0.3.1/tests/test_generators.py +69 -0
- conceptflow-0.3.1/tests/test_lattice_navigation.py +180 -0
- conceptflow-0.3.1/tests/test_layout_and_graphviz.py +85 -0
- conceptflow-0.3.1/tests/test_measures.py +167 -0
- conceptflow-0.3.1/tests/test_patch_0_3_1.py +287 -0
- conceptflow-0.3.1/tests/test_quality.py +193 -0
- conceptflow-0.3.1/tests/test_review_fixes.py +213 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_static_figures.py +5 -4
- conceptflow-0.3.1/tests/test_tikz.py +73 -0
- conceptflow-0.2.0/PKG-INFO +0 -834
- conceptflow-0.2.0/README.md +0 -771
- conceptflow-0.2.0/src/conceptflow/_version.py +0 -1
- conceptflow-0.2.0/src/conceptflow/algorithms/enumeration.py +0 -218
- conceptflow-0.2.0/src/conceptflow/core/context.py +0 -283
- conceptflow-0.2.0/src/conceptflow/core/lattice.py +0 -144
- conceptflow-0.2.0/src/conceptflow/io/__init__.py +0 -6
- conceptflow-0.2.0/src/conceptflow/metrics/__init__.py +0 -13
- conceptflow-0.2.0/src/conceptflow.egg-info/PKG-INFO +0 -834
- {conceptflow-0.2.0 → conceptflow-0.3.1}/LICENSE +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/setup.cfg +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/__init__.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/algorithms/_bitset.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/algorithms/_membership.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/algorithms/derivation.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/algorithms/order.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/cluster/__init__.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/core/concept.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/decomposition/__init__.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/exploration/builder.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/exploration/view.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/feature_extraction/__init__.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/model_selection/__init__.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/preprocessing/__init__.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow/validation/__init__.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow.egg-info/dependency_links.txt +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/src/conceptflow.egg-info/top_level.txt +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_algorithm_registry.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_audit_regressions.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_cluster_estimator.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_concept.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_concept_encoder.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_conceptual_scaler.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_cxt_io.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_d3_backend.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_derivation.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_dimflux_layout.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_exploration.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_formal_context.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_graph_data.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_hasse.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_html_figure.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_implication_basis_estimator.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_implications.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_incomplete_context.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_lattice.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_many_valued_context.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_metrics.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_nested_combinations.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_nested_visualization.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_ordinal_factorization.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_public_api.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_reduction.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_scales.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_sklearn_compatibility.py +0 -0
- {conceptflow-0.2.0 → conceptflow-0.3.1}/tests/test_validation_input.py +0 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: conceptflow
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: A scikit-learn compatible Formal Concept Analysis framework.
|
|
5
|
+
Author-email: Anurag Sharma <sharma@cs.uni-kassel.de>
|
|
6
|
+
License: BSD 3-Clause License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2025, Anurag Sharma
|
|
9
|
+
|
|
10
|
+
Redistribution and use in source and binary forms, with or without
|
|
11
|
+
modification, are permitted provided that the following conditions are met:
|
|
12
|
+
|
|
13
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
14
|
+
list of conditions and the following disclaimer.
|
|
15
|
+
|
|
16
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
17
|
+
this list of conditions and the following disclaimer in the documentation
|
|
18
|
+
and/or other materials provided with the distribution.
|
|
19
|
+
|
|
20
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
21
|
+
contributors may be used to endorse or promote products derived from
|
|
22
|
+
this software without specific prior written permission.
|
|
23
|
+
|
|
24
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
25
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
26
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
27
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
28
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
29
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
30
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
31
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
32
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
33
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
34
|
+
|
|
35
|
+
Project-URL: Homepage, https://github.com/anuragxorma/conceptflow
|
|
36
|
+
Project-URL: Documentation, https://conceptflow.readthedocs.io
|
|
37
|
+
Project-URL: Repository, https://github.com/anuragxorma/conceptflow
|
|
38
|
+
Project-URL: Issues, https://github.com/anuragxorma/conceptflow/issues
|
|
39
|
+
Keywords: formal-concept-analysis,fca,scikit-learn,concept-lattice,conceptual-scaling
|
|
40
|
+
Classifier: Development Status :: 3 - Alpha
|
|
41
|
+
Classifier: Intended Audience :: Science/Research
|
|
42
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
43
|
+
Classifier: Programming Language :: Python :: 3
|
|
44
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
45
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
46
|
+
Classifier: Operating System :: OS Independent
|
|
47
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
48
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
49
|
+
Requires-Python: >=3.12
|
|
50
|
+
Description-Content-Type: text/markdown
|
|
51
|
+
License-File: LICENSE
|
|
52
|
+
Requires-Dist: numpy
|
|
53
|
+
Requires-Dist: pandas
|
|
54
|
+
Requires-Dist: scipy
|
|
55
|
+
Requires-Dist: scikit-learn>=1.5
|
|
56
|
+
Requires-Dist: networkx
|
|
57
|
+
Requires-Dist: dim-flux<1.1,>=1.0.11
|
|
58
|
+
Provides-Extra: docs
|
|
59
|
+
Requires-Dist: mkdocs-material>=9.5; extra == "docs"
|
|
60
|
+
Requires-Dist: mkdocstrings[python]>=0.26; extra == "docs"
|
|
61
|
+
Provides-Extra: dev
|
|
62
|
+
Requires-Dist: scikit-learn>=1.6; extra == "dev"
|
|
63
|
+
Requires-Dist: pytest; extra == "dev"
|
|
64
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
65
|
+
Requires-Dist: ruff; extra == "dev"
|
|
66
|
+
Dynamic: license-file
|
|
67
|
+
|
|
68
|
+
# ConceptFlow
|
|
69
|
+
|
|
70
|
+

|
|
71
|
+

|
|
72
|
+
[](https://conceptflow.readthedocs.io)
|
|
73
|
+

|
|
74
|
+
|
|
75
|
+
ConceptFlow is a Python library for **Formal Concept Analysis (FCA)** that
|
|
76
|
+
fits into the scientific Python stack. Its machine-learning parts are proper
|
|
77
|
+
[scikit-learn](https://scikit-learn.org) estimators that pass scikit-learn's
|
|
78
|
+
estimator checks.
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
pip install conceptflow
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Requires Python 3.12 or newer.
|
|
85
|
+
|
|
86
|
+
## Example
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
import conceptflow as cf
|
|
90
|
+
from conceptflow.algorithms import compute_canonical_basis
|
|
91
|
+
|
|
92
|
+
# Each object has either all three attributes or exactly one.
|
|
93
|
+
ctx = cf.FormalContext.from_array(
|
|
94
|
+
[[1, 1, 1], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
|
|
95
|
+
objects=["g1", "g2", "g3", "g4"],
|
|
96
|
+
attributes=["a", "b", "c"],
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
lattice = cf.ConceptLattice.from_context(ctx)
|
|
100
|
+
print(lattice.n_concepts) # 5
|
|
101
|
+
|
|
102
|
+
for implication in compute_canonical_basis(ctx):
|
|
103
|
+
print(implication.premise_names(ctx), "->", implication.conclusion_names(ctx))
|
|
104
|
+
# ('a', 'b') -> ('c',)
|
|
105
|
+
# ('a', 'c') -> ('b',)
|
|
106
|
+
# ('b', 'c') -> ('a',)
|
|
107
|
+
|
|
108
|
+
cf.plot_lattice(lattice, backend="tikz", layout="layered").write("lattice.pdf")
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Features
|
|
112
|
+
|
|
113
|
+
- **Formal contexts:** building and editing, clarification and reduction,
|
|
114
|
+
apposition, subposition, direct sum and product; `.cxt`, JSON (FCART/fcapy)
|
|
115
|
+
and CSV files; incomplete (yes/no/unknown) contexts.
|
|
116
|
+
- **Concept lattices:** NextClosure and Close-by-One on bitsets, iceberg
|
|
117
|
+
lattices, navigation (join, meet, up-sets, object and attribute concepts),
|
|
118
|
+
explicit opt-in limits for very large lattices.
|
|
119
|
+
- **Implications and rules:** canonical (Duquenne-Guigues) basis,
|
|
120
|
+
proper-premise basis, near-implications with exceptions (Luxenburger basis),
|
|
121
|
+
minimal generators.
|
|
122
|
+
- **Measures:** stability (exact and bounds), Δ-measure, entropy, information
|
|
123
|
+
gain, linearity and distributivity indices.
|
|
124
|
+
- **Conceptual scaling** of many-valued data with seven scale types and
|
|
125
|
+
explicit missing-value handling.
|
|
126
|
+
- **scikit-learn:** scaling, concept and implication features, and an
|
|
127
|
+
outlier detector that explains its decisions with implications.
|
|
128
|
+
- **Visualization:** interactive HTML, DimFlux and layered layouts,
|
|
129
|
+
matplotlib, Graphviz and TikZ/LaTeX export; Toscana-style nested line
|
|
130
|
+
diagrams.
|
|
131
|
+
- **Data quality:** rule violations, redundant objects and attributes,
|
|
132
|
+
explanations of objects and rules.
|
|
133
|
+
|
|
134
|
+
## Documentation
|
|
135
|
+
|
|
136
|
+
The documentation is at **[conceptflow.readthedocs.io](https://conceptflow.readthedocs.io)**:
|
|
137
|
+
|
|
138
|
+
- [Getting started](https://conceptflow.readthedocs.io/en/latest/getting-started/)
|
|
139
|
+
- User guide: [contexts](https://conceptflow.readthedocs.io/en/latest/guide/contexts/),
|
|
140
|
+
[lattices](https://conceptflow.readthedocs.io/en/latest/guide/lattices/),
|
|
141
|
+
[implications](https://conceptflow.readthedocs.io/en/latest/guide/rules/),
|
|
142
|
+
[measures](https://conceptflow.readthedocs.io/en/latest/guide/measures/),
|
|
143
|
+
[scaling](https://conceptflow.readthedocs.io/en/latest/guide/scaling/),
|
|
144
|
+
[scikit-learn](https://conceptflow.readthedocs.io/en/latest/guide/sklearn/),
|
|
145
|
+
[visualization](https://conceptflow.readthedocs.io/en/latest/guide/visualization/),
|
|
146
|
+
[nested diagrams](https://conceptflow.readthedocs.io/en/latest/guide/nested/),
|
|
147
|
+
[data quality](https://conceptflow.readthedocs.io/en/latest/guide/quality/),
|
|
148
|
+
[ordinal factorization](https://conceptflow.readthedocs.io/en/latest/guide/decomposition/)
|
|
149
|
+
- [API reference](https://conceptflow.readthedocs.io/en/latest/api/core/)
|
|
150
|
+
- [Changelog](https://conceptflow.readthedocs.io/en/latest/changelog/)
|
|
151
|
+
|
|
152
|
+
The sources are in [`docs/`](https://github.com/anuragxorma/conceptflow/tree/main/docs).
|
|
153
|
+
|
|
154
|
+
To build the documentation site locally (with the API reference):
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
pip install -e ".[docs]"
|
|
158
|
+
mkdocs serve
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Runnable examples, including a full case study, are in
|
|
162
|
+
[`examples/`](https://github.com/anuragxorma/conceptflow/tree/main/examples).
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
BSD 3-Clause; see [LICENSE](https://github.com/anuragxorma/conceptflow/blob/main/LICENSE).
|
|
167
|
+
Lattice layouts use [DimFlux](https://arxiv.org/abs/2603.16366) (the
|
|
168
|
+
`dim-flux` package, CC BY 4.0), installed automatically.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# ConceptFlow
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
[](https://conceptflow.readthedocs.io)
|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
ConceptFlow is a Python library for **Formal Concept Analysis (FCA)** that
|
|
9
|
+
fits into the scientific Python stack. Its machine-learning parts are proper
|
|
10
|
+
[scikit-learn](https://scikit-learn.org) estimators that pass scikit-learn's
|
|
11
|
+
estimator checks.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install conceptflow
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Requires Python 3.12 or newer.
|
|
18
|
+
|
|
19
|
+
## Example
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
import conceptflow as cf
|
|
23
|
+
from conceptflow.algorithms import compute_canonical_basis
|
|
24
|
+
|
|
25
|
+
# Each object has either all three attributes or exactly one.
|
|
26
|
+
ctx = cf.FormalContext.from_array(
|
|
27
|
+
[[1, 1, 1], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
|
|
28
|
+
objects=["g1", "g2", "g3", "g4"],
|
|
29
|
+
attributes=["a", "b", "c"],
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
lattice = cf.ConceptLattice.from_context(ctx)
|
|
33
|
+
print(lattice.n_concepts) # 5
|
|
34
|
+
|
|
35
|
+
for implication in compute_canonical_basis(ctx):
|
|
36
|
+
print(implication.premise_names(ctx), "->", implication.conclusion_names(ctx))
|
|
37
|
+
# ('a', 'b') -> ('c',)
|
|
38
|
+
# ('a', 'c') -> ('b',)
|
|
39
|
+
# ('b', 'c') -> ('a',)
|
|
40
|
+
|
|
41
|
+
cf.plot_lattice(lattice, backend="tikz", layout="layered").write("lattice.pdf")
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Features
|
|
45
|
+
|
|
46
|
+
- **Formal contexts:** building and editing, clarification and reduction,
|
|
47
|
+
apposition, subposition, direct sum and product; `.cxt`, JSON (FCART/fcapy)
|
|
48
|
+
and CSV files; incomplete (yes/no/unknown) contexts.
|
|
49
|
+
- **Concept lattices:** NextClosure and Close-by-One on bitsets, iceberg
|
|
50
|
+
lattices, navigation (join, meet, up-sets, object and attribute concepts),
|
|
51
|
+
explicit opt-in limits for very large lattices.
|
|
52
|
+
- **Implications and rules:** canonical (Duquenne-Guigues) basis,
|
|
53
|
+
proper-premise basis, near-implications with exceptions (Luxenburger basis),
|
|
54
|
+
minimal generators.
|
|
55
|
+
- **Measures:** stability (exact and bounds), Δ-measure, entropy, information
|
|
56
|
+
gain, linearity and distributivity indices.
|
|
57
|
+
- **Conceptual scaling** of many-valued data with seven scale types and
|
|
58
|
+
explicit missing-value handling.
|
|
59
|
+
- **scikit-learn:** scaling, concept and implication features, and an
|
|
60
|
+
outlier detector that explains its decisions with implications.
|
|
61
|
+
- **Visualization:** interactive HTML, DimFlux and layered layouts,
|
|
62
|
+
matplotlib, Graphviz and TikZ/LaTeX export; Toscana-style nested line
|
|
63
|
+
diagrams.
|
|
64
|
+
- **Data quality:** rule violations, redundant objects and attributes,
|
|
65
|
+
explanations of objects and rules.
|
|
66
|
+
|
|
67
|
+
## Documentation
|
|
68
|
+
|
|
69
|
+
The documentation is at **[conceptflow.readthedocs.io](https://conceptflow.readthedocs.io)**:
|
|
70
|
+
|
|
71
|
+
- [Getting started](https://conceptflow.readthedocs.io/en/latest/getting-started/)
|
|
72
|
+
- User guide: [contexts](https://conceptflow.readthedocs.io/en/latest/guide/contexts/),
|
|
73
|
+
[lattices](https://conceptflow.readthedocs.io/en/latest/guide/lattices/),
|
|
74
|
+
[implications](https://conceptflow.readthedocs.io/en/latest/guide/rules/),
|
|
75
|
+
[measures](https://conceptflow.readthedocs.io/en/latest/guide/measures/),
|
|
76
|
+
[scaling](https://conceptflow.readthedocs.io/en/latest/guide/scaling/),
|
|
77
|
+
[scikit-learn](https://conceptflow.readthedocs.io/en/latest/guide/sklearn/),
|
|
78
|
+
[visualization](https://conceptflow.readthedocs.io/en/latest/guide/visualization/),
|
|
79
|
+
[nested diagrams](https://conceptflow.readthedocs.io/en/latest/guide/nested/),
|
|
80
|
+
[data quality](https://conceptflow.readthedocs.io/en/latest/guide/quality/),
|
|
81
|
+
[ordinal factorization](https://conceptflow.readthedocs.io/en/latest/guide/decomposition/)
|
|
82
|
+
- [API reference](https://conceptflow.readthedocs.io/en/latest/api/core/)
|
|
83
|
+
- [Changelog](https://conceptflow.readthedocs.io/en/latest/changelog/)
|
|
84
|
+
|
|
85
|
+
The sources are in [`docs/`](https://github.com/anuragxorma/conceptflow/tree/main/docs).
|
|
86
|
+
|
|
87
|
+
To build the documentation site locally (with the API reference):
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
pip install -e ".[docs]"
|
|
91
|
+
mkdocs serve
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Runnable examples, including a full case study, are in
|
|
95
|
+
[`examples/`](https://github.com/anuragxorma/conceptflow/tree/main/examples).
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
BSD 3-Clause; see [LICENSE](https://github.com/anuragxorma/conceptflow/blob/main/LICENSE).
|
|
100
|
+
Lattice layouts use [DimFlux](https://arxiv.org/abs/2603.16366) (the
|
|
101
|
+
`dim-flux` package, CC BY 4.0), installed automatically.
|
|
@@ -42,6 +42,10 @@ dependencies = [
|
|
|
42
42
|
]
|
|
43
43
|
|
|
44
44
|
[project.optional-dependencies]
|
|
45
|
+
docs = [
|
|
46
|
+
"mkdocs-material>=9.5",
|
|
47
|
+
"mkdocstrings[python]>=0.26",
|
|
48
|
+
]
|
|
45
49
|
dev = [
|
|
46
50
|
# The check_estimator tests use the scikit-learn >= 1.6 API.
|
|
47
51
|
"scikit-learn>=1.6",
|
|
@@ -52,6 +56,7 @@ dev = [
|
|
|
52
56
|
|
|
53
57
|
[project.urls]
|
|
54
58
|
Homepage = "https://github.com/anuragxorma/conceptflow"
|
|
59
|
+
Documentation = "https://conceptflow.readthedocs.io"
|
|
55
60
|
Repository = "https://github.com/anuragxorma/conceptflow"
|
|
56
61
|
Issues = "https://github.com/anuragxorma/conceptflow/issues"
|
|
57
62
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.1"
|
|
@@ -22,13 +22,18 @@ from conceptflow.algorithms.implications import (
|
|
|
22
22
|
compute_canonical_basis,
|
|
23
23
|
compute_canonical_basis_bruteforce,
|
|
24
24
|
compute_luxenburger_basis,
|
|
25
|
+
compute_proper_premise_basis,
|
|
25
26
|
)
|
|
27
|
+
from conceptflow.algorithms.generators import compute_minimal_generators
|
|
26
28
|
from conceptflow.algorithms.order import strict_subconcept_of, subconcept_of
|
|
27
29
|
|
|
28
30
|
from conceptflow.algorithms.reduction import (
|
|
29
31
|
ClarificationResult,
|
|
32
|
+
ReductionResult,
|
|
30
33
|
clarified_context,
|
|
31
34
|
clarify_context,
|
|
35
|
+
reduce_context,
|
|
36
|
+
reduced_context,
|
|
32
37
|
)
|
|
33
38
|
|
|
34
39
|
__all__ = [
|
|
@@ -48,9 +53,14 @@ __all__ = [
|
|
|
48
53
|
"compute_canonical_basis_bruteforce",
|
|
49
54
|
"AssociationRule",
|
|
50
55
|
"compute_luxenburger_basis",
|
|
56
|
+
"compute_proper_premise_basis",
|
|
57
|
+
"compute_minimal_generators",
|
|
51
58
|
"SUPPORTED_ENUMERATION_ALGORITHMS",
|
|
52
59
|
"normalize_enumeration_algorithm",
|
|
53
60
|
"ClarificationResult",
|
|
54
61
|
"clarified_context",
|
|
55
62
|
"clarify_context",
|
|
63
|
+
"ReductionResult",
|
|
64
|
+
"reduce_context",
|
|
65
|
+
"reduced_context",
|
|
56
66
|
]
|
|
@@ -46,7 +46,7 @@ def normalize_enumeration_algorithm(name: str) -> str:
|
|
|
46
46
|
ValueError
|
|
47
47
|
If the algorithm is unknown.
|
|
48
48
|
"""
|
|
49
|
-
normalized = name.lower().strip().replace(" ", "_")
|
|
49
|
+
normalized = name.lower().strip().replace(" ", "_") if isinstance(name, str) else None
|
|
50
50
|
|
|
51
51
|
if normalized not in ENUMERATION_ALGORITHM_ALIASES:
|
|
52
52
|
supported = ", ".join(sorted(SUPPORTED_ENUMERATION_ALGORITHMS))
|