[ML] fix segfault caused by to few outliers and harden container usage#96
Merged
hendrikmuhs merged 2 commits intoelastic:masterfrom May 17, 2018
Merged
[ML] fix segfault caused by to few outliers and harden container usage#96hendrikmuhs merged 2 commits intoelastic:masterfrom
hendrikmuhs merged 2 commits intoelastic:masterfrom
Conversation
…stream and harden accumulators to prevent empty containers. fixes elastic#94
hendrikmuhs
commented
May 16, 2018
| CTools::logisticFunction(static_cast<double>(i) / numberOutliers, | ||
| 0.1, 1.0)}; | ||
| CBasicStatistics::count(values[outliers[i].second]) *= weight; | ||
| if (numberOutliers > 1.0) { |
Author
There was a problem hiding this comment.
changes below are just formatings
tveasey
approved these changes
May 16, 2018
Contributor
tveasey
left a comment
There was a problem hiding this comment.
Definitely, a good idea to make this class more robust! I left a couple of suggestions for slightly rewording the errors. I don't think I need to review again, so going ahead and approving now.
include/maths/CBasicStatistics.h
Outdated
| //! Reset the number of statistics to gather to \p n. | ||
| void resize(std::size_t n) { | ||
| if (n == 0) { | ||
| LOG_ERROR(<< "Invalid resize of 0 for statistics accumulator"); |
Contributor
There was a problem hiding this comment.
nit: I think this reads slightly better as Invalid resize to 0 for order statistics accumulator.
include/maths/CBasicStatistics.h
Outdated
| : TImpl{std::vector<T>(n, T{}), less} {} | ||
| : TImpl{std::vector<T>(std::max(n, std::size_t(1)), T{}), less} { | ||
| if (n == 0) { | ||
| LOG_ERROR(<< "Invalid size of 0 for statistics accumulator"); |
Contributor
There was a problem hiding this comment.
nit: I'd make this Invalid size of 0 for order statistics accumulator, since there are other types of statistics accumulators.
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
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.
Do not re-weight outliers if there is just 1, preventing a crash downstream
and harden accumulators to prevent empty containers.
relates to #90
fixes #94
Note: backport to be done together with pending backport of #90