aggregationslib 0.2.7__tar.gz → 0.2.8__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.

Potentially problematic release.


This version of aggregationslib might be problematic. Click here for more details.

Files changed (103) hide show
  1. aggregationslib-0.2.8/AGENTS.md +7 -0
  2. {aggregationslib-0.2.7/aggregationslib.egg-info → aggregationslib-0.2.8}/PKG-INFO +8 -1
  3. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/README.pl.md +1 -1
  4. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/README.rst +14 -7
  5. {aggregationslib-0.2.7 → aggregationslib-0.2.8/aggregationslib.egg-info}/PKG-INFO +8 -1
  6. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib.egg-info/SOURCES.txt +4 -0
  7. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib.egg-info/scm_file_list.json +4 -0
  8. aggregationslib-0.2.8/aggregationslib.egg-info/scm_version.json +8 -0
  9. aggregationslib-0.2.8/apps/shiny/README.md +71 -0
  10. aggregationslib-0.2.8/apps/shiny/README.pl.md +71 -0
  11. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/apps/shiny/app.py +215 -19
  12. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/apps/shiny/core.py +107 -6
  13. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/build_docs.ps1 +2 -2
  14. aggregationslib-0.2.8/docs/CNAME +1 -0
  15. aggregationslib-0.2.8/docs/assets/means-icon.svg +20 -0
  16. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/site.css +188 -185
  17. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/en/index.html +81 -80
  18. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/pl/index.html +81 -80
  19. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/tests/test_shiny_app.py +51 -1
  20. aggregationslib-0.2.7/aggregationslib.egg-info/scm_version.json +0 -8
  21. aggregationslib-0.2.7/apps/shiny/README.md +0 -118
  22. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/.gitignore +0 -0
  23. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/LICENSE +0 -0
  24. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/README.md +0 -0
  25. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregation_classification.html +0 -0
  26. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib/__init__.py +0 -0
  27. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib/aggregation.py +0 -0
  28. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib/aggregations.py +0 -0
  29. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib/cli.py +0 -0
  30. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib/conjuctive/__init__.py +0 -0
  31. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib/conjuctive/purepython.py +0 -0
  32. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib/decimalaggregations.py +0 -0
  33. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib/disjunctive/__init__.py +0 -0
  34. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib/example.py +0 -0
  35. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib/feature_selection/__init__.py +0 -0
  36. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib/feature_selection/binary_fuzzy_entropy.py +0 -0
  37. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib/feature_selection/fuzzy_com_entropy.py +0 -0
  38. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib/models/__init__.py +0 -0
  39. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib/models/ensemble/__init__.py +0 -0
  40. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib/models/ensemble/aggregation_regressor.py +0 -0
  41. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib/models/single/__init__.py +0 -0
  42. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib/ndarray.py +0 -0
  43. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib/purepython.py +0 -0
  44. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib.egg-info/dependency_links.txt +0 -0
  45. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib.egg-info/entry_points.txt +0 -0
  46. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib.egg-info/requires.txt +0 -0
  47. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/aggregationslib.egg-info/top_level.txt +0 -0
  48. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/apps/shiny/column-selection.js +0 -0
  49. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/apps/shiny/evaluation.py +0 -0
  50. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/apps/shiny/example.csv +0 -0
  51. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/assets/icons/icon.ico +0 -0
  52. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/assets/icons/icon.png +0 -0
  53. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/assets/icons/icon.svg +0 -0
  54. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/commands.md +0 -0
  55. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/diagram-aggregation-classification.svg +0 -0
  56. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/diagram-implikacja-agregacja.svg +0 -0
  57. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/diagram-klasyfikacja-agregacji.svg +0 -0
  58. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/diagram-odwzorowanie.svg +0 -0
  59. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/.nojekyll +0 -0
  60. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/aggregation-classes.md +0 -0
  61. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/aggregation-plots.md +0 -0
  62. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/aggregation_classification.html +0 -0
  63. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/aggregation-surfaces-all.png +0 -0
  64. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/aggregation-surfaces.png +0 -0
  65. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/aggregations/A_amn_p=0.5.png +0 -0
  66. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/aggregations/A_amx_p=0.5.png +0 -0
  67. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/aggregations/A_ar.png +0 -0
  68. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/aggregations/A_ex2_p=2,q=2.png +0 -0
  69. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/aggregations/A_ex3_p=2,q=1.5.png +0 -0
  70. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/aggregations/A_ex_r=1.png +0 -0
  71. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/aggregations/A_gm.png +0 -0
  72. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/aggregations/A_hm.png +0 -0
  73. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/aggregations/A_lm_r=2.png +0 -0
  74. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/aggregations/A_lo.png +0 -0
  75. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/aggregations/A_md.png +0 -0
  76. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/aggregations/A_mn.png +0 -0
  77. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/aggregations/A_mx.png +0 -0
  78. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/aggregations/A_ol.png +0 -0
  79. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/aggregations/A_oln_p=1.png +0 -0
  80. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/aggregations/A_pr.png +0 -0
  81. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/aggregations/A_pw_r=2.png +0 -0
  82. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/aggregations/A_qd.png +0 -0
  83. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/diagram-aggregation-classification.svg +0 -0
  84. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/assets/diagram-klasyfikacja-agregacji.svg +0 -0
  85. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/fuzzy-integrals.md +0 -0
  86. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/index.html +0 -0
  87. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/docs/klasyfikacja_agregacji.html +0 -0
  88. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/generate_aggregation_plots.py +0 -0
  89. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/klasyfikacja_agregacji.html +0 -0
  90. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/pyproject.toml +0 -0
  91. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/setup.cfg +0 -0
  92. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/tests/__init__.py +0 -0
  93. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/tests/data/README.md +0 -0
  94. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/tests/data/wolfram_integral_reference.json +0 -0
  95. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/tests/data/wolfram_measure_reference.json +0 -0
  96. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/tests/test_aggregations.py +0 -0
  97. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/tests/test_decimal_exponential_mean.py +0 -0
  98. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/tests/test_decimal_fuzzy_integrals.py +0 -0
  99. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/tests/test_exponential_cardinality.py +0 -0
  100. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/tests/test_fuzzy_integrals.py +0 -0
  101. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/tests/test_ndarray.py +0 -0
  102. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/tests/test_shiny_evaluation.py +0 -0
  103. {aggregationslib-0.2.7 → aggregationslib-0.2.8}/tests/test_wolfram_measures.py +0 -0
@@ -0,0 +1,7 @@
1
+ # Słowniczek projektu
2
+
3
+ Stosuj poniższe formy w polskiej dokumentacji, na stronie projektu i w interfejsie.
4
+
5
+ | Stosuj | Zamiast |
6
+ | --- | --- |
7
+ | Funkcje agregacji dla Python | Funkcje agregacji dla Pythona |
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aggregationslib
3
- Version: 0.2.7
3
+ Version: 0.2.8
4
4
  Summary: Python implementation of Arithmetic, quasi arithmetic and other aggregating functions
5
5
  Author: wgalka
6
6
  Project-URL: Homepage, https://github.com/wgalka/Means
@@ -35,6 +35,13 @@ Documentation:
35
35
  - English: https://wgalka.github.io/Means/en/
36
36
  - Polski: https://wgalka.github.io/Means/pl/
37
37
 
38
+ **Table of contents**
39
+
40
+ - `Example 1 <#example-1>`__
41
+ - `Example 2 <#example2>`__
42
+ - `Aggregation functions <#aggregation-functions>`__
43
+ - `References <#references>`__
44
+
38
45
  Aggregation functions can be classified in several ways. A familiar distinction
39
46
  is between three types of behaviour:
40
47
 
@@ -1,6 +1,6 @@
1
1
  # Means
2
2
 
3
- Means to biblioteka funkcji agregacji dla języka Python.
3
+ Means to biblioteka, która udostępnia funkcje agregacji dla Python.
4
4
 
5
5
  Dokumentacja:
6
6
 
@@ -8,6 +8,13 @@ Documentation:
8
8
  - English: https://wgalka.github.io/Means/en/
9
9
  - Polski: https://wgalka.github.io/Means/pl/
10
10
 
11
+ **Table of contents**
12
+
13
+ - `Example 1 <#example-1>`__
14
+ - `Example 2 <#example2>`__
15
+ - `Aggregation functions <#aggregation-functions>`__
16
+ - `References <#references>`__
17
+
11
18
  Aggregation functions can be classified in several ways. A familiar distinction
12
19
  is between three types of behaviour:
13
20
 
@@ -17,13 +24,13 @@ is between three types of behaviour:
17
24
 
18
25
  These are not the only possibilities: aggregation functions can also exhibit
19
26
  mixed behaviour. The diagram below presents a broader classification.
20
-
21
- .. image:: https://raw.githubusercontent.com/wgalka/Means/main/docs/assets/diagram-aggregation-classification.svg
22
- :alt: Classification of aggregation functions
23
- :target: https://wgalka.github.io/Means/aggregation_classification.html
24
-
25
- *Diagram elaborated on the basis of: A. Pradera, G. Beliakov, H. Bustince, B. De Baets, "A review of the relationships between implication, negation and aggregation functions from the point of view of material implication", Information Sciences 329 (2016) 357–380,* `DOI: 10.1016/j.ins.2015.09.033 <https://doi.org/10.1016/j.ins.2015.09.033>`__.
26
-
27
+
28
+ .. image:: https://raw.githubusercontent.com/wgalka/Means/main/docs/assets/diagram-aggregation-classification.svg
29
+ :alt: Classification of aggregation functions
30
+ :target: https://wgalka.github.io/Means/aggregation_classification.html
31
+
32
+ *Diagram elaborated on the basis of: A. Pradera, G. Beliakov, H. Bustince, B. De Baets, "A review of the relationships between implication, negation and aggregation functions from the point of view of material implication", Information Sciences 329 (2016) 357–380,* `DOI: 10.1016/j.ins.2015.09.033 <https://doi.org/10.1016/j.ins.2015.09.033>`__.
33
+
27
34
  An interactive version of this diagram is available at: https://wgalka.github.io/Means/aggregation_classification.html
28
35
 
29
36
  Example 1:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aggregationslib
3
- Version: 0.2.7
3
+ Version: 0.2.8
4
4
  Summary: Python implementation of Arithmetic, quasi arithmetic and other aggregating functions
5
5
  Author: wgalka
6
6
  Project-URL: Homepage, https://github.com/wgalka/Means
@@ -35,6 +35,13 @@ Documentation:
35
35
  - English: https://wgalka.github.io/Means/en/
36
36
  - Polski: https://wgalka.github.io/Means/pl/
37
37
 
38
+ **Table of contents**
39
+
40
+ - `Example 1 <#example-1>`__
41
+ - `Example 2 <#example2>`__
42
+ - `Aggregation functions <#aggregation-functions>`__
43
+ - `References <#references>`__
44
+
38
45
  Aggregation functions can be classified in several ways. A familiar distinction
39
46
  is between three types of behaviour:
40
47
 
@@ -1,4 +1,5 @@
1
1
  .gitignore
2
+ AGENTS.md
2
3
  LICENSE
3
4
  README.md
4
5
  README.pl.md
@@ -40,6 +41,7 @@ aggregationslib/models/ensemble/__init__.py
40
41
  aggregationslib/models/ensemble/aggregation_regressor.py
41
42
  aggregationslib/models/single/__init__.py
42
43
  apps/shiny/README.md
44
+ apps/shiny/README.pl.md
43
45
  apps/shiny/app.py
44
46
  apps/shiny/column-selection.js
45
47
  apps/shiny/core.py
@@ -49,6 +51,7 @@ assets/icons/icon.ico
49
51
  assets/icons/icon.png
50
52
  assets/icons/icon.svg
51
53
  docs/.nojekyll
54
+ docs/CNAME
52
55
  docs/aggregation-classes.md
53
56
  docs/aggregation-plots.md
54
57
  docs/aggregation_classification.html
@@ -59,6 +62,7 @@ docs/assets/aggregation-surfaces-all.png
59
62
  docs/assets/aggregation-surfaces.png
60
63
  docs/assets/diagram-aggregation-classification.svg
61
64
  docs/assets/diagram-klasyfikacja-agregacji.svg
65
+ docs/assets/means-icon.svg
62
66
  docs/assets/site.css
63
67
  docs/assets/aggregations/A_amn_p=0.5.png
