Modifiers and operators¶
- fuzzy_expert.operators.apply_modifiers(membership, modifiers)[source]¶
Apply a list of modifiers or hedges to a numpy array.
- Parameters
membership – Membership values to be modified.
modifiers – List of modifiers or hedges.
>>> from fuzzy_expert.operators import apply_modifiers >>> x = [0.0, 0.25, 0.5, 0.75, 1] >>> apply_modifiers(x, ('not', 'very')) array([1. , 0.9375, 0.75 , 0.4375, 0. ])
- fuzzy_expert.operators.bounded_diff(memberships)[source]¶
Applies the element-wise function max(0, u - v).
- Parameters
memberships – List of arrays of membership values.
>>> from fuzzy_expert.operators import bounded_diff >>> x = [0, 0.25, 0.5, 0.75, 1] >>> y = [0, 0.25, 0.5, 0.6, 0.7] >>> bounded_diff([x, y]) array([0. , 0. , 0. , 0.15, 0.3 ])
- fuzzy_expert.operators.bounded_prod(memberships)[source]¶
Applies the element-wise function max(0, u + v - 1).
- Parameters
memberships – List of arrays of membership values.
>>> from fuzzy_expert.operators import bounded_prod >>> x = [0.1, 0.25, 0.5, 0.75, 1] >>> bounded_prod([x, x]) array([0. , 0. , 0. , 0.5, 1. ])
- fuzzy_expert.operators.bounded_sum(memberships)[source]¶
Applies the element-wise function min(1, u + v).
- Parameters
memberships – List of arrays of membership values.
>>> from fuzzy_expert.operators import bounded_sum >>> x = [0, 0.25, 0.5, 0.75, 1] >>> bounded_sum([x, x, x]) array([0. , 0.75, 1. , 1. , 1. ])
- fuzzy_expert.operators.defuzzificate(universe, membership, operator='cog')[source]¶
Computes a representative crisp value for the fuzzy set.
- Parameters
universe – Array of values representing the universe of discourse.
membership – Array of values representing the membership function.
operator –
Method used for computing the crisp representative value of the fuzzy set.
”cog”: Center of gravity.
”boa”: Bisector of area.
”mom”: Mean of the values for which the membership function is maximum.
”lom”: Largest value for which the membership function is maximum.
”som”: Smallest value for which the membership function is minimum.
>>> from fuzzy_expert.operators import defuzzificate >>> u = [0, 1, 2, 3, 4] >>> m = [0, 0, 0.5, 1, 1] >>> defuzzificate(u, m, "cog") 2.9166666666666665
>>> defuzzificate(u, m, "boa") 3.0
>>> defuzzificate(u, m, "mom") 3.5
>>> defuzzificate(u, m, "lom") 4
>>> defuzzificate(u, m, "som") 3
- fuzzy_expert.operators.drastic_prod(memberships)[source]¶
Applies the element-wise function f(u, v) = u if v == 0 else v if u == 1 else 0.
- Parameters
memberships – List of arrays of membership values.
>>> from fuzzy_expert.operators import drastic_prod >>> x = [0, 0.25, 0.5, 0.75, 1] >>> y = [1, 0.75, 0.5, 0.25, 0] >>> drastic_prod([x, y]) array([0., 0., 0., 0., 1.])
- fuzzy_expert.operators.drastic_sum(memberships)[source]¶
Applies the element-wise function f(u, v) = u if v == 0 else v if u == 0 else 1.
- Parameters
memberships – List of arrays of membership values.
>>> from fuzzy_expert.operators import drastic_sum >>> x = [0.1, 0.25, 0.5, 0.75, 0.3] >>> y = [0, 0.75, 0.5, 0.25, 0] >>> drastic_sum([x, y]) array([0.1, 1. , 1. , 1. , 0.3])
- fuzzy_expert.operators.extremely(membership)[source]¶
Applies the element-wise function fn(u) = u^3.
- Parameters
membership – Membership function to be modified.
>>> from fuzzy_expert.operators import extremely >>> extremely([0, 0.25, 0.5, 0.75, 1]) array([0. , 0.015625, 0.125 , 0.421875, 1. ])
- fuzzy_expert.operators.intensify(membership)[source]¶
Applies the element-wise function fn(u) = u^2 if u <= 0.5 else 1 - 2 * (1 - u)^2.
- Parameters
membership – Membership function to be modified.
>>> from fuzzy_expert.operators import intensify >>> intensify([0, 0.25, 0.5, 0.75, 1]) array([0. , 0.0625, 0.25 , 0.875 , 1. ])
- fuzzy_expert.operators.maximum(memberships)[source]¶
Applies the element-wise function f(u, v) = max(u, v).
- Parameters
memberships – List of arrays of membership values.
>>> from fuzzy_expert.operators import maximum >>> x = [0.1, 0.25, 0.5, 0.75, 0.3] >>> y = [0, 0.75, 0.5, 0.25, 0] >>> maximum([x, y]) array([0.1 , 0.75, 0.5 , 0.75, 0.3 ])
- fuzzy_expert.operators.minimum(memberships)[source]¶
Applies the element-wise function f(u, v) = min(u, v).
- Parameters
memberships – List of arrays of membership values.
>>> from fuzzy_expert.operators import minimum >>> x = [0.1, 0.25, 0.5, 0.75, 0.3] >>> y = [0, 0.75, 0.5, 0.25, 0] >>> minimum([x, y]) array([0. , 0.25, 0.5 , 0.25, 0. ])
- fuzzy_expert.operators.more_or_less(membership)[source]¶
Applies the element-wise function fn(u) = u^(1/2).
- Parameters
membership – Membership function to be modified.
>>> from fuzzy_expert.operators import more_or_less >>> more_or_less([0, 0.25, 0.5, 0.75, 1]) array([0. , 0.5 , 0.70710678, 0.8660254 , 1. ])
- fuzzy_expert.operators.norm(membership)[source]¶
Applies the element-wise function fn(u) = u / max(u).
- Parameters
membership – Membership function to be modified.
>>> from fuzzy_expert.operators import norm >>> norm([0, 0.25, 0.5]) array([0. , 0.5, 1. ])
- fuzzy_expert.operators.not_(membership)[source]¶
Applies the element-wise function fn(u) = 1 - u.
- Parameters
membership – Membership function to be modified.
>>> from fuzzy_expert.operators import not_ >>> not_([0, 0.25, 0.5, 0.75, 1]) array([1. , 0.75, 0.5 , 0.25, 0. ])
- fuzzy_expert.operators.plus(membership)[source]¶
Applies the element-wise function fn(u) = u^1.25.
- Parameters
membership – Membership function to be modified.
>>> from fuzzy_expert.operators import plus >>> plus([0, 0.25, 0.5, 0.75, 1]) array([0. , 0.1767767 , 0.42044821, 0.69795364, 1. ])
- fuzzy_expert.operators.prob_or(memberships)[source]¶
Applies the element-wise function fn(u, v) = u + v - u * v. Also known as algebraic-sum.
- Parameters
memberships – List of arrays of membership values.
>>> from fuzzy_expert.operators import prob_or >>> x = [0.1, 0.25, 0.5, 0.75, 0.3] >>> y = [0, 0.75, 0.5, 0.25, 0] >>> prob_or([x, y]) array([0.1 , 0.8125, 0.75 , 0.8125, 0.3 ])
- fuzzy_expert.operators.product(memberships)[source]¶
Applies the element-wise function f(u, v) = u * v.
- Parameters
memberships – List of arrays of membership values.
>>> from fuzzy_expert.operators import product >>> x = [0, 0.25, 0.5, 0.75, 1] >>> product([x, x, x]) array([0. , 0.015625, 0.125 , 0.421875, 1. ])
- fuzzy_expert.operators.slightly(membership)[source]¶
Applies the element-wise function fn(u) = u^(1/2).
- Parameters
membership – Membership function to be modified.
>>> from fuzzy_expert.operators import slightly >>> slightly([0, 0.25, 0.5, 0.75, 1]) array([0. , 0.16326531, 0.99696182, 1. , 0. ])
- fuzzy_expert.operators.somewhat(membership)[source]¶
Applies the element-wise function fn(u) = u^(1/3).
- Parameters
membership – Membership function to be modified.
>>> from fuzzy_expert.operators import somewhat >>> somewhat([0, 0.25, 0.5, 0.75, 1]) array([0. , 0.62996052, 0.79370053, 0.9085603 , 1. ])