frlearn.utils.owa_operators
.OWAOperator¶
-
class
frlearn.utils.owa_operators.
OWAOperator
(f, *, scale: bool = False, name: Optional[str] = None)[source]¶ Ordered Weighted Averaging (OWA) operator, which can be applied to an array to obtain its ordered weighted average. Intended specifically for dual pairs of OWA operators that approximate maxima and minima, which are encoded together in one object.
- Parameters
- fint -> array shape=(k, )
Generating function which takes an integer k and returns a valid weight vector of length k. (The values should be in [0, 1] and sum to 1.)
- scaleboolean, default=False
If True, weights will be scaled to sum to 1 before being applied.
- namestr, default=None
Name of the weights to be displayed as its string representation. If None, f will be used to generate a weight array of length 4.
-
__init__
(self, f, *, scale: 'bool' = False, name: 'str' = None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
soft_head
(self, a, k=None, axis=-1, flavour: 'str' = 'arithmetic')[source]¶ Calculates the soft head of an array.
- Parameters
- andarray
Input array of values.
- kint or float or None, default=None
Number of initial values from which the soft head is calculated. If a float in (0, 1), taken as a fraction of the total number of values. If None, all values are used.
- axisint, default=-1
The axis along which the soft head is calculated.
- flavourstr {‘arithmetic’, ‘geometric’, ‘harmonic’, }, default=’arithmetic’
Determines the type of weighted average.
- Returns
- soft_head_along_axisndarray
An array with the same shape as a, with the specified axis removed. If a is a 0-d array, a scalar is returned.
-
soft_max
(self, a, k=None, axis=-1, flavour: 'str' = 'arithmetic')[source]¶ Calculates the soft maximum of an array.
- Parameters
- andarray
Input array of values.
- kint or float or None, default=None
Number of greatest values from which the soft maximum is calculated. If a float in (0, 1), taken as a fraction of the total number of values. If None, all values are used.
- axisint, default=-1
The axis along which the soft maximum is calculated.
- flavourstr {‘arithmetic’, ‘geometric’, ‘harmonic’, }, default=’arithmetic’
Determines the type of weighted average.
- Returns
- soft_max_along_axisndarray
An array with the same shape as a, with the specified axis removed. If a is a 0-d array, a scalar is returned.
-
soft_min
(self, a, k=None, axis=-1, flavour: 'str' = 'arithmetic')[source]¶ Calculates the soft minimum of an array.
- Parameters
- andarray
Input array of values.
- kint or float or None, default=None
Number of least values from which the soft minimum is calculated. If a float in (0, 1), taken as a fraction of the total number of values. If None, all values are used.
- axisint, default=-1
The axis along which the soft minimum is calculated.
- flavourstr {‘arithmetic’, ‘geometric’, ‘harmonic’, }, default=’arithmetic’
Determines the type of weighted average.
- Returns
- soft_min_along_axisndarray
An array with the same shape as a, with the specified axis removed. If a is a 0-d array, a scalar is returned.
-
soft_tail
(self, a, k=None, axis=-1, flavour: 'str' = 'arithmetic')[source]¶ Calculates the soft tail of an array.
- Parameters
- andarray
Input array of values.
- kint or float or None, default=None
Number of terminal values from which the soft tail is calculated. If a float in (0, 1), taken as a fraction of the total number of values. If None, all values are used.
- axisint, default=-1
The axis along which the soft tail is calculated.
- flavourstr {‘arithmetic’, ‘geometric’, ‘harmonic’, }, default=’arithmetic’
Determines the type of weighted average.
- Returns
- soft_tail_along_axisndarray
An array with the same shape as a, with the specified axis removed. If a is a 0-d array, a scalar is returned.