64
68
  docs/assets/aggregations/A_amx_p=0.5.png
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "files": [
3
3
  ".gitignore",
4
+ "AGENTS.md",
4
5
  "LICENSE",
5
6
  "README.md",
6
7
  "README.pl.md",
@@ -25,6 +26,7 @@
25
26
  "aggregationslib\\ndarray.py",
26
27
  "aggregationslib\\purepython.py",
27
28
  "apps\\shiny\\README.md",
29
+ "apps\\shiny\\README.pl.md",
28
30
  "apps\\shiny\\app.py",
29
31
  "apps\\shiny\\column-selection.js",
30
32
  "apps\\shiny\\core.py",
@@ -40,6 +42,7 @@
40
42
  "diagram-klasyfikacja-agregacji.svg",
41
43
  "diagram-odwzorowanie.svg",
42
44
  "docs\\.nojekyll",
45
+ "docs\\CNAME",
43
46
  "docs\\aggregation-classes.md",
44
47
  "docs\\aggregation-plots.md",
45
48
  "docs\\aggregation_classification.html",
@@ -65,6 +68,7 @@
65
68
  "docs\\assets\\aggregations\\A_qd.png",
66
69
  "docs\\assets\\diagram-aggregation-classification.svg",
67
70
  "docs\\assets\\diagram-klasyfikacja-agregacji.svg",
71
+ "docs\\assets\\means-icon.svg",
68
72
  "docs\\assets\\site.css",
69
73
  "docs\\en\\index.html",
70
74
  "docs\\fuzzy-integrals.md",
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "0.2.8",
3
+ "distance": 0,
4
+ "node": "gd082fac750952f4b15edfe12e04f562050baf005",
5
+ "dirty": false,
6
+ "branch": "main",
7
+ "node_date": "2026-11-16"
8
+ }
@@ -0,0 +1,71 @@
1
+ # Shiny App
2
+
3
+ Graphical interface for computing aggregation functions on tabular data and evaluating binary classification.
4
+
5
+ *Wersja polska: [README.pl.md](README.pl.md)*
6
+
7
+ ## Getting Started
8
+
9
+ Install the library from the repository root:
10
+
11
+ ```powershell
12
+ python -m pip install .
13
+ ```
14
+
15
+ Launch the application with:
16
+
17
+ ```powershell
18
+ agglib start
19
+ ```
20
+
21
+ If the environment is missing packages required by the interface (`shiny`, `pandas`, `matplotlib`, `scikit-learn`, `pygments`), the CLI will ask whether to install them:
22
+
23
+ ```text
24
+ Install the graphical interface? [Y/n]
25
+ ```
26
+
27
+ You can also install all dependencies upfront:
28
+
29
+ ```powershell
30
+ python -m pip install ".[app]"
31
+ ```
32
+
33
+ The `agglib serve` command works identically to `agglib start`. Press `Ctrl+C` to stop the server.
34
+
35
+ > **Test mode:** Appending `?tester=1` to the browser URL (e.g. `http://127.0.0.1:8000/?tester=1`) automatically loads the sample dataset `example.csv` along with ground truth labels.
36
+
37
+ ## Working with Data
38
+
39
+ 1. **Upload a file** – upload a CSV file and choose the column separator and decimal separator. Each row is treated as a separate vector to aggregate.
40
+ 2. **Additional vectors** – in the collapsible *Additional vectors* section, you can enter custom rows (one vector per line, space-separated values, dot as the decimal separator).
41
+ 3. **Column selection** – in the data preview, use the checkboxes in column headers to select which columns to include in calculations (text columns such as identifiers should be unchecked). Clicking a column name sorts the table preview.
42
+
43
+ By default, the preview shows the first 5 and last 5 rows (`5 … 5`), with an option to switch to the full table (`All rows`, capped at 2,000 rows in the browser view). Sorting and truncating the preview do not affect the row order in calculations or exports.
44
+
45
+ Uploaded CSV files are validated before loading (up to 20 MB and 100,000 rows), and each task checks estimated memory usage and method complexity before entering the queue. Aggregations run asynchronously in a bounded background queue with a live progress bar.
46
+
47
+ ## Aggregations and Weights
48
+
49
+ All 20 aggregation functions from `aggregationslib.ndarray` are available, including the Choquet (`A_ch`) and Sugeno (`A_sg`) fuzzy integrals with six types of measures:
50
+
51
+ - **weighted** and **k-fuzzy** – weight inputs appear directly above the selected columns (for the weighted measure, weights must sum to 1).
52
+ - **owa** – weights are assigned to positions after sorting values from largest to smallest (weights must sum to 1).
53
+ - **exponential_cardinality** – takes a single parameter $q > 0$.
54
+ - **uniform** and **relative** – measures that do not require additional weights.
55
+
56
+ Because measure constructors generate subsets, the `weighted`, `owa`, and `k-fuzzy` variants are limited to 12 selected columns in the interface. Input data are not automatically normalized, and missing values (`NaN`) or infinite values in selected columns are reported as errors.
57
+
58
+ At the bottom of the form, you can download the resulting CSV file (containing the original columns plus the computed result) as well as ready-to-run, standalone Python code reproducing the calculations.
59
+
60
+ ## Classification Evaluation
61
+
62
+ In the *Ground truth labels* section, you can provide true class labels (by pasting them as text or uploading a CSV file) to evaluate binary classification based on the aggregation scores:
63
+
64
+ - Labels must match the data rows in order (including manually appended vectors) and contain exactly two classes.
65
+ - Specify the positive class label (default `1`) and choose whether a higher aggregation score indicates the positive or negative class.
66
+
67
+ Once labels are provided, the application computes:
68
+ - **ROC curve** together with the area under the curve (ROC AUC),
69
+ - **Optimal cutoff threshold ($t$)** according to the selected criterion: Youden's index ($J = \text{TPR} - \text{FPR}$), Accuracy, or F1 score. The threshold can also be set manually in *Manual* mode,
70
+ - **Metrics summary**: Average Precision, Accuracy, Balanced Accuracy, Precision, Recall, Specificity, NPV, F1 (for the positive class as well as micro/macro/weighted variants), MCC, and Cohen's $\kappa$ (metric names in the table link to `scikit-learn` documentation),
71
+ - **Confusion matrices** displayed as heatmaps (raw counts and row-normalized percentages per true class).
@@ -0,0 +1,71 @@
1
+ # Aplikacja Shiny
2
+
3
+ Graficzny interfejs do obliczania funkcji agregacji na danych tabelarycznych oraz oceny klasyfikacji binarnej.
4
+
5
+ *English version: [README.md](README.md)*
6
+
7
+ ## Uruchomienie
8
+
9
+ Zainstaluj bibliotekę z katalogu głównego repozytorium:
10
+
11
+ ```powershell
12
+ python -m pip install .
13
+ ```
14
+
15
+ Uruchom aplikację poleceniem:
16
+
17
+ ```powershell
18
+ agglib start
19
+ ```
20
+
21
+ Jeśli w środowisku brakuje pakietów wymaganych przez interfejs (`shiny`, `pandas`, `matplotlib`, `scikit-learn`, `pygments`), CLI zapyta o ich doinstalowanie:
22
+
23
+ ```text
24
+ Install the graphical interface? [Y/n]
25
+ ```
26
+
27
+ Możesz też zainstalować wszystkie zależności od razu:
28
+
29
+ ```powershell
30
+ python -m pip install ".[app]"
31
+ ```
32
+
33
+ Polecenie `agglib serve` działa analogicznie do `agglib start`. Serwer zatrzymuje się skrótem `Ctrl+C`.
34
+
35
+ > **Tryb testowy:** Dopisanie `?tester=1` do adresu w przeglądarce (np. `http://127.0.0.1:8000/?tester=1`) automatycznie wczytuje przykładowy zbiór `example.csv` wraz z wektorem decyzji.
36
+
37
+ ## Praca z danymi
38
+
39
+ 1. **Wczytanie pliku** – wgraj plik CSV i dobierz separator kolumn oraz separator dziesiętny. Każdy wiersz traktowany jest jako osobny wektor do agregacji.
40
+ 2. **Dodatkowe wektory** – w rozwijanej sekcji *Additional vectors* możesz dopisać własne wiersze (jeden wektor na linię, wartości oddzielone spacją, kropka jako separator dziesiętny).
41
+ 3. **Wybór kolumn** – w podglądzie danych zaznacz checkboxy w nagłówkach kolumn, które mają wejść do obliczeń (kolumny tekstowe, np. identyfikatory, należy odznaczyć). Kliknięcie samej nazwy kolumny sortuje podgląd tabeli.
42
+
43
+ Podgląd domyślnie pokazuje 5 pierwszych i 5 ostatnich wierszy (`5 … 5`), z możliwością przełączenia na pełną tabelę (`All rows`, ograniczoną w widoku przeglądarki do 2 000 wierszy). Sortowanie i skracanie widoku nie wpływa na kolejność wierszy w obliczeniach ani w eksporcie.
44
+
45
+ Wgrywane pliki CSV są weryfikowane jeszcze przed wczytaniem do pamięci (limit 20 MB oraz 100 000 wierszy), a przed dodaniem zadania do kolejki aplikacja szacuje zapotrzebowanie na pamięć i złożoność obliczeniową wybranej metody. Obliczenia wykonują się asynchronicznie w ograniczonej kolejce zadań z paskiem postępu.
46
+
47
+ ## Agregacje i wagi
48
+
49
+ Dostępnych jest 20 funkcji agregacji z modułu `aggregationslib.ndarray`, w tym całki rozmyte Choqueta (`A_ch`) i Sugeno (`A_sg`) z sześcioma rodzajami miar:
50
+
51
+ - **weighted** oraz **k-fuzzy** – pola na wagi pojawiają się bezpośrednio nad zaznaczonymi kolumnami (dla miary ważonej wagi muszą sumować się do 1).
52
+ - **owa** – wagi przypisywane są kolejnym pozycjom po uporządkowaniu wartości od największej (suma wag równa 1).
53
+ - **exponential_cardinality** – przyjmuje pojedynczy parametr $q > 0$.
54
+ - **uniform** oraz **relative** – miary niewymagające dodatkowych wag.
55
+
56
+ Ze względu na generowanie podzbiorów w konstruktorach miar, dla wariantów `weighted`, `owa` i `k-fuzzy` w interfejsie obowiązuje limit 12 zaznaczonych kolumn. Dane wejściowe nie są automatycznie normalizowane, a braki danych (`NaN`) lub wartości nieskończone w wybranych kolumnach zostaną zgłoszone jako błąd.
57
+
58
+ Na dole formularza można pobrać wynikowy plik CSV (zawierający oryginalne kolumny powiększone o kolumnę z wynikiem) oraz gotowy, samodzielny kod w Pythonie odtwarzający obliczenia.
59
+
60
+ ## Ocena klasyfikacji
61
+
62
+ W sekcji *Ground truth labels* można podać rzeczywiste etykiety klas (wklejając je jako tekst lub wgrywając z pliku CSV), aby ocenić jakość klasyfikacji opartej na wynikach agregacji:
63
+
64
+ - Etykiety muszą odpowiadać kolejnym wierszom danych (wliczając dopisane ręcznie wektory) i zawierać dokładnie dwie klasy.
65
+ - Należy wskazać etykietę klasy dodatniej (domyślnie `1`) oraz określić, czy wyższy wynik agregacji oznacza klasę dodatnią, czy ujemną.
66
+
67
+ Po podaniu etykiet aplikacja wyznacza:
68
+ - **Krzywą ROC** wraz z polem pod krzywą (ROC AUC),
69
+ - **Optymalny próg odcięcia ($t$)** według wybranego kryterium: indeksu Youdena ($J = \text{TPR} - \text{FPR}$), dokładności (Accuracy) lub miary F1. Próg można też ustawić ręcznie w trybie *Manual*,
70
+ - **Zestaw metryk**: Average Precision, Accuracy, Balanced Accuracy, Precision, Recall, Specificity, NPV, F1 (dla klasy dodatniej oraz warianty micro/macro/weighted), MCC i współczynnik $\kappa$ Cohena (nazwy metryk w tabeli linkują do dokumentacji `scikit-learn`),
71
+ - **Macierze pomyłek** w postaci map ciepła (liczności oraz udziały procentowe w klasach rzeczywistych).
@@ -1,4 +1,6 @@
1
1
  """Run from the repository root: python -m shiny run apps/shiny/app.py"""
2
+ import asyncio
3
+ from concurrent.futures import ThreadPoolExecutor
2
4
  from pathlib import Path
3
5
  import math
4
6
  import textwrap
@@ -11,11 +13,33 @@ from pygments.formatters import HtmlFormatter
11
13
  from pygments.lexers import PythonLexer
12
14
  from shiny import App, reactive, render, ui
13
15
 
14
- from apps.shiny.core import AGGREGATIONS, MEASURES, PARAMETERS, calculate, header_weight_vector, grid_view
16
+ from apps.shiny.core import (
17
+ AGGREGATIONS,
18
+ MEASURES,
19
+ PARAMETERS,
20
+ calculate,
21
+ estimate_workload,
22
+ grid_view,
23
+ header_weight_vector,
24
+ validate_csv_upload,
25
+ )
15
26
  from apps.shiny.evaluation import CRITERIA, METRIC_DOCS, evaluate, text_decisions
16
27
 
17
28
  EXAMPLE = Path(__file__).with_name('example.csv')
18
29
  CODE_FORMATTER = HtmlFormatter(cssclass='python-code', style='friendly')
30
+ MAX_WORKERS = 2
31
+ MAX_QUEUED_TASKS = 6
32
+ COMPUTATION_EXECUTOR = ThreadPoolExecutor(max_workers=MAX_WORKERS, thread_name_prefix='agg-worker')
33
+ _COMPUTATION_SEMAPHORE = None
34
+ _QUEUED_TASKS = 0
35
+ _ACTIVE_TASKS = 0
36
+
37
+
38
+ def get_computation_semaphore():
39
+ global _COMPUTATION_SEMAPHORE
40
+ if _COMPUTATION_SEMAPHORE is None:
41
+ _COMPUTATION_SEMAPHORE = asyncio.Semaphore(MAX_WORKERS)
42
+ return _COMPUTATION_SEMAPHORE
19
43
 
20
44
 
21
45
  def view_picker(id, label):
@@ -107,6 +131,10 @@ app_ui = ui.page_fluid(
107
131
  ui.output_ui('weight_hint'),
108
132
  view_picker('preview_view', 'Input view'), ui.output_data_frame('preview')),
109
133
 
134
+ ui.div(
135
+ ui.input_task_button('run_calc', 'Run aggregation', label_busy='Calculating…', class_='btn-primary'),
136
+ class_='d-flex align-items-center gap-2',
137
+ ),
110
138
  ui.output_ui('status'),
111
139
  ui.card(ui.card_header('5. Aggregation results'),
112
140
  ui.help_text('The default view shows the first and last five rows. Sorting applies to all results.'),
@@ -142,6 +170,11 @@ def server(input, output, session):
142
170
  selected_columns = reactive.value([])
143
171
  weight_values = reactive.value({})
144
172
  sort_states = reactive.value({})
173
+ data_version = reactive.value(0)
174
+ last_completed_sig = reactive.value(None)
175
+ in_flight_sig = reactive.value(None)
176
+ initial_triggered = reactive.value(False)
177
+ progress_state = {'phase': 'idle', 'done': 0, 'total': 0}
145
178
 
146
179
  @reactive.calc
147
180
  def tester_mode():
@@ -163,6 +196,7 @@ def server(input, output, session):
163
196
  if file:
164
197
  if input.separator() == input.decimal():
165
198
  raise ValueError('The CSV delimiter and decimal separator must be different.')
199
+ validate_csv_upload(file[0]['datapath'])
166
200
  df = pd.read_csv(file[0]['datapath'], sep=input.separator(),
167
201
  decimal=input.decimal(), header=0 if input.header() else None)
168
202
  if not input.header():
@@ -243,25 +277,149 @@ def server(input, output, session):
243
277
  def select_none():
244
278
  selected_columns.set([])
245
279
 
246
- @reactive.calc
247
- def computation():
280
+ @reactive.effect
281
+ def _bump_data_version():
282
+ data()
283
+ with reactive.isolate():
284
+ data_version.set(data_version() + 1)
285
+
286
+ def current_request():
248
287
  df, error = data()
249
288
  if error:
250
- return None, '', error
289
+ return ('error', data_version(), error), None, error
290
+ name = input.aggregation()
291
+ params = {key: getattr(input, key)() for key in PARAMETERS.get(name, ())}
292
+ if name in ('A_ch', 'A_sg') and input.measure() == 'exponential_cardinality':
293
+ params['measure_q'] = input.measure_q()
294
+ columns = [column for column in df.columns if column in selected_columns()]
295
+ kind = weight_kind()
296
+ kind_weights = weight_values().get(kind, {}) if kind else {}
297
+ sig = (
298
+ data_version(),
299
+ tuple(columns),
300
+ input.extra(),
301
+ name,
302
+ tuple(sorted(params.items())),
303
+ input.measure(),
304
+ tuple((col, kind_weights.get(col, '')) for col in (columns if kind != 'owa' else [str(i + 1) for i in range(len(columns))])),
305
+ input.separator(),
306
+ input.decimal(),
307
+ input.header(),
308
+ bool(input.file()),
309
+ )
310
+ args = {
311
+ 'df': df,
312
+ 'columns': columns,
313
+ 'extra': input.extra(),
314
+ 'name': name,
315
+ 'params': params,
316
+ 'kind': kind,
317
+ 'kind_weights': kind_weights,
318
+ 'measure': input.measure(),
319
+ 'separator': input.separator(),
320
+ 'decimal': input.decimal(),
321
+ 'header': input.header(),
322
+ 'uploaded': bool(input.file()),
323
+ }
324
+ return sig, args, None
325
+
326
+ @reactive.extended_task
327
+ async def compute_task(sig, args, data_error, state):
328
+ global _QUEUED_TASKS, _ACTIVE_TASKS
329
+ if data_error:
330
+ return sig, None, '', data_error
331
+ if not args['columns']:
332
+ return sig, None, '', 'Select at least one column.'
333
+ try:
334
+ estimate_workload(args['df'], args['columns'], args['extra'], args['name'], args['measure'])
335
+ except ValueError as err:
336
+ return sig, None, '', str(err)
337
+ if _QUEUED_TASKS >= MAX_QUEUED_TASKS:
338
+ return sig, None, '', 'Server is busy (task queue is full). Please wait a moment and try again.'
339
+
340
+ def run_sync():
341
+ def on_progress(done, total):
342
+ state['done'] = done
343
+ state['total'] = total
344
+
345
+ weights = header_weight_vector(args['kind'], args['columns'], args['kind_weights']) if args['kind'] else ''
346
+ return calculate(
347
+ args['df'], args['columns'], args['extra'], args['name'], args['params'],
348
+ args['measure'], weights, args['separator'], args['decimal'],
349
+ args['header'], args['uploaded'], on_progress=on_progress,
350
+ )
351
+
352
+ state['phase'] = 'queued'
353
+ state['done'] = 0
354
+ state['total'] = len(args['df'])
355
+ _QUEUED_TASKS += 1
356
+ semaphore = get_computation_semaphore()
251
357
  try:
252
- name = input.aggregation()
253
- params = {key: getattr(input, key)() for key in PARAMETERS.get(name, ())}
254
- if name in ('A_ch', 'A_sg') and input.measure() == 'exponential_cardinality':
255
- params['measure_q'] = input.measure_q()
256
- columns = [column for column in df.columns if column in selected_columns()]
257
- kind = weight_kind()
258
- weights = header_weight_vector(kind, columns, weight_values().get(kind, {})) if kind else ''
259
- result, code = calculate(df, columns, input.extra(), name, params,
260
- input.measure(), weights, input.separator(),
261
- input.decimal(), input.header(), bool(input.file()))
262
- return result, code, None
263
- except (ValueError, TypeError, ArithmeticError, KeyError) as error:
264
- return None, '', str(error)
358
+ async with semaphore:
359
+ _QUEUED_TASKS -= 1
360
+ _ACTIVE_TASKS += 1
361
+ state['phase'] = 'running'
362
+ try:
363
+ loop = asyncio.get_running_loop()
364
+ result, code = await loop.run_in_executor(COMPUTATION_EXECUTOR, run_sync)
365
+ return sig, result, code, None
366
+ except (ValueError, TypeError, ArithmeticError, KeyError) as err:
367
+ return sig, None, '', str(err)
368
+ finally:
369
+ _ACTIVE_TASKS -= 1
370
+ state['phase'] = 'idle'
371
+ except BaseException:
372
+ if state['phase'] == 'queued':
373
+ _QUEUED_TASKS -= 1
374
+ state['phase'] = 'idle'
375
+ raise
376
+
377
+ def start_computation(notify_duplicate=False):
378
+ sig, args, data_error = current_request()
379
+ with reactive.isolate():
380
+ if sig == in_flight_sig():
381
+ if notify_duplicate:
382
+ ui.notification_show('This calculation is already running.', type='warning', duration=3)
383
+ return
384
+ if sig == last_completed_sig():
385
+ if notify_duplicate:
386
+ ui.notification_show('Results for these exact parameters are already up to date.', type='message', duration=3)
387
+ return
388
+ in_flight_sig.set(sig)
389
+ ui.update_task_button('run_calc', state='busy')
390
+ compute_task(sig, args, data_error, progress_state)
391
+
392
+ @reactive.effect
393
+ def auto_run_initial():
394
+ if not initial_triggered() and selected_columns():
395
+ initial_triggered.set(True)
396
+ start_computation(notify_duplicate=False)
397
+
398
+ @reactive.effect
399
+ @reactive.event(input.run_calc)
400
+ def trigger_computation():
401
+ start_computation(notify_duplicate=True)
402
+
403
+ @reactive.effect
404
+ def sync_task_state():
405
+ status = compute_task.status()
406
+ if status == 'success':
407
+ sig, _, _, error = compute_task.result()
408
+ with reactive.isolate():
409
+ last_completed_sig.set(sig if error is None else None)
410
+ if in_flight_sig() == sig:
411
+ in_flight_sig.set(None)
412
+ ui.update_task_button('run_calc', state='ready')
413
+ elif status == 'error':
414
+ with reactive.isolate():
415
+ last_completed_sig.set(None)
416
+ in_flight_sig.set(None)
417
+ ui.update_task_button('run_calc', state='ready')
418
+
419
+ @reactive.calc
420
+ def computation():
421
+ _, result, code, error = compute_task.result()
422
+ return result, code, error
265
423
 
266
424
  @reactive.calc
267
425
  def decision_data():
@@ -269,6 +427,7 @@ def server(input, output, session):
269
427
  files = input.decision_file()
270
428
  if not files:
271
429
  return pd.DataFrame(), None
430
+ validate_csv_upload(files[0]['datapath'])
272
431
  frame = pd.read_csv(files[0]['datapath'], sep=input.decision_separator(),
273
432
  header=0 if input.decision_header() else None,
274
433
  dtype=str, keep_default_na=False)
@@ -406,9 +565,46 @@ def server(input, output, session):
406
565
 
407
566
  @render.ui
408
567
  def status():
568
+ task_status = compute_task.status()
569
+ if task_status == 'running':
570
+ reactive.invalidate_later(0.15)
571
+ phase = progress_state['phase']
572
+ done = progress_state['done']
573
+ total = progress_state['total']
574
+ if phase == 'queued':
575
+ label = f'Waiting in queue… (active: {_ACTIVE_TASKS}/{MAX_WORKERS}, queued: {_QUEUED_TASKS})'
576
+ bar = ui.div(
577
+ ui.div(class_='progress-bar progress-bar-striped progress-bar-animated w-100',
578
+ role='progressbar'),
579
+ class_='progress mt-2', style='height: 10px;',
580
+ )
581
+ return ui.div(ui.div(label), bar, class_='alert alert-info mb-0', role='status')
582
+ pct = int(round(100 * done / total)) if total > 0 else 0
583
+ label = f'Calculating… {done:,} / {total:,} rows ({pct}%)'
584
+ bar = ui.div(
585
+ ui.div(class_='progress-bar progress-bar-striped progress-bar-animated',
586
+ role='progressbar',
587
+ style=f'width: {pct}%;',
588
+ aria_valuenow=str(pct), aria_valuemin='0', aria_valuemax='100'),
589
+ class_='progress mt-2', style='height: 10px;',
590
+ )
591
+ return ui.div(ui.div(label), bar, class_='alert alert-info mb-0', role='status')
592
+
593
+ if task_status == 'initial':
594
+ return ui.div('Select columns and click Run aggregation.', class_='alert alert-secondary mb-0', role='status')
595
+
409
596
  result, code, error = computation()
410
- return ui.div(error if error else f'Processed {len(result)} rows.',
411
- class_='alert alert-danger' if error else 'alert alert-success', role='status')
597
+ sig, _, _ = current_request()
598
+ stale = last_completed_sig() is not None and sig != last_completed_sig()
599
+ alert = ui.div(error if error else f'Processed {len(result):,} rows.',
600
+ class_='alert alert-danger mb-0' if error else 'alert alert-success mb-0', role='status')
601
+ if stale:
602
+ return ui.div(
603
+ alert,
604
+ ui.div('Parameters or data changed — click Run aggregation to update results.',
605
+ class_='alert alert-warning mt-2 mb-0', role='status'),
606
+ )
607
+ return alert
412
608
 
413
609
  @render.data_frame
414
610
  def results():