-
Notifications
You must be signed in to change notification settings - Fork 66
[ML] Improve quantile estimation accuracy and median accuracy for anomaly detection #2367
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
droberts195
reviewed
Jul 19, 2022
… better to just always use inlear interpolation
droberts195
approved these changes
Jul 25, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This was referenced Jul 27, 2022
tveasey
added a commit
to tveasey/ml-cpp-1
that referenced
this pull request
Aug 1, 2022
…maly detection (elastic#2367) We use a histogram sketch for estimating data quantiles and also computing the time bucket median for anomaly detection. Once data are merged into buckets we have to make some assumptions about how values are distributed on buckets. Previously, we assumed data are uniformly distributed on buckets whose endpoints are the midpoints between the bucket "centres" we track. In fact, the points we track are the weighted means of the values in each bucket, so it is more accurate to assume that roughly half the data in a bucket falls either side of this point. This changes the interpolation scheme to use the same endpoints but to incorporate this new assumption. This gives a very nice additional property: a quantile which falls between two buckets each containing a single value is computed exactly. An immediate corollary is that all quantiles are exact if the data size is less than the sketch size. Previously, we used piecewise constant interpolation for estimating the median because it is exact in this case. We now cut over to linear interpolation. This is attractive because for large data, if the data distribution is smooth, linear interpolation is significantly more accurate for fixed memory usage than piecewise constant interpolation. Closes elastic#2364.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We use a histogram sketch for estimating data quantiles and also computing the time bucket median for anomaly detection.
Once data are merged into buckets we have to make some assumptions about how values are distributed on buckets. Previously, we assumed data are uniformly distributed on buckets whose endpoints are the midpoints between the bucket "centres" we track. In fact, the points we track are the weighted means of the values in each bucket, so it is more accurate to assume that roughly half the data in a bucket falls either side of this point.
This changes the interpolation scheme to use the same endpoints but to incorporate this new assumption. This gives a very nice additional property: a quantile which falls between two buckets each containing a single value is computed exactly. An immediate corollary is that all quantiles are exact if the data size is less than the sketch size. Previously, we used piecewise constant interpolation for estimating the median because it is exact in this case. We now cut over to linear interpolation. This is attractive because for large data, if the data distribution is smooth, linear interpolation is significantly more accurate for fixed memory usage than piecewise constant interpolation.
Closes #2364.