Skip to content

Commit

Permalink
refactor(fuzzy_overlay)
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaarnio committed Apr 29, 2024
1 parent 9a5e7a0 commit 76b07f8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions eis_toolkit/prediction/fuzzy_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ def sum_overlay(data: Union[Sequence[np.ndarray], np.ndarray]) -> np.ndarray:
InvalidParameterValueException: If data values are not in range [0, 1].
"""
data = _prepare_data_for_fuzzy_overlay(data)
return 1 - np.prod(1 - data, axis=0)
product_term = np.prod(1 - data, axis=0)
fuzzy_sum = 1 - product_term
return fuzzy_sum


@beartype
Expand All @@ -120,6 +122,7 @@ def gamma_overlay(data: Union[Sequence[np.ndarray], np.ndarray], gamma: float =
if gamma < 0 or gamma > 1:
raise InvalidParameterValueException("The gamma parameter must be in range [0, 1]")

product = np.prod(data, axis=0)
sum = 1 - np.prod(1 - data, axis=0)
return product ** (1 - gamma) * sum**gamma
fuzzy_product = np.prod(data, axis=0)
product_term_for_sum = np.prod(1 - data, axis=0)
fuzzy_sum = 1 - product_term_for_sum
return fuzzy_product ** (1 - gamma) * fuzzy_sum**gamma

0 comments on commit 76b07f8

Please sign in to comment.