Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add membership function options for fuzzy entropy #1051

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

DongCheninmuenster
Copy link

@DongCheninmuenster DongCheninmuenster commented Nov 18, 2024

Description

I noticed a TODO about membership functions in utils_entropy.py when I tried to use this package for fuzzy entropy analysis. Therefore I added following 8 kinds of membership functions:

    "exp"    : exponential,
    "gauss"  : gaussian,
    "cgauss" : constgaussian,
    "bell"   : bell,
    "z"      : z,
    "trapez" : trapezoidal,
    "tri"    : triangular,
    "sig"    : sigmoid,

See:

Azami, H., Li, P., Arnold, S. E., Escudero, J., & Humeau-Heurtier, A. (2019b). Fuzzy Entropy Metrics for the analysis of Biomedical Signals: Assessment and comparison. IEEE Access, 7, 104833–104847. https://doi.org/10.1109/access.2019.2930625

Zheng, J., Jiang, Z., & Pan, H. (2018b). Sigmoid-based refined composite multiscale fuzzy entropy and t-SNE based fault diagnosis approach for rolling bearing. Measurement, 129, 332–342. https://doi.org/10.1016/j.measurement.2018.07.045

Changes

  • Introduced a new func_name parameter for selecting the membership function.

  • Modified the tolerance parameter to accept both scalar and two-element vector formats as the parameters of membership functions. Detailed definition can be found in the referenced papers above.

    • If it's a scalar, it refers to a threshold.
    • If it's a two-element vector, it refers to threshold and power respectively.
  • To optimize memory usage, fuzzy entropy is calculated using block matrices. (block size is 10 in default)

Testing

Compared the result with Azami's MATLAB version: FuzzyEntropy_Matlab

Example

print(nk.entropy_fuzzy(series, func_name="exp", tolerance=[0.0018,4]))
print(nk.entropy_fuzzy(series, func_name="gauss", tolerance=0.1253))
print(nk.entropy_fuzzy(series, func_name="cgauss", tolerance=0.0903))
print(nk.entropy_fuzzy(series, func_name="bell", tolerance=[0.1414,2]))
print(nk.entropy_fuzzy(series, func_name="z", tolerance=0.1309))
print(nk.entropy_fuzzy(series, func_name="trapez", tolerance=0.1286))
print(nk.entropy_fuzzy(series, func_name="tri", tolerance=0.3))

Checklist

  • I have read the CONTRIBUTING file.
  • My PR is targeted at the dev branch (and not towards the master branch).
  • I ran the CODE CHECKS on the files I added or modified and fixed the errors.
  • I have added the newly added features to News.rst (if applicable)

I have added membership functions to the fuzzy entropy algorithm by modifying the parameters in the entropy_sample function. Although I'm still a beginner in Python, the good news is that it works as expected. I compared my code and results with Azami's MATLAB version to verify this.

However, I believe there may be a more efficient approach, especially by improving the complexity_tolerance function. I'm continuing to work on implementing this optimization.

Additionally, I have modified the core algorithm of fuzzy entropy by using block matrix, which helps reduce memory usage.
Copy link
Author

@DongCheninmuenster DongCheninmuenster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some changes are just format changes modified by checks code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant