-
Notifications
You must be signed in to change notification settings - Fork 107
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
Handling constant subsequence #11
Comments
@oentaryorj This is a great call-out. There are a couple of options:
Since it sounds like you've encountered this situation in practice, what are your thoughts? |
@oentaryorj Something that's worked for me was to add some very small noise to the signal. This has the added benefit that the flat regions can be detected later on as different segments of the time series. |
@vanbenschoten: Sorry for the late response - just back from vacation :) I would be more inclined toward option 2, although we could probably put an option to ignore/skip the flat segments. @aouyang1: Thanks for the suggestion. Do you need to modify the current codes to make this work? Any other numerical issues encountered? |
If you read the original SAX paper (SAX was invented by the same people who invented the Matrix Profile) you will see that they handle subsequences with very low standard deviation (that includes the constant subsequence, as that has standard deviation zero) by not dividing by the standard deviation when normalizing. (The threshold for the standard deviation is a parameter here.) |
Agreed. Found this from stack overflow as well https://github.com/scikit-learn/scikit-learn/blob/7389dbac82d362f296dc2746f10e43ffa1615660/sklearn/preprocessing/data.py#L70 treating the standard deviation as 1 keeping the existing subsequence values and not normalizing. Since we're trying to compare to subsequences together such that one subsequence's spectral power does not bias over another, would it make sense to divide the signal such that we satisfy parseval's theorem? |
Thanks for the inputs. So I guess "ignoring" the standard deviation means option 2 in @vanbenschoten's reply (i.e., treating constant subsequence as "trivial" motif)? This makes sense to me, although it may depend on the application context. |
Performing the mean subtraction but not the division by the standard deviation in the distance profile computation should suffice as well? |
In some occasion, a time series subsequence can be flat/constant for a while, which may lead to a zero standard deviation for that subsequence. However, the the current codes does not seem to handle this case yet. Is there a way to fix this?
The text was updated successfully, but these errors were encountered: