aggregationslib 0.2.2__tar.gz → 0.2.4__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.
Files changed (76) hide show
  1. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/.gitignore +1 -0
  2. {aggregationslib-0.2.2/aggregationslib.egg-info → aggregationslib-0.2.4}/PKG-INFO +65 -1
  3. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/README.md +58 -0
  4. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/README.rst +64 -0
  5. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib/__init__.py +12 -0
  6. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib/aggregation.py +175 -4
  7. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib/aggregations.py +16 -4
  8. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib/decimalaggregations.py +205 -10
  9. {aggregationslib-0.2.2 → aggregationslib-0.2.4/aggregationslib.egg-info}/PKG-INFO +65 -1
  10. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib.egg-info/SOURCES.txt +4 -0
  11. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib.egg-info/scm_file_list.json +4 -0
  12. aggregationslib-0.2.4/aggregationslib.egg-info/scm_version.json +8 -0
  13. aggregationslib-0.2.4/diagram-implikacja-agregacja.svg +111 -0
  14. aggregationslib-0.2.4/diagram-klasyfikacja-agregacji.svg +403 -0
  15. aggregationslib-0.2.4/diagram-odwzorowanie.svg +82 -0
  16. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/fuzzy-integrals.md +71 -0
  17. aggregationslib-0.2.4/klasyfikacja_agregacji.html +932 -0
  18. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/tests/test_decimal_fuzzy_integrals.py +106 -0
  19. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/tests/test_fuzzy_integrals.py +86 -0
  20. aggregationslib-0.2.2/aggregationslib.egg-info/scm_version.json +0 -8
  21. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/LICENSE +0 -0
  22. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/README.pl.md +0 -0
  23. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib/conjuctive/__init__.py +0 -0
  24. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib/conjuctive/purepython.py +0 -0
  25. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib/disjunctive/__init__.py +0 -0
  26. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib/example.py +0 -0
  27. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib/feature_selection/__init__.py +0 -0
  28. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib/feature_selection/binary_fuzzy_entropy.py +0 -0
  29. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib/feature_selection/fuzzy_com_entropy.py +0 -0
  30. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib/models/__init__.py +0 -0
  31. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib/models/ensemble/__init__.py +0 -0
  32. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib/models/ensemble/aggregation_regressor.py +0 -0
  33. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib/models/single/__init__.py +0 -0
  34. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib/purepython.py +0 -0
  35. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib.egg-info/dependency_links.txt +0 -0
  36. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib.egg-info/requires.txt +0 -0
  37. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/aggregationslib.egg-info/top_level.txt +0 -0
  38. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/assets/icons/icon.ico +0 -0
  39. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/assets/icons/icon.png +0 -0
  40. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/assets/icons/icon.svg +0 -0
  41. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/build_docs.ps1 +0 -0
  42. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/commands.md +0 -0
  43. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/.nojekyll +0 -0
  44. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/aggregation-classes.md +0 -0
  45. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/aggregation-plots.md +0 -0
  46. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/aggregation-surfaces-all.png +0 -0
  47. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/aggregation-surfaces.png +0 -0
  48. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/aggregations/A_amn_p=0.5.png +0 -0
  49. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/aggregations/A_amx_p=0.5.png +0 -0
  50. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/aggregations/A_ar.png +0 -0
  51. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/aggregations/A_ex2_p=2,q=2.png +0 -0
  52. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/aggregations/A_ex3_p=2,q=1.5.png +0 -0
  53. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/aggregations/A_ex_r=1.png +0 -0
  54. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/aggregations/A_gm.png +0 -0
  55. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/aggregations/A_hm.png +0 -0
  56. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/aggregations/A_lm_r=2.png +0 -0
  57. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/aggregations/A_lo.png +0 -0
  58. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/aggregations/A_md.png +0 -0
  59. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/aggregations/A_mn.png +0 -0
  60. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/aggregations/A_mx.png +0 -0
  61. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/aggregations/A_ol.png +0 -0
  62. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/aggregations/A_oln_p=1.png +0 -0
  63. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/aggregations/A_pr.png +0 -0
  64. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/aggregations/A_pw_r=2.png +0 -0
  65. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/aggregations/A_qd.png +0 -0
  66. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/assets/site.css +0 -0
  67. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/en/index.html +0 -0
  68. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/index.html +0 -0
  69. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/docs/pl/index.html +0 -0
  70. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/generate_aggregation_plots.py +0 -0
  71. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/pyproject.toml +0 -0
  72. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/setup.cfg +0 -0
  73. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/tests/__init__.py +0 -0
  74. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/tests/data/wolfram_integral_reference.json +0 -0
  75. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/tests/test_aggregations.py +0 -0
  76. {aggregationslib-0.2.2 → aggregationslib-0.2.4}/tests/test_decimal_exponential_mean.py +0 -0
@@ -130,3 +130,4 @@ dmypy.json
130
130
 
131
131
  # Local scratch files and generated temporary data
132
132
  /tmp/
133
+ /output/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aggregationslib
3
- Version: 0.2.2
3
+ Version: 0.2.4
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
@@ -111,10 +111,44 @@ For an input vector :math:`(x_1,\dots,x_n)\in[0,1]^n`, let
111
111
 
112
112
  .. math:: A_{ch}^{(\mu)}(x_1,\dots,x_n)=\sum_{i=1}^{n}(x_{\sigma(i)}-x_{\sigma(i-1)})\,\mu(A_{\sigma(i)})
113
113
 
114
+ Available fuzzy measures for the Choquet integral:
115
+
116
+ Each constructor returns a monotone fuzzy measure with
117
+ :math:`\mu(\emptyset)=0` and :math:`\mu(N)=1`.
118
+
119
+ - **Uniform/cardinality** (``uniform_measure(n)``):
120
+ :math:`\mu(A)=|A|/n`; every position has equal singleton weight.
121
+ - **Relative** (``relative_measure(n)``):
122
+ :math:`\mu(A)=\frac{\sum_{i\in A}i}{\sum_{j=1}^{n}j}`; singleton
123
+ weights are proportional to ``1, 2, ..., n``, so later positions
124
+ receive larger weights.
125
+ - **k-fuzzy/Sugeno** (``k_fuzzy_measure(weights)``): for ``k ≠ 0``,
126
+ :math:`\mu(A)=\frac{\prod_{i\in A}(1+k w_i)-1}{k}`; for ``k = 0``,
127
+ :math:`\mu(A)=\sum_{i\in A}w_i`. The parameter ``k`` is chosen so
128
+ :math:`\mu(N)=1`; incompatible singleton weights raise ``ValueError``.
129
+ - **Weighted mean** (``weighted_measure(weights)``):
130
+ :math:`\mu(A)=\sum_{i\in A}w_i`. The weights must be in ``[0, 1]`` and
131
+ sum to ``1``; with the Choquet integral this gives a weighted
132
+ arithmetic mean.
133
+ - **OWA** (``owa_measure(weights)``):
134
+ :math:`\mu(A)=\sum_{j=1}^{|A|}w_j`. The normalized weights are applied
135
+ by descending value rank, so the first belongs to the largest value;
136
+ with the Choquet integral this capacity gives the OWA aggregation.
137
+ - **Exponential cardinality**: :math:`\mu(A)=(|A|/n)^q` is not
138
+ implemented yet; choosing ``q`` is future work.
139
+
140
+ The constructors are in ``aggregationslib.aggregation``; Decimal
141
+ equivalents are available in ``aggregationslib.decimalaggregations``.
142
+
114
143
  With the default cardinality measure :math:`\mu(A)=|A|/n`, this is the
115
144
  arithmetic mean,
116
145
  :math:`A_{ch}^{(\mu)}(x_1,\dots,x_n)=\frac{1}{n}\sum_{i=1}^{n}x_i`.
117
146
 
147
+ For the quasi-overlap generalization from Equation (9), pass a
148
+ two-argument function ``O(x, mu)`` as ``quasi_overlap`` to
149
+ ``choquet_integral`` or ``A_ch``. The default remains the classical
150
+ product-based Choquet integral.
151
+
118
152
  :math:`\mathbf{A_{sg}^{(\mu)}}` **- Sugeno integral [1]**
119
153
 
120
154
  Tags: ``averaging`` ``aggregation interval: [0,1]``
@@ -127,6 +161,36 @@ For an input vector :math:`(x_1,\dots,x_n)\in[0,1]^n`, let
127
161
 
128
162
  .. math:: A_{sg}^{(\mu)}(x_1,\dots,x_n)=\max_{1\leq i\leq n}\min(x_{\sigma(i)},\mu(A_{\sigma(i)}))
129
163
 
164
+ Available fuzzy measures for the Sugeno integral:
165
+
166
+ Each constructor returns a monotone fuzzy measure with
167
+ :math:`\mu(\emptyset)=0` and :math:`\mu(N)=1`. The same constructors are
168
+ available in ``aggregationslib.aggregation`` and
169
+ ``aggregationslib.decimalaggregations``.
170
+
171
+ - **Uniform/cardinality** (``uniform_measure(n)``):
172
+ :math:`\mu(A)=|A|/n`; every position has equal singleton weight.
173
+ - **Relative** (``relative_measure(n)``):
174
+ :math:`\mu(A)=\frac{\sum_{i\in A}i}{\sum_{j=1}^{n}j}`; singleton
175
+ weights are proportional to ``1, 2, ..., n``, so later positions
176
+ receive larger weights.
177
+ - **k-fuzzy/Sugeno** (``k_fuzzy_measure(weights)``): for ``k ≠ 0``,
178
+ :math:`\mu(A)=\frac{\prod_{i\in A}(1+k w_i)-1}{k}`; for ``k = 0``,
179
+ :math:`\mu(A)=\sum_{i\in A}w_i`. The parameter ``k`` is chosen so
180
+ :math:`\mu(N)=1`; incompatible singleton weights raise ``ValueError``.
181
+ - **Weighted mean** (``weighted_measure(weights)``):
182
+ :math:`\mu(A)=\sum_{i\in A}w_i`. The weights must be in ``[0, 1]`` and
183
+ sum to ``1``. In the Sugeno integral this measure is used in the
184
+ max–min formula; it does not turn Sugeno into a weighted arithmetic
185
+ mean.
186
+ - **OWA** (``owa_measure(weights)``):
187
+ :math:`\mu(A)=\sum_{j=1}^{|A|}w_j`. The normalized weights are applied
188
+ by descending value rank, so the first belongs to the largest value.
189
+ In the Sugeno integral this capacity is used in the max–min formula;
190
+ the result is not the OWA aggregation.
191
+ - **Exponential cardinality**: :math:`\mu(A)=(|A|/n)^q` is not
192
+ implemented yet; choosing ``q`` is future work.
193
+
130
194
  :math:`\mathbf{A_{ar}}` **- Arithmetic mean**
131
195
 
132
196
  Tags: ``averaging`` ``symmetric``
@@ -75,9 +75,40 @@ Define $A_{\sigma(i)}=\{\sigma(i),\dots,\sigma(n)\}$ and $x_{\sigma(0)}=0$:
75
75
 
76
76
  $$A_{ch}^{(\mu)}(x_1,\dots,x_n)=\sum_{i=1}^{n}(x_{\sigma(i)}-x_{\sigma(i-1)})\,\mu(A_{\sigma(i)})$$
77
77
 
78
+ Available fuzzy measures for the Choquet integral:
79
+
80
+ Each constructor returns a monotone fuzzy measure with
81
+ $\mu(\emptyset)=0$ and $\mu(N)=1$.
82
+
83
+ - **Uniform/cardinality** (`uniform_measure(n)`):
84
+ $\mu(A)=|A|/n$; every position has equal singleton weight.
85
+ - **Relative** (`relative_measure(n)`):
86
+ $\mu(A)=\frac{\sum_{i\in A}i}{\sum_{j=1}^{n}j}$; singleton weights are
87
+ proportional to `1, 2, ..., n`, so later positions receive larger weights.
88
+ - **k-fuzzy/Sugeno** (`k_fuzzy_measure(weights)`): for `k ≠ 0`,
89
+ $\mu(A)=\frac{\prod_{i\in A}(1+k w_i)-1}{k}$; for `k = 0`,
90
+ $\mu(A)=\sum_{i\in A}w_i$. The parameter `k` is chosen so
91
+ $\mu(N)=1$; incompatible singleton weights raise `ValueError`.
92
+ - **Weighted mean** (`weighted_measure(weights)`):
93
+ $\mu(A)=\sum_{i\in A}w_i$. The weights must be in `[0, 1]` and sum to
94
+ `1`; with the Choquet integral this gives a weighted arithmetic mean.
95
+ - **OWA** (`owa_measure(weights)`):
96
+ $\mu(A)=\sum_{j=1}^{|A|}w_j$. The normalized weights are applied by
97
+ descending value rank, so the first belongs to the largest value; with the
98
+ Choquet integral this capacity gives the OWA aggregation.
99
+ - **Exponential cardinality**: $\mu(A)=(|A|/n)^q$ is not implemented yet;
100
+ choosing `q` is future work.
101
+
102
+ The constructors are in `aggregationslib.aggregation`; Decimal equivalents
103
+ are available in `aggregationslib.decimalaggregations`.
104
+
78
105
  With the default cardinality measure $\mu(A)=|A|/n$, this is the arithmetic
79
106
  mean, $A_{ch}^{(\mu)}(x_1,\dots,x_n)=\frac{1}{n}\sum_{i=1}^{n}x_i$.
80
107
 
108
+ For the quasi-overlap generalization from Equation (9), pass a two-argument
109
+ function `O(x, mu)` as `quasi_overlap` to `choquet_integral` or `A_ch`. The
110
+ default remains the classical product-based Choquet integral.
111
+
81
112
  $\mathbf{A_{sg}^{(\mu)}}$ **- Sugeno integral [1]**
82
113
 
83
114
  Tags: `averaging` `aggregation interval: [0,1]` `symmetric if μ is symmetric`
@@ -88,6 +119,33 @@ $A_{\sigma(i)}=\{\sigma(i),\dots,\sigma(n)\}$:
88
119
 
89
120
  $$A_{sg}^{(\mu)}(x_1,\dots,x_n)=\max_{1\leq i\leq n}\min(x_{\sigma(i)},\mu(A_{\sigma(i)}))$$
90
121
 
122
+ Available fuzzy measures for the Sugeno integral:
123
+
124
+ Each constructor returns a monotone fuzzy measure with
125
+ $\mu(\emptyset)=0$ and $\mu(N)=1$. The same constructors are available in
126
+ `aggregationslib.aggregation` and `aggregationslib.decimalaggregations`.
127
+
128
+ - **Uniform/cardinality** (`uniform_measure(n)`):
129
+ $\mu(A)=|A|/n$; every position has equal singleton weight.
130
+ - **Relative** (`relative_measure(n)`):
131
+ $\mu(A)=\frac{\sum_{i\in A}i}{\sum_{j=1}^{n}j}$; singleton weights are
132
+ proportional to `1, 2, ..., n`, so later positions receive larger weights.
133
+ - **k-fuzzy/Sugeno** (`k_fuzzy_measure(weights)`): for `k ≠ 0`,
134
+ $\mu(A)=\frac{\prod_{i\in A}(1+k w_i)-1}{k}$; for `k = 0`,
135
+ $\mu(A)=\sum_{i\in A}w_i$. The parameter `k` is chosen so
136
+ $\mu(N)=1$; incompatible singleton weights raise `ValueError`.
137
+ - **Weighted mean** (`weighted_measure(weights)`):
138
+ $\mu(A)=\sum_{i\in A}w_i$. The weights must be in `[0, 1]` and sum to
139
+ `1`. In the Sugeno integral this measure is used in the max–min formula; it
140
+ does not turn Sugeno into a weighted arithmetic mean.
141
+ - **OWA** (`owa_measure(weights)`):
142
+ $\mu(A)=\sum_{j=1}^{|A|}w_j$. The normalized weights are applied by
143
+ descending value rank, so the first belongs to the largest value. In the
144
+ Sugeno integral this capacity is used in the max–min formula; the result is
145
+ not the OWA aggregation.
146
+ - **Exponential cardinality**: $\mu(A)=(|A|/n)^q$ is not implemented yet;
147
+ choosing `q` is future work.
148
+
91
149
  $\mathbf{A_{ar}}$ **- Arithmetic mean**
92
150
 
93
151
  Tags: `averaging` `symmetric` `aggregation interval: any [a,b] ⊂ ℝ`
@@ -89,10 +89,44 @@ For an input vector :math:`(x_1,\dots,x_n)\in[0,1]^n`, let
89
89
 
90
90
  .. math:: A_{ch}^{(\mu)}(x_1,\dots,x_n)=\sum_{i=1}^{n}(x_{\sigma(i)}-x_{\sigma(i-1)})\,\mu(A_{\sigma(i)})
91
91
 
92
+ Available fuzzy measures for the Choquet integral:
93
+
94
+ Each constructor returns a monotone fuzzy measure with
95
+ :math:`\mu(\emptyset)=0` and :math:`\mu(N)=1`.
96
+
97
+ - **Uniform/cardinality** (``uniform_measure(n)``):
98
+ :math:`\mu(A)=|A|/n`; every position has equal singleton weight.
99
+ - **Relative** (``relative_measure(n)``):
100
+ :math:`\mu(A)=\frac{\sum_{i\in A}i}{\sum_{j=1}^{n}j}`; singleton
101
+ weights are proportional to ``1, 2, ..., n``, so later positions
102
+ receive larger weights.
103
+ - **k-fuzzy/Sugeno** (``k_fuzzy_measure(weights)``): for ``k ≠ 0``,
104
+ :math:`\mu(A)=\frac{\prod_{i\in A}(1+k w_i)-1}{k}`; for ``k = 0``,
105
+ :math:`\mu(A)=\sum_{i\in A}w_i`. The parameter ``k`` is chosen so
106
+ :math:`\mu(N)=1`; incompatible singleton weights raise ``ValueError``.
107
+ - **Weighted mean** (``weighted_measure(weights)``):
108
+ :math:`\mu(A)=\sum_{i\in A}w_i`. The weights must be in ``[0, 1]`` and
109
+ sum to ``1``; with the Choquet integral this gives a weighted
110
+ arithmetic mean.
111
+ - **OWA** (``owa_measure(weights)``):
112
+ :math:`\mu(A)=\sum_{j=1}^{|A|}w_j`. The normalized weights are applied
113
+ by descending value rank, so the first belongs to the largest value;
114
+ with the Choquet integral this capacity gives the OWA aggregation.
115
+ - **Exponential cardinality**: :math:`\mu(A)=(|A|/n)^q` is not
116
+ implemented yet; choosing ``q`` is future work.
117
+
118
+ The constructors are in ``aggregationslib.aggregation``; Decimal
119
+ equivalents are available in ``aggregationslib.decimalaggregations``.
120
+
92
121
  With the default cardinality measure :math:`\mu(A)=|A|/n`, this is the
93
122
  arithmetic mean,
94
123
  :math:`A_{ch}^{(\mu)}(x_1,\dots,x_n)=\frac{1}{n}\sum_{i=1}^{n}x_i`.
95
124
 
125
+ For the quasi-overlap generalization from Equation (9), pass a
126
+ two-argument function ``O(x, mu)`` as ``quasi_overlap`` to
127
+ ``choquet_integral`` or ``A_ch``. The default remains the classical
128
+ product-based Choquet integral.
129
+
96
130
  :math:`\mathbf{A_{sg}^{(\mu)}}` **- Sugeno integral [1]**
97
131
 
98
132
  Tags: ``averaging`` ``aggregation interval: [0,1]``
@@ -105,6 +139,36 @@ For an input vector :math:`(x_1,\dots,x_n)\in[0,1]^n`, let
105
139
 
106
140
  .. math:: A_{sg}^{(\mu)}(x_1,\dots,x_n)=\max_{1\leq i\leq n}\min(x_{\sigma(i)},\mu(A_{\sigma(i)}))
107
141
 
142
+ Available fuzzy measures for the Sugeno integral:
143
+
144
+ Each constructor returns a monotone fuzzy measure with
145
+ :math:`\mu(\emptyset)=0` and :math:`\mu(N)=1`. The same constructors are
146
+ available in ``aggregationslib.aggregation`` and
147
+ ``aggregationslib.decimalaggregations``.
148
+
149
+ - **Uniform/cardinality** (``uniform_measure(n)``):
150
+ :math:`\mu(A)=|A|/n`; every position has equal singleton weight.
151
+ - **Relative** (``relative_measure(n)``):
152
+ :math:`\mu(A)=\frac{\sum_{i\in A}i}{\sum_{j=1}^{n}j}`; singleton
153
+ weights are proportional to ``1, 2, ..., n``, so later positions
154
+ receive larger weights.
155
+ - **k-fuzzy/Sugeno** (``k_fuzzy_measure(weights)``): for ``k ≠ 0``,
156
+ :math:`\mu(A)=\frac{\prod_{i\in A}(1+k w_i)-1}{k}`; for ``k = 0``,
157
+ :math:`\mu(A)=\sum_{i\in A}w_i`. The parameter ``k`` is chosen so
158
+ :math:`\mu(N)=1`; incompatible singleton weights raise ``ValueError``.
159
+ - **Weighted mean** (``weighted_measure(weights)``):
160
+ :math:`\mu(A)=\sum_{i\in A}w_i`. The weights must be in ``[0, 1]`` and
161
+ sum to ``1``. In the Sugeno integral this measure is used in the
162
+ max–min formula; it does not turn Sugeno into a weighted arithmetic
163
+ mean.
164
+ - **OWA** (``owa_measure(weights)``):
165
+ :math:`\mu(A)=\sum_{j=1}^{|A|}w_j`. The normalized weights are applied
166
+ by descending value rank, so the first belongs to the largest value.
167
+ In the Sugeno integral this capacity is used in the max–min formula;
168
+ the result is not the OWA aggregation.
169
+ - **Exponential cardinality**: :math:`\mu(A)=(|A|/n)^q` is not
170
+ implemented yet; choosing ``q`` is future work.
171
+
108
172
  :math:`\mathbf{A_{ar}}` **- Arithmetic mean**
109
173
 
110
174
  Tags: ``averaging`` ``symmetric``
@@ -1,3 +1,10 @@
1
+ from .aggregation import (
2
+ k_fuzzy_measure,
3
+ owa_measure,
4
+ relative_measure,
5
+ uniform_measure,
6
+ weighted_measure,
7
+ )
1
8
  from .aggregations import (
2
9
  A_amn,
3
10
  A_amx,
@@ -23,6 +30,11 @@ from .aggregations import (
23
30
  )
24
31
 
25
32
  __all__ = [
33
+ "k_fuzzy_measure",
34
+ "owa_measure",
35
+ "relative_measure",
36
+ "uniform_measure",
37
+ "weighted_measure",
26
38
  "A_amn",
27
39
  "A_amx",
28
40
  "A_ar",
@@ -307,6 +307,164 @@ def _as_unit_interval_vector(values: object) -> np.ndarray:
307
307
  return vector
308
308
 
309
309
 
310
+ def _capacity_from_function(n: int, capacity_function) -> FuzzyMeasure:
311
+ values = {}
312
+ for mask in range(1 << n):
313
+ subset = frozenset(index for index in range(n) if mask & (1 << index))
314
+ values[subset] = capacity_function(subset)
315
+ return FuzzyMeasure(n, values)
316
+
317
+
318
+ def _measure_size(n: int) -> int:
319
+ if isinstance(n, bool) or not isinstance(n, Integral) or n < 1:
320
+ raise ValueError("n must be a positive integer")
321
+ return int(n)
322
+
323
+
324
+ def _normalized_weights(weights: object, name: str = "weights") -> np.ndarray:
325
+ vector = _as_unit_interval_vector(weights)
326
+ if not isclose(
327
+ math.fsum(float(weight) for weight in vector),
328
+ 1.0,
329
+ abs_tol=_TOLERANCE,
330
+ rel_tol=0.0,
331
+ ):
332
+ raise ValueError(f"{name} must sum to 1")
333
+ return vector
334
+
335
+
336
+ def uniform_measure(n: int) -> FuzzyMeasure:
337
+ """Return the cardinality capacity ``mu(A) = |A| / n``."""
338
+ n = _measure_size(n)
339
+ return _capacity_from_function(n, lambda subset: len(subset) / n)
340
+
341
+
342
+ def relative_measure(n: int) -> FuzzyMeasure:
343
+ """Return the relative capacity with singleton weights 1, ..., n."""
344
+ n = _measure_size(n)
345
+ denominator = n * (n + 1) / 2
346
+ return _capacity_from_function(
347
+ n,
348
+ lambda subset: sum(index + 1 for index in subset) / denominator,
349
+ )
350
+
351
+
352
+ def weighted_measure(weights: object) -> FuzzyMeasure:
353
+ """Return the additive capacity induced by normalized positional weights."""
354
+ vector = _normalized_weights(weights)
355
+ n = vector.size
356
+ return _capacity_from_function(
357
+ n, lambda subset: sum(float(vector[index]) for index in subset)
358
+ )
359
+
360
+
361
+ def owa_measure(weights: object) -> FuzzyMeasure:
362
+ """Return the symmetric capacity that yields OWA weights on sorted values.
363
+
364
+ ``weights[0]`` is applied to the largest input, ``weights[1]`` to the
365
+ second largest, and so on. The weights must sum to one.
366
+ """
367
+ vector = _normalized_weights(weights)
368
+ cumulative_weights = np.concatenate(([0.0], np.cumsum(vector)))
369
+ n = vector.size
370
+ return _capacity_from_function(
371
+ n, lambda subset: float(cumulative_weights[len(subset)])
372
+ )
373
+
374
+
375
+ def _sugeno_lambda(weights: np.ndarray) -> float:
376
+ total = math.fsum(float(weight) for weight in weights)
377
+ if total == 1.0:
378
+ return 0.0
379
+
380
+ positive_count = int(np.count_nonzero(weights))
381
+ if total < 1.0:
382
+ if positive_count < 2:
383
+ raise ValueError(
384
+ "singleton weights do not define a normalized k-fuzzy measure"
385
+ )
386
+
387
+ def log_gap(value):
388
+ return math.fsum(
389
+ math.log1p(value * float(weight)) for weight in weights
390
+ ) - math.log1p(value)
391
+
392
+ lower, upper = 0.0, 1.0
393
+ while log_gap(upper) <= 0.0:
394
+ upper *= 2.0
395
+ if not isfinite(upper):
396
+ raise ValueError("could not find the k-fuzzy measure parameter")
397
+ for _ in range(100):
398
+ middle = (lower + upper) / 2.0
399
+ if log_gap(middle) < 0.0:
400
+ lower = middle
401
+ else:
402
+ upper = middle
403
+ return (lower + upper) / 2.0
404
+
405
+ if np.any(weights == 1.0):
406
+ return -1.0
407
+
408
+ def gap(value):
409
+ product = math.prod(1.0 + value * float(weight) for weight in weights)
410
+ return product - (1.0 + value)
411
+
412
+ lower, upper = -1.0, 0.0
413
+ for _ in range(100):
414
+ middle = (lower + upper) / 2.0
415
+ if gap(middle) > 0.0:
416
+ lower = middle
417
+ else:
418
+ upper = middle
419
+ return (lower + upper) / 2.0
420
+
421
+
422
+ def k_fuzzy_measure(singleton_weights: object) -> FuzzyMeasure:
423
+ """Return the normalized Sugeno ``k``-fuzzy capacity.
424
+
425
+ The values are determined from the singleton weights by
426
+ ``mu(A) = (prod(1 + k*w_i) - 1) / k``. The parameter ``k`` is selected
427
+ so that the measure of the full set is one; when ``k = 0``, this reduces
428
+ to the additive measure. Some singleton-weight vectors cannot define a
429
+ normalized ``k``-fuzzy measure and are rejected.
430
+ """
431
+ vector = _as_unit_interval_vector(singleton_weights)
432
+ n = vector.size
433
+ parameter = _sugeno_lambda(vector)
434
+
435
+ def capacity(subset):
436
+ if not subset:
437
+ return 0.0
438
+ subset_weights = [float(vector[index]) for index in subset]
439
+ if parameter == 0.0:
440
+ return math.fsum(subset_weights)
441
+ if parameter == -1.0:
442
+ return 1.0 - math.prod(1.0 - weight for weight in subset_weights)
443
+ product = math.prod(1.0 + parameter * weight for weight in subset_weights)
444
+ return (product - 1.0) / parameter
445
+
446
+ values = {}
447
+ for mask in range(1 << n):
448
+ subset = frozenset(index for index in range(n) if mask & (1 << index))
449
+ values[subset] = capacity(subset)
450
+ values[frozenset()] = 0.0
451
+ values[frozenset(range(n))] = 1.0
452
+ return FuzzyMeasure(n, values)
453
+
454
+
455
+ def _overlap_value(quasi_overlap, value: float, measure_value: float) -> float:
456
+ result = quasi_overlap(value, measure_value)
457
+ if isinstance(result, (bool, np.bool_)):
458
+ raise TypeError("quasi_overlap must return a real number in [0, 1]")
459
+ try:
460
+ result = float(result)
461
+ except (TypeError, ValueError) as exc:
462
+ raise TypeError("quasi_overlap must return a real number in [0, 1]") from exc
463
+ if not isfinite(result) or not 0.0 <= result <= 1.0:
464
+ raise ValueError("quasi_overlap must return a finite value in [0, 1]")
465
+ return result
466
+
467
+
310
468
  def _resolve_measure(measure: object, n: int):
311
469
  if measure is None:
312
470
  return lambda subset: len(subset) / n
@@ -348,8 +506,10 @@ def _resolve_measure(measure: object, n: int):
348
506
  return lambda subset: float(cardinality_values[len(subset)])
349
507
 
350
508
 
351
- def choquet_integral(values: object, measure: object = None) -> float:
352
- """Return the scalar discrete Choquet integral of a vector in ``[0, 1]``.
509
+ def choquet_integral(
510
+ values: object, measure: object = None, *, quasi_overlap=None
511
+ ) -> float:
512
+ """Return the discrete Choquet or quasi-overlap Choquet integral.
353
513
 
354
514
  Values are sorted in ascending order. ``measure`` can be:
355
515
 
@@ -359,8 +519,13 @@ def choquet_integral(values: object, measure: object = None) -> float:
359
519
  * a :class:`FuzzyMeasure` or a mapping that defines every subset.
360
520
 
361
521
  Subset keys in mappings use zero-based vector positions. The result is a
362
- Python ``float``. The Choquet integral is defined here on ``[0, 1]^n``.
522
+ Python ``float``. If ``quasi_overlap`` is supplied, it must be a callable
523
+ ``O(x, mu)`` and the implementation uses the CQO formula
524
+ ``sum(O(x_i, mu(A_i)) - O(x_(i-1), mu(A_i)))``. Omitting it uses the
525
+ classical product formula.
363
526
  """
527
+ if quasi_overlap is not None and not callable(quasi_overlap):
528
+ raise TypeError("quasi_overlap must be callable")
364
529
  vector = _as_unit_interval_vector(values)
365
530
  capacity = _resolve_measure(measure, vector.size)
366
531
  order = np.argsort(vector, kind="stable")
@@ -370,7 +535,13 @@ def choquet_integral(values: object, measure: object = None) -> float:
370
535
  previous_value = 0.0
371
536
  for rank, value in enumerate(ordered_values):
372
537
  upper_level_set = frozenset(int(index) for index in order[rank:])
373
- result += (float(value) - previous_value) * capacity(upper_level_set)
538
+ measure_value = capacity(upper_level_set)
539
+ if quasi_overlap is None:
540
+ result += (float(value) - previous_value) * measure_value
541
+ else:
542
+ result += _overlap_value(
543
+ quasi_overlap, float(value), measure_value
544
+ ) - _overlap_value(quasi_overlap, previous_value, measure_value)
374
545
  previous_value = float(value)
375
546
  return float(result)
376
547
 
@@ -85,16 +85,28 @@ class A_ch:
85
85
 
86
86
  name = "ch"
87
87
 
88
- def __init__(self, measure=None):
88
+ def __init__(self, measure=None, *, quasi_overlap=None):
89
89
  self.__measure = measure
90
+ if quasi_overlap is not None and not callable(quasi_overlap):
91
+ raise TypeError("quasi_overlap must be callable")
92
+ self.__quasi_overlap = quasi_overlap
90
93
 
91
94
  def __call__(self, array):
92
- return choquet_integral(array, measure=self.__measure)
95
+ return choquet_integral(
96
+ array,
97
+ measure=self.__measure,
98
+ quasi_overlap=self.__quasi_overlap,
99
+ )
93
100
 
94
101
  def __repr__(self):
95
- if self.__measure is None:
102
+ if self.__measure is None and self.__quasi_overlap is None:
96
103
  return "A_ch()"
97
- return f"A_ch(measure={self.__measure!r})"
104
+ arguments = []
105
+ if self.__measure is not None:
106
+ arguments.append(f"measure={self.__measure!r}")
107
+ if self.__quasi_overlap is not None:
108
+ arguments.append(f"quasi_overlap={self.__quasi_overlap!r}")
109
+ return f"A_ch({', '.join(arguments)})"
98
110
 
99
111
  def __str__(self):
100
112
  return self.__repr__()