conceptflow 0.5.0__tar.gz → 0.6.0__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.5.0/src/conceptflow.egg-info → conceptflow-0.6.0}/PKG-INFO +9 -4
- {conceptflow-0.5.0 → conceptflow-0.6.0}/README.md +8 -3
- conceptflow-0.6.0/src/conceptflow/_version.py +1 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/core/__init__.py +10 -0
- conceptflow-0.6.0/src/conceptflow/core/scale_measures.py +143 -0
- conceptflow-0.6.0/src/conceptflow/metrics/__init__.py +71 -0
- conceptflow-0.6.0/src/conceptflow/metrics/drawing_quality.py +898 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/metrics/measures.py +80 -2
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/visualization/__init__.py +2 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/visualization/graph_data.py +22 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0/src/conceptflow.egg-info}/PKG-INFO +9 -4
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow.egg-info/SOURCES.txt +6 -1
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_docs_examples.py +11 -7
- conceptflow-0.6.0/tests/test_drawing_quality.py +336 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_layout_and_graphviz.py +29 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_measures.py +38 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_oracles.py +68 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_public_api.py +16 -0
- conceptflow-0.6.0/tests/test_scale_measures.py +100 -0
- conceptflow-0.6.0/tests/test_workflows.py +130 -0
- conceptflow-0.5.0/src/conceptflow/_version.py +0 -1
- conceptflow-0.5.0/src/conceptflow/metrics/__init__.py +0 -29
- {conceptflow-0.5.0 → conceptflow-0.6.0}/LICENSE +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/pyproject.toml +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/setup.cfg +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/__init__.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/_deprecation.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/algorithms/__init__.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/algorithms/_bitset.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/algorithms/_membership.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/algorithms/_registry.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/algorithms/derivation.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/algorithms/enumeration.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/algorithms/generators.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/algorithms/hasse.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/algorithms/implications.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/algorithms/order.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/algorithms/reduction.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/cluster/__init__.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/cluster/concept_lattice.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/core/concept.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/core/context.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/core/incomplete_context.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/core/lattice.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/core/many_valued_context.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/core/operations.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/__init__.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/_loaders.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/README.md +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/animals_en.cxt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/binary_relations_en.cxt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/bodiesofwater_de.cxt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/bodiesofwater_en.cxt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/driveconcepts_de.cxt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/driveconcepts_en.cxt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/famous_animals_en.cxt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/forum_romanum_en.cxt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/livingbeings_de.cxt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/livingbeings_en.cxt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/missmarple_de.cxt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/missmarple_en.cxt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/music_en.cxt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/newzealand_en.cxt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/officesupplies_de.cxt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/officesupplies_en.cxt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/planets_en.cxt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/seasoningplanner_de.cxt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/tealady.cxt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository/triangles_en.cxt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/datasets/data/fca_repository.json +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/decomposition/__init__.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/decomposition/bipartite.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/decomposition/boolean_factorization.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/decomposition/ordinal_factorization.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/exploration/__init__.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/exploration/builder.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/exploration/combinations.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/exploration/view.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/feature_extraction/__init__.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/feature_extraction/concept_encoder.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/io/__init__.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/io/cxt.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/io/formats.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/metrics/rules.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/preprocessing/__init__.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/preprocessing/conceptual_scaler.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/preprocessing/scales.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/quality.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/rules/__init__.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/rules/implication_basis.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/rules/outlier_detector.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/validation/__init__.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/validation/input.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/visualization/_checks.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/visualization/_clearance.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/visualization/_text.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/visualization/d3_backend.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/visualization/dimflux_layout.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/visualization/graphviz.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/visualization/html_figure.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/visualization/lattice_plot.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/visualization/layered_layout.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/visualization/nested.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/visualization/static.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow/visualization/tikz.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow.egg-info/dependency_links.txt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow.egg-info/requires.txt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/src/conceptflow.egg-info/top_level.txt +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_algorithm_registry.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_audit_regressions.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_boolean_factorization.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_browser.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_check_estimator.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_cluster_estimator.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_concept.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_concept_encoder.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_conceptual_scaler.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_context_handling.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_context_operations.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_cxt_io.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_d3_backend.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_datasets.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_derivation.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_dimflux_layout.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_enumeration.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_exploration.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_formal_context.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_generators.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_graph_data.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_hasse.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_html_figure.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_implication_basis_estimator.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_implications.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_incomplete_context.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_lattice.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_lattice_navigation.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_many_valued_context.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_metrics.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_nested_combinations.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_nested_visualization.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_ord2factor.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_ordinal_factorization.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_patch_0_3_1.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_quality.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_reduction.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_review_fixes.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_scales.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_sklearn_compatibility.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_static_figures.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_tikz.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_validation_input.py +0 -0
- {conceptflow-0.5.0 → conceptflow-0.6.0}/tests/test_visualization_options.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: conceptflow
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: A scikit-learn compatible Formal Concept Analysis framework.
|
|
5
5
|
Author-email: Anurag Sharma <sharma@cs.uni-kassel.de>
|
|
6
6
|
License: BSD 3-Clause License
|
|
@@ -107,7 +107,8 @@ for implication in compute_canonical_basis(ctx):
|
|
|
107
107
|
# ('a', 'c') -> ('b',)
|
|
108
108
|
# ('b', 'c') -> ('a',)
|
|
109
109
|
|
|
110
|
-
cf.plot_lattice(lattice, backend="
|
|
110
|
+
fig = cf.plot_lattice(lattice, backend="matplotlib", layout="layered")
|
|
111
|
+
fig.savefig("lattice.png") # backend="tikz" gives LaTeX code instead
|
|
111
112
|
```
|
|
112
113
|
|
|
113
114
|
## Features
|
|
@@ -122,14 +123,18 @@ cf.plot_lattice(lattice, backend="tikz", layout="layered").write("lattice.pdf")
|
|
|
122
123
|
LinCbO, proper-premise basis, near-implications with exceptions (Luxenburger
|
|
123
124
|
basis), minimal generators.
|
|
124
125
|
- **Measures:** stability (exact and bounds), Δ-measure, entropy, information
|
|
125
|
-
gain, linearity and
|
|
126
|
+
gain; lattice width, height, incomparable pairs, linearity and
|
|
127
|
+
distributivity indices.
|
|
128
|
+
- **Scale-measures:** coarser views of a context from attribute projections
|
|
129
|
+
and conjunctions, their verification, and refinement pairs.
|
|
126
130
|
- **Conceptual scaling** of many-valued data with seven scale types and
|
|
127
131
|
explicit missing-value handling.
|
|
128
132
|
- **scikit-learn:** scaling, concept and implication features, and an
|
|
129
133
|
outlier detector that explains its decisions with implications.
|
|
130
134
|
- **Visualization:** interactive HTML, DimFlux and layered layouts,
|
|
131
135
|
matplotlib, Graphviz and TikZ/LaTeX export; Toscana-style nested line
|
|
132
|
-
diagrams
|
|
136
|
+
diagrams; 14 drawing quality metrics (crossings, layering, slopes,
|
|
137
|
+
clearance).
|
|
133
138
|
- **Data quality:** rule violations, redundant objects and attributes,
|
|
134
139
|
explanations of objects and rules.
|
|
135
140
|
- **Factorization:** Boolean matrix factorization (GreConD, ASSO) as
|
|
@@ -38,7 +38,8 @@ for implication in compute_canonical_basis(ctx):
|
|
|
38
38
|
# ('a', 'c') -> ('b',)
|
|
39
39
|
# ('b', 'c') -> ('a',)
|
|
40
40
|
|
|
41
|
-
cf.plot_lattice(lattice, backend="
|
|
41
|
+
fig = cf.plot_lattice(lattice, backend="matplotlib", layout="layered")
|
|
42
|
+
fig.savefig("lattice.png") # backend="tikz" gives LaTeX code instead
|
|
42
43
|
```
|
|
43
44
|
|
|
44
45
|
## Features
|
|
@@ -53,14 +54,18 @@ cf.plot_lattice(lattice, backend="tikz", layout="layered").write("lattice.pdf")
|
|
|
53
54
|
LinCbO, proper-premise basis, near-implications with exceptions (Luxenburger
|
|
54
55
|
basis), minimal generators.
|
|
55
56
|
- **Measures:** stability (exact and bounds), Δ-measure, entropy, information
|
|
56
|
-
gain, linearity and
|
|
57
|
+
gain; lattice width, height, incomparable pairs, linearity and
|
|
58
|
+
distributivity indices.
|
|
59
|
+
- **Scale-measures:** coarser views of a context from attribute projections
|
|
60
|
+
and conjunctions, their verification, and refinement pairs.
|
|
57
61
|
- **Conceptual scaling** of many-valued data with seven scale types and
|
|
58
62
|
explicit missing-value handling.
|
|
59
63
|
- **scikit-learn:** scaling, concept and implication features, and an
|
|
60
64
|
outlier detector that explains its decisions with implications.
|
|
61
65
|
- **Visualization:** interactive HTML, DimFlux and layered layouts,
|
|
62
66
|
matplotlib, Graphviz and TikZ/LaTeX export; Toscana-style nested line
|
|
63
|
-
diagrams
|
|
67
|
+
diagrams; 14 drawing quality metrics (crossings, layering, slopes,
|
|
68
|
+
clearance).
|
|
64
69
|
- **Data quality:** rule violations, redundant objects and attributes,
|
|
65
70
|
explanations of objects and rules.
|
|
66
71
|
- **Factorization:** Boolean matrix factorization (GreConD, ASSO) as
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.6.0"
|
|
@@ -11,6 +11,12 @@ from conceptflow.core.operations import (
|
|
|
11
11
|
dual,
|
|
12
12
|
subposition,
|
|
13
13
|
)
|
|
14
|
+
from conceptflow.core.scale_measures import (
|
|
15
|
+
is_scale_measure,
|
|
16
|
+
refines,
|
|
17
|
+
scale_measure,
|
|
18
|
+
scale_measure_problems,
|
|
19
|
+
)
|
|
14
20
|
|
|
15
21
|
__all__ = [
|
|
16
22
|
"Concept",
|
|
@@ -24,4 +30,8 @@ __all__ = [
|
|
|
24
30
|
"direct_product",
|
|
25
31
|
"complement",
|
|
26
32
|
"dual",
|
|
33
|
+
"scale_measure",
|
|
34
|
+
"is_scale_measure",
|
|
35
|
+
"scale_measure_problems",
|
|
36
|
+
"refines",
|
|
27
37
|
]
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Scale-measures: coarser views of a formal context on the same objects.
|
|
3
|
+
|
|
4
|
+
Following Hanika & Hirth, "On the lattice of conceptual measurements" (2022).
|
|
5
|
+
A scale-measure of a context K keeps K's objects and makes fewer
|
|
6
|
+
distinctions between them: every extent of the scale is an extent of K, so
|
|
7
|
+
its concept lattice is a coarser view of K's.
|
|
8
|
+
|
|
9
|
+
- ``scale_measure(context, attributes)`` builds one whose attributes are
|
|
10
|
+
original attributes (attribute projection, Cor. 22) or conjunctions of
|
|
11
|
+
them (Cor. 17); both are scale-measures unconditionally. Disjunctions and
|
|
12
|
+
negations are not offered: they give a scale-measure only when the
|
|
13
|
+
resulting extent happens to be an extent of K (Prop. 16).
|
|
14
|
+
- ``is_scale_measure(original, scale)`` checks the property for a context on
|
|
15
|
+
the same objects, attribute by attribute (Prop. 20), and
|
|
16
|
+
``scale_measure_problems`` says which attributes fail.
|
|
17
|
+
- ``refines(coarse, fine)`` tells whether every extent of ``coarse`` is an
|
|
18
|
+
extent of ``fine``. Such a *refinement pair* has every concept of the
|
|
19
|
+
coarser view among the concepts of the finer one, so the two lattices (and
|
|
20
|
+
their drawings) can be compared concept by concept.
|
|
21
|
+
|
|
22
|
+
These scales are not the conceptual scales of ``conceptflow.preprocessing``,
|
|
23
|
+
which turn many-valued data into a formal context.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
from __future__ import annotations
|
|
27
|
+
|
|
28
|
+
import numbers
|
|
29
|
+
from collections.abc import Iterable
|
|
30
|
+
|
|
31
|
+
import numpy as np
|
|
32
|
+
|
|
33
|
+
from conceptflow.core.context import FormalContext
|
|
34
|
+
from conceptflow.core.lattice import ConceptLattice
|
|
35
|
+
|
|
36
|
+
# Joins the names of the parts of a conjunction in the scale's attribute name.
|
|
37
|
+
CONJUNCTION = " ∧ "
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def scale_measure(
|
|
41
|
+
context: FormalContext,
|
|
42
|
+
attributes: Iterable[str | int | Iterable[str | int]] | None,
|
|
43
|
+
) -> FormalContext:
|
|
44
|
+
"""
|
|
45
|
+
The scale-measure of ``context`` with the given attributes.
|
|
46
|
+
|
|
47
|
+
Each entry of ``attributes`` is one attribute of ``context`` (a name or
|
|
48
|
+
a position), kept as it is, or a tuple of them, which becomes their
|
|
49
|
+
conjunction: an object has it iff it has every part. The conjunction of
|
|
50
|
+
``"a"`` and ``"b"`` is named ``"a ∧ b"``. ``None`` returns ``context``.
|
|
51
|
+
|
|
52
|
+
The objects stay those of ``context``, in the same order. The attributes
|
|
53
|
+
are put in one canonical order: by the positions of their parts in
|
|
54
|
+
``context``, compared as sorted tuples. Two scales of one context then
|
|
55
|
+
list their common attributes in the same relative order, which matters
|
|
56
|
+
for layouts that depend on column order.
|
|
57
|
+
|
|
58
|
+
Raises
|
|
59
|
+
------
|
|
60
|
+
KeyError
|
|
61
|
+
For a name that is not an attribute of ``context``.
|
|
62
|
+
ValueError
|
|
63
|
+
For an empty conjunction, or two entries that give the same name.
|
|
64
|
+
"""
|
|
65
|
+
if attributes is None:
|
|
66
|
+
return context
|
|
67
|
+
|
|
68
|
+
entries = []
|
|
69
|
+
for entry in attributes:
|
|
70
|
+
parts = (entry,) if isinstance(entry, (str, numbers.Integral)) else tuple(entry)
|
|
71
|
+
if not parts:
|
|
72
|
+
raise ValueError("A conjunction needs at least one attribute.")
|
|
73
|
+
indices = context._resolve_attribute_indices(parts)
|
|
74
|
+
entries.append((tuple(sorted(indices)), indices))
|
|
75
|
+
entries.sort(key=lambda item: item[0]) # stable: equal keys keep their order
|
|
76
|
+
|
|
77
|
+
names = [CONJUNCTION.join(context.attributes[i] for i in indices) for _, indices in entries]
|
|
78
|
+
if len(set(names)) != len(names):
|
|
79
|
+
raise ValueError(f"Two attributes of the scale would have the same name: {names}.")
|
|
80
|
+
incidence = np.ones((context.n_objects, len(entries)), dtype=bool)
|
|
81
|
+
for column, (_, indices) in enumerate(entries):
|
|
82
|
+
for index in indices:
|
|
83
|
+
incidence[:, column] &= context.incidence[:, index]
|
|
84
|
+
return FormalContext(objects=context.objects, attributes=tuple(names), incidence=incidence)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def scale_measure_problems(original: FormalContext, scale: FormalContext) -> list[str]:
|
|
88
|
+
"""
|
|
89
|
+
Why ``scale`` is not a scale-measure of ``original`` (empty if it is).
|
|
90
|
+
|
|
91
|
+
The scale must have the same objects, in the same order (the map between
|
|
92
|
+
them is the identity). It is then a scale-measure iff the extent of each
|
|
93
|
+
of its attributes is an extent of ``original``, i.e. equals its own
|
|
94
|
+
closure there (Hanika & Hirth, Prop. 20). That is one closure per
|
|
95
|
+
attribute; the scale's lattice is not enumerated.
|
|
96
|
+
"""
|
|
97
|
+
if tuple(scale.objects) != tuple(original.objects):
|
|
98
|
+
return ["object sets differ, so the identity is not a map between them"]
|
|
99
|
+
problems = []
|
|
100
|
+
for index, name in enumerate(scale.attributes):
|
|
101
|
+
extent = scale.attribute_derivation([index])
|
|
102
|
+
closed = original.attribute_derivation(original.object_derivation(extent))
|
|
103
|
+
if closed != extent:
|
|
104
|
+
problems.append(
|
|
105
|
+
f"attribute {name!r}: its extent has {len(extent)} objects but closes to "
|
|
106
|
+
f"{len(closed)} in the original context, so it is not an extent there"
|
|
107
|
+
)
|
|
108
|
+
return problems
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def is_scale_measure(original: FormalContext, scale: FormalContext) -> bool:
|
|
112
|
+
"""Whether ``scale`` is a scale-measure of ``original`` (see ``scale_measure_problems``)."""
|
|
113
|
+
return not scale_measure_problems(original, scale)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def _extents_by_name(view: FormalContext | ConceptLattice) -> tuple[tuple, set[frozenset]]:
|
|
117
|
+
if isinstance(view, ConceptLattice):
|
|
118
|
+
if view.is_iceberg:
|
|
119
|
+
raise ValueError("refines() needs full lattices, not iceberg lattices.")
|
|
120
|
+
lattice = view
|
|
121
|
+
else:
|
|
122
|
+
lattice = ConceptLattice.from_context(view)
|
|
123
|
+
objects = lattice.context.objects
|
|
124
|
+
return objects, {frozenset(objects[i] for i in concept.extent) for concept in lattice.concepts}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def refines(
|
|
128
|
+
coarse: FormalContext | ConceptLattice,
|
|
129
|
+
fine: FormalContext | ConceptLattice,
|
|
130
|
+
) -> bool:
|
|
131
|
+
"""
|
|
132
|
+
Whether every extent of ``coarse`` is an extent of ``fine``.
|
|
133
|
+
|
|
134
|
+
Then every concept of the coarser view is a concept of the finer one,
|
|
135
|
+
matched by its extent, and the two form a *refinement pair*. Both must
|
|
136
|
+
have the same objects (matched by name); contexts or full concept
|
|
137
|
+
lattices can be given, a lattice saving its recomputation.
|
|
138
|
+
"""
|
|
139
|
+
coarse_objects, coarse_extents = _extents_by_name(coarse)
|
|
140
|
+
fine_objects, fine_extents = _extents_by_name(fine)
|
|
141
|
+
if set(coarse_objects) != set(fine_objects):
|
|
142
|
+
raise ValueError("refines() compares views of the same objects; these differ.")
|
|
143
|
+
return coarse_extents <= fine_extents
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from conceptflow.metrics.drawing_quality import (
|
|
2
|
+
bottleneck_clearance_radius,
|
|
3
|
+
crossing_angle_score,
|
|
4
|
+
drawing_quality_scores,
|
|
5
|
+
edge_crossing_score,
|
|
6
|
+
edge_edge_conflict_score,
|
|
7
|
+
edge_length_uniformity_score,
|
|
8
|
+
layer_consistency_score,
|
|
9
|
+
nested_suitability_score,
|
|
10
|
+
node_edge_conflict_score,
|
|
11
|
+
node_node_conflict_score,
|
|
12
|
+
slope_economy_score,
|
|
13
|
+
slope_parallelism_score,
|
|
14
|
+
slope_standard_score,
|
|
15
|
+
slope_verticality_score,
|
|
16
|
+
vertical_axis_balance_score,
|
|
17
|
+
visual_chain_linearity_score,
|
|
18
|
+
)
|
|
19
|
+
from conceptflow.metrics.measures import (
|
|
20
|
+
concept_entropy,
|
|
21
|
+
concept_information_gain,
|
|
22
|
+
concept_levels,
|
|
23
|
+
concept_stability,
|
|
24
|
+
delta_measure,
|
|
25
|
+
distributivity_index,
|
|
26
|
+
incomparable_pairs,
|
|
27
|
+
lattice_height,
|
|
28
|
+
lattice_width,
|
|
29
|
+
linearity_index,
|
|
30
|
+
stability_bounds,
|
|
31
|
+
)
|
|
32
|
+
from conceptflow.metrics.rules import (
|
|
33
|
+
attribute_set_support,
|
|
34
|
+
concept_support,
|
|
35
|
+
implication_confidence,
|
|
36
|
+
implication_exceptions,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
__all__ = [
|
|
40
|
+
"concept_support",
|
|
41
|
+
"attribute_set_support",
|
|
42
|
+
"implication_confidence",
|
|
43
|
+
"implication_exceptions",
|
|
44
|
+
"concept_stability",
|
|
45
|
+
"stability_bounds",
|
|
46
|
+
"delta_measure",
|
|
47
|
+
"concept_entropy",
|
|
48
|
+
"concept_information_gain",
|
|
49
|
+
"linearity_index",
|
|
50
|
+
"distributivity_index",
|
|
51
|
+
"concept_levels",
|
|
52
|
+
"lattice_width",
|
|
53
|
+
"lattice_height",
|
|
54
|
+
"incomparable_pairs",
|
|
55
|
+
"visual_chain_linearity_score",
|
|
56
|
+
"node_node_conflict_score",
|
|
57
|
+
"node_edge_conflict_score",
|
|
58
|
+
"edge_edge_conflict_score",
|
|
59
|
+
"edge_crossing_score",
|
|
60
|
+
"crossing_angle_score",
|
|
61
|
+
"edge_length_uniformity_score",
|
|
62
|
+
"layer_consistency_score",
|
|
63
|
+
"slope_economy_score",
|
|
64
|
+
"slope_parallelism_score",
|
|
65
|
+
"slope_standard_score",
|
|
66
|
+
"slope_verticality_score",
|
|
67
|
+
"nested_suitability_score",
|
|
68
|
+
"vertical_axis_balance_score",
|
|
69
|
+
"bottleneck_clearance_radius",
|
|
70
|
+
"drawing_quality_scores",
|
|
71
|
+
]
|