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

Bugs in adaptive median filter implementation (Crespo algorithm) #69

Open
juliusandretti opened this issue Dec 9, 2020 · 3 comments
Open

Comments

@juliusandretti
Copy link

juliusandretti commented Dec 9, 2020

Greetings, hope you're doing well.

I've been running a few tests with your implementation of the Crespo algorithm confronting it with my own implementation and I've come across a few divergences, some are bugs and cause inaccuracies. On a previous issue, I told you about a bug in the inactivity mask, the ones I'm going to discuss now are newly discovered.

  1. In line 1130 of your /sleep/scoring_base.py script you use the rolling class from pandas with parameter min_periods. You should check that because min_periods may produce unexpected results when applied to series containing NaNs.
  2. Starting at line 1136 you use the expanding class from pandas with parameter center=True and it produces "unexpected" results. Please refer to expanding-git-issue.
  3. In line 1141 you apply an index reversion using "[::-1]". You should check that because it leads to indexing problems in subsequent pandas-related operations.

I hope this will help to improve the library.
Keep up the good work.

Julius

@ghammad
Copy link
Owner

ghammad commented Dec 14, 2020

Hi Julius,

thank you for the feedback. It will definitely help to improve the package.

In order to proceed now, may I ask you to:

  • specifiy which branch/commit of the code you are referring to
  • provide me some examples to reproduce the problems ( "unexpected results" or "might lead to problems" are hard to reproduce without guidance)

Or, if you have your own implementation of the Crespo algorithm, you could make a pull request and become a contributor of the package? Open-sourcing the project was done in that perspective.

Either way, thank you in advance for your help.

PS: I'll try to have all your issues resolved (#65 and #69) asap.

@juliusandretti
Copy link
Author

Hello,

I'm referring to the latest commit on branch master. I'm attaching a script to this reply that I used to visualize the results of several rolling and expanding configurations, I think it will help you to understand what I'm talking about on points 1 and 2 and how it relates to your implementation. I've also added a minimal example demonstrating the issue with the [::-1] inversion.

Hope it helps.
Julius

operation_probe.zip

@juliusandretti
Copy link
Author

Hello,

I've just updated my first post. The link was missing on point 2, please check it out. Also, I've noticed that I had forgotten to write about one last point, so let me add it now:

  1. Slicing with [... : -1] causes the last point to be ignored. Correct slice should be [... : ]

Julius

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

No branches or pull requests

2 participants