Means
Means, Aggregation functions…
Documentation:
English: https://wgalka.github.io/Means/en/
Aggregations functions are:
Conjuctive - the final aggregated value will always be influenced by the smallest value among the inputs.
Disjnuctive - the aggregated value will always be influenced by the largest value among the inputs.
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.
An interactive version of this diagram is available at: https://wgalka.github.io/Means/klasyfikacja_agregacji.html
Example 1:
# example data
data = [0.2, 0.6, 0.7]
# configure function parameters
func1 = A_amn(p=0.5)
# use aggregation funciton
print(func1(data))
# Combine two aggregations - arithmetic mean and minimum
func2 = Combine2Aggregations(A_ar(), min)
# use combination of aggregation funciton
print(func2(data))
Example2:
To get information about aggregation function you can use __str__() or ‘repr()’ methods.
func1 = A_amn(p=0.5)
print(func1)
>>>A_amn(0.5)
func2 = Combine2Aggregations(A_ar(), A_md())
print(func2)
>>>A_armd
func3 = Combine2Aggregations(A_ar(), A_pw(r=3))
print(func3.__repr__()) # function parameters are printed in order: func1, func2
>>>A_arpw(r=3)
Aggregation functions
An aggregation function on the unit interval [1] is an increasing mapping \(A:[0,1]^n\to[0,1]\), \(n \in \mathbb{N}\), \(n\ge 2\), satisfying \(A(0,\dots,0) = 0\) and \(A(1,\dots,1) = 1\). For inputs on another interval \([a,b]\subset\mathbb{R}\), an \([a,b]\)-aggregation is an increasing mapping \(A:[a,b]^n\to[a,b]\) satisfying \(A(a,\dots,a)=a\) and \(A(b,\dots,b)=b\).
The following aggregation functions are implemented in this library. Tags describe properties of each formula. averaging means the result lies between the minimum and maximum inputs; conjunctive means it does not exceed the minimum; symmetric means permuting the inputs does not change the result. aggregation interval states the intervals on which the formula is an aggregation function: an increasing map \(A:[a,b]^n\to[a,b]\) satisfying \(A(a,\dots,a)=a\) and \(A(b,\dots,b)=b\). any [a,b] ⊂ ℝ includes intervals with negative values; any [a,b] ⊆ [0,∞) is restricted to nonnegative intervals. [0,1] means only the unit interval. These are mathematical properties; most callable objects do not validate input bounds at runtime. Some tags depend on parameters or the fuzzy measure.
\(\mathbf{A_{ch}^{(\mu)}}\) - Choquet integral [1]
Tags: averaging aggregation interval: [0,1] symmetric if μ is symmetric
For an input vector \((x_1,\dots,x_n)\in[0,1]^n\), let \(\sigma\) sort its indices so that \(x_{\sigma(1)} \leq \dots \leq x_{\sigma(n)}\). Define \(A_{\sigma(i)}=\{\sigma(i),\dots,\sigma(n)\}\) and \(x_{\sigma(0)}=0\):
Available fuzzy measures for the Choquet integral:
Each constructor returns a monotone fuzzy measure with \(\mu(\emptyset)=0\) and \(\mu(N)=1\).
Uniform/cardinality (uniform_measure(n)): \(\mu(A)=|A|/n\); every position has equal singleton weight.
Relative (relative_measure(n)): \(\mu(A)=\frac{\sum_{i\in A}i}{\sum_{j=1}^{n}j}\); singleton weights are proportional to 1, 2, ..., n, so later positions receive larger weights.
k-fuzzy/Sugeno (k_fuzzy_measure(weights)): for k ≠ 0, \(\mu(A)=\frac{\prod_{i\in A}(1+k w_i)-1}{k}\); for k = 0, \(\mu(A)=\sum_{i\in A}w_i\). The parameter k is chosen so \(\mu(N)=1\); incompatible singleton weights raise ValueError.
Weighted mean (weighted_measure(weights)): \(\mu(A)=\sum_{i\in A}w_i\). The weights must be in [0, 1] and sum to 1; with the Choquet integral this gives a weighted arithmetic mean.
OWA (owa_measure(weights)): \(\mu(A)=\sum_{j=1}^{|A|}w_j\). The normalized weights are applied by descending value rank, so the first belongs to the largest value; with the Choquet integral this capacity gives the OWA aggregation.
Exponential cardinality: \(\mu(A)=(|A|/n)^q\) is not implemented yet; choosing q is future work.
The constructors are in aggregationslib.aggregation; Decimal equivalents are available in aggregationslib.decimalaggregations.
With the default cardinality measure \(\mu(A)=|A|/n\), this is the arithmetic mean, \(A_{ch}^{(\mu)}(x_1,\dots,x_n)=\frac{1}{n}\sum_{i=1}^{n}x_i\).
For the quasi-overlap generalization from Equation (9), pass a two-argument function O(x, mu) as quasi_overlap to choquet_integral or A_ch. The default remains the classical product-based Choquet integral.
\(\mathbf{A_{sg}^{(\mu)}}\) - Sugeno integral [1]
Tags: averaging aggregation interval: [0,1] symmetric if μ is symmetric
For an input vector \((x_1,\dots,x_n)\in[0,1]^n\), let \(\sigma\) sort its indices so that \(x_{\sigma(1)} \leq \dots \leq x_{\sigma(n)}\), and define \(A_{\sigma(i)}=\{\sigma(i),\dots,\sigma(n)\}\):
Available fuzzy measures for the Sugeno integral:
Each constructor returns a monotone fuzzy measure with \(\mu(\emptyset)=0\) and \(\mu(N)=1\). The same constructors are available in aggregationslib.aggregation and aggregationslib.decimalaggregations.
Uniform/cardinality (uniform_measure(n)): \(\mu(A)=|A|/n\); every position has equal singleton weight.
Relative (relative_measure(n)): \(\mu(A)=\frac{\sum_{i\in A}i}{\sum_{j=1}^{n}j}\); singleton weights are proportional to 1, 2, ..., n, so later positions receive larger weights.
k-fuzzy/Sugeno (k_fuzzy_measure(weights)): for k ≠ 0, \(\mu(A)=\frac{\prod_{i\in A}(1+k w_i)-1}{k}\); for k = 0, \(\mu(A)=\sum_{i\in A}w_i\). The parameter k is chosen so \(\mu(N)=1\); incompatible singleton weights raise ValueError.
Weighted mean (weighted_measure(weights)): \(\mu(A)=\sum_{i\in A}w_i\). The weights must be in [0, 1] and sum to 1. In the Sugeno integral this measure is used in the max–min formula; it does not turn Sugeno into a weighted arithmetic mean.
OWA (owa_measure(weights)): \(\mu(A)=\sum_{j=1}^{|A|}w_j\). The normalized weights are applied by descending value rank, so the first belongs to the largest value. In the Sugeno integral this capacity is used in the max–min formula; the result is not the OWA aggregation.
Exponential cardinality: \(\mu(A)=(|A|/n)^q\) is not implemented yet; choosing q is future work.
\(\mathbf{A_{ar}}\) - Arithmetic mean
Tags: averaging symmetric aggregation interval: any [a,b] ⊂ ℝ
\(\mathbf{A_{qd}}\) - Quadratic mean
Tags: averaging symmetric aggregation interval: any [a,b] ⊆ [0,∞)
\(\mathbf{A_{pr}}\) - Product aggregation
Tags: conjunctive symmetric aggregation interval: [0,1]
\(\mathbf{A_{gm}}\) - Geometric mean
Tags: averaging symmetric aggregation interval: any [a,b] ⊆ [0,∞)
\(\mathbf{A_{hm}}\) - Harmonic mean
Tags: averaging symmetric aggregation interval: any [a,b] ⊆ [0,∞)
\(\mathbf{A_{pw}^{(r)}}\) - Power mean
Tags: averaging symmetric aggregation interval: any [a,b] ⊆ [0,∞) r ≠ 0
special cases of power means \(A_{\text{pw}}^r\) [1] are:
Arithmetic Mean where r=1;
Quadratic Mean where r=2;
Harmonic Mean where r=-1;
Geometric Mean obtained as the limit \(\lim_{r \to 0} A_{\text{pw}}^r\).
\(\mathbf{A_{ex}^{(r)}}\) - Exponential mean
Tags: averaging symmetric aggregation interval: any [a,b] ⊂ ℝ r ≠ 0
For computer implementations, to avoid numerical instability (overflow when \(r x_k > 709.78\) or underflow when all \(r x_k < -709.78\)), we use a numerically stable Log-Sum-Exp formulation by shifting the exponents by \(a_{max} = \max_{j} (r x_j)\):
\(\mathbf{A_{lm}}\) - Lehmer mean
Tags: averaging symmetric aggregation interval: any [a,b] ⊆ [0,∞) if 0 ≤ r ≤ 1
\(\mathbf{A_{amn}^{(p)}}\) - Arithmetic minimum mean
Tags: averaging symmetric conjunctive if p = 0 aggregation interval: any [a,b] ⊂ ℝ p ∈ [0,1]
\(\mathbf{A_{amx}^{(p)}}\) - Arithmetic maximum mean
Tags: averaging symmetric disjunctive if p = 0 aggregation interval: any [a,b] ⊂ ℝ p ∈ [0,1]
OWA
In the case of n = 2 (when only two values are aggregated) the calculation of the median and the Olympic aggregation are reduced to the case of calculating the arithmetic mean of the given values.
\(\mathbf{A_{md}}\) - Median - ordered weighted aggregation
Tags: averaging symmetric aggregation interval: any [a,b] ⊂ ℝ
\(\mathbf{A_{ol}}\) - Olimpic aggregation
Tags: averaging symmetric aggregation interval: any [a,b] ⊂ ℝ
\(\mathbf{A_{oln}^{(p)}}\) - Olimpic aggregation
Tags: averaging symmetric aggregation interval: any [a,b] ⊂ ℝ p ∈ ℕ, p ≥ 1
We can specify how many greatest and smallest records remove
\(\mathbf{A_{ln}}\) - Logaritmic aggregation [2]
Tags: averaging (continuous formula) symmetric aggregation interval (after continuous extension): any [a,b] ⊂ (0,∞)
The formula has a continuous averaging extension when input values coincide, but the current implementation does not handle ties: a zero denominator makes it return 0.
\(\mathbf{A^{(p)}_{A_1,A_2}}\) - Convex combinations of aggregation functions
Tags: aggregation interval: common interval of A₁ and A₂ averaging if both inputs are averaging p ∈ [0,1]
We can construct covex combination of aggregation functions as \(A^{(p)}_{A_1,A_2}=pA_1+(1-p)A_2\), where \(A_1, A_2\) are aggregation functions and \(p \in [0,1]\).
References
Beliakov, G., Bustince, H., and Calvo, T.: A Practical Guide to Averaging Functions. Berlin: Springer, vol. 329, 2016.
Mustonen, Seppo. (2010). Logarithmic mean for several arguments.
Metadata
Release files for aggregationslib 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aggregationslib-0.2.5.tar.gz | 15.3 MB | Without provenance | Details for aggregationslib-0.2.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aggregationslib-0.2.5-py3-none-any.whl | Python 3 | none | any | Details for aggregationslib-0.2.5-py3-none-any.whl |
Total release size: 15.3 MB
Release files / aggregationslib-0.2.5.tar.gz
| Download URL | aggregationslib-0.2.5.tar.gz |
|---|---|
| Size | 15.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
017c05c9ba4015bd9a8ff5d8931b32e207918ebacff8a983dffeddb6b6bac925
|
|
BLAKE2b-256 checksum How to use checksums |
61c4b78df6b0f3d6e3f574a79c95ecc96587dab4a9a05f3d05ff861ca4672322
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / aggregationslib-0.2.5-py3-none-any.whl
| Download URL | aggregationslib-0.2.5-py3-none-any.whl |
|---|---|
| Size | 30.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bb3b2679f513dd8c3e54b2f08e0687ec17ab42f4ae775c3bf99b0471556a52d5
|
|
BLAKE2b-256 checksum How to use checksums |
a3ab5bb7adb16c5bddb7e1630e9c957896add51e5793d94416b471066d2a9853
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Security for aggregationslib 0.2.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.