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

[ML] Adding anomaly score explanations #142999

Merged
merged 35 commits into from
Oct 24, 2022

Conversation

jgowdyelastic
Copy link
Member

@jgowdyelastic jgowdyelastic commented Oct 10, 2022

Adds the new anomaly explanation data to the expanded rows in the anomaly explorer and the single metric viewer.
If no anomaly_score_explanation record data is present, the section is no shown.

image

The elasticsearch changes are not in yet, but this can be tested by mocking the data by making these changes 1ab9b45
As soon as the backend changes are in, I will test throughly and raise a follow up PR to fix any issues.

Also refactors the AnomalyDetails component into typescript.

@elastic/kibana-design removes some now unused rules from a sass file.

cc @valeriy42

content={i18n.translate(
'xpack.ml.anomaliesTable.anomalyDetails.anomalyExplanationDetails.recordScoreTooltip',
{
defaultMessage: 'Record score normalized blah blah blah',
Copy link
Member Author

Choose a reason for hiding this comment

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

Description text needed

Copy link
Member Author

Choose a reason for hiding this comment

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

@szabosteve and @valeriy42 can you please help me with this tooltip text.

Copy link
Contributor

Choose a reason for hiding this comment

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

We have a lot of questions / SDHs where the final score is significantly different than the initial score. As well as the tooltip text here, I wonder if we need extra text (not behind a tooltip), possibly in the 'Impact on initial score' section clarifying why this is, giving reasons for 'why the actual score is so much lower than the initial score?'.

image

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this is just a repeat of the "Initial record score" and the "Record score" from the left column, just with an arrow in between? If that's true, having "normalized" in the label here seems to falsely imply the other values aren't normalized. Unless there's something else going on here that you want to cover in the tooltip?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking that the label could be "Record score reduction" or something like that. With the tooltip explaining that normalization has caused the score to be reduced.

I wonder if we need extra text (not behind a tooltip), possibly in the 'Impact on initial score' section clarifying why this is, giving reasons for 'why the actual score is so much lower than the initial score?'.

Yes I think that would be helpful.

content={i18n.translate(
'xpack.ml.anomaliesTable.anomalyDetails.anomalyExplanationDetails.anomalyCharacteristicsTooltip',
{
defaultMessage: 'Anomaly characteristics impact blah blah blah',
Copy link
Member Author

Choose a reason for hiding this comment

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

Description text needed

Copy link
Member Author

Choose a reason for hiding this comment

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

@szabosteve and @valeriy42 can you please help me with this tooltip text.

Copy link
Contributor

Choose a reason for hiding this comment

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

The description we use in the API is: "Impact of the statistical properties of the detected anomalous interval", though hopefully we can make that more intelligible.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated in 45313cd

Copy link
Contributor

@valeriy42 valeriy42 Oct 19, 2022

Choose a reason for hiding this comment

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

"The high impact from the statistical properties of the detected anomaly compared to the previous anomalies." or "impact from the shape of the detected anomaly distribution compared to the previous anomalies."

content={i18n.translate(
'xpack.ml.anomaliesTable.anomalyDetails.anomalyExplanationDetails.singleBucketTooltip',
{
defaultMessage: 'Single bucket impact blah blah blah',
Copy link
Member Author

Choose a reason for hiding this comment

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

Description text needed

Copy link
Member Author

Choose a reason for hiding this comment

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

@szabosteve and @valeriy42 can you please help me with this tooltip text.

Copy link
Contributor

Choose a reason for hiding this comment

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

The text we used in the API was: "Impact of the deviation between actual and typical in the current bucket." However, a clearer tip here might be: "The impact of the difference between actual and typical values in this bucket on the score."

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated in 45313cd

content={i18n.translate(
'xpack.ml.anomaliesTable.anomalyDetails.anomalyExplanationDetails.multiBucketTooltip',
{
defaultMessage: 'Multi bucket impact blah blah blah',
Copy link
Member Author

Choose a reason for hiding this comment

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

Description text needed

Copy link
Member Author

Choose a reason for hiding this comment

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

@szabosteve and @valeriy42 can you please help me with this tooltip text.

Copy link
Contributor

Choose a reason for hiding this comment

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

The description in the API docs is " Impact of the deviation between actual and typical in the past 12 buckets." So to match my other suggestion, I'd suggest "The impact of the difference between actual and typical values in the past 12 buckets on the score."

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated in 45313cd

Copy link
Contributor

Choose a reason for hiding this comment

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

I would skip putting "on the score." as the fields belong to the group "Impact on the initial score".

content={i18n.translate(
'xpack.ml.anomaliesTable.anomalyDetails.anomalyExplanationDetails.highVarianceTooltip',
{
defaultMessage: 'High variance interval blah blah blah',
Copy link
Member Author

Choose a reason for hiding this comment

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

Description text needed

Copy link
Member Author

Choose a reason for hiding this comment

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

@szabosteve and @valeriy42 can you please help me with this tooltip text.

Copy link
Contributor

Choose a reason for hiding this comment

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

The API docs for this one say "Indicates reduction of anomaly score for the bucket with large confidence intervals." However, I think that's another one we should try to make more intelligible if possible. For example, "If a bucket has large confidence intervals, the score is reduced." Though that begs the question of why this bucket has large confidence intervals.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated in 45313cd

Copy link
Contributor

Choose a reason for hiding this comment

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

The long and simplified answer is: We have detected a periodic pattern in the time series. The current bucket is in the part of the periodic interval where data can vary a lot. This leads to a large confidence interval since we have seen data all over the place in this part of the period before. Hence, we reduce the anomaly score for the current anomaly in this region.

Now, how to fit it in a tooltip?

content={i18n.translate(
'xpack.ml.anomaliesTable.anomalyDetails.anomalyExplanationDetails.incompleteBucketTooltip',
{
defaultMessage: 'Incomplete bucket blah blah blah',
Copy link
Member Author

Choose a reason for hiding this comment

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

Description text needed

Copy link
Member Author

Choose a reason for hiding this comment

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

@szabosteve and @valeriy42 can you please help me with this tooltip text.

Copy link
Contributor

Choose a reason for hiding this comment

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

The API docs for this one say "Indicates reduction of anomaly score if the bucket contains fewer samples than historically expected." It might be clearer to say something like "If the bucket contains fewer samples than expected, the score is reduced."

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated in 45313cd

@jgowdyelastic jgowdyelastic self-assigned this Oct 11, 2022
@jgowdyelastic jgowdyelastic marked this pull request as ready for review October 11, 2022 16:41
@jgowdyelastic jgowdyelastic requested review from a team as code owners October 11, 2022 16:41
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@kibanamachine kibanamachine requested a review from a team as a code owner October 11, 2022 16:45
@valeriy42 valeriy42 requested review from valeriy42 and removed request for valeriy42 October 17, 2022 14:34
@peteharverson
Copy link
Contributor

I reckon we should not introduce another severity indicator. Did you consider using the one from the table row?
Good point. I'd vote for using the existing health indicator circle icon, unless there's a reason why you went with the underline style here?

Having seen the examples which use the health indicator in #142999 (comment), I agree the underline style works better in this case where we are showing how the score has dropped. Happy to go with the underline style in the explanation section.

'xpack.ml.anomaliesTable.anomalyDetails.anomalyExplanationDetails.anomalyCharacteristicsTooltip.low',
{
defaultMessage:
'The statistical properties of the detected anomalous interval have a low impact on the score.',
Copy link
Contributor

Choose a reason for hiding this comment

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

@valeriy42 are there any more details we can provide for the 'statistical properties' info? This text is a bit unclear to me and leaves me wondering 'what statistical properties'.

Copy link
Contributor

@valeriy42 valeriy42 Oct 19, 2022

Choose a reason for hiding this comment

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

@peteharverson: "The duration and magnitude of the current anomaly relative to the historical average among the detected anomalies."

Copy link
Contributor

Choose a reason for hiding this comment

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

magnitude, scale, extent, expanse, range of deviation

Copy link
Contributor

Choose a reason for hiding this comment

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

How about this?

Moderate /  medium / high impact from the duration and magnitude of the detected anomaly relative to the historical average.

'xpack.ml.anomaliesTable.anomalyDetails.anomalyExplanationDetails.singleBucketTooltip.low',
{
defaultMessage:
'The difference between actual and typical values in this bucket have a moderate impact.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be has a moderate..

'xpack.ml.anomaliesTable.anomalyDetails.anomalyExplanationDetails.singleBucketTooltip.medium',
{
defaultMessage:
'The difference between actual and typical values in this bucket have a significant impact.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be has a significant..

'xpack.ml.anomaliesTable.anomalyDetails.anomalyExplanationDetails.singleBucketTooltip.high',
{
defaultMessage:
'The difference between actual and typical values in this bucket have a high impact.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be has a high..

'xpack.ml.anomaliesTable.anomalyDetails.anomalyExplanationDetails.multiBucketTooltip.low',
{
defaultMessage:
'The difference between actual and typical values in the past 12 buckets have a moderate impact.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be The differences or switch have to has

'xpack.ml.anomaliesTable.anomalyDetails.anomalyExplanationDetails.multiBucketTooltip.medium',
{
defaultMessage:
'The difference between actual and typical values in the past 12 buckets have a significant impact.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be The differences or switch have to has

'xpack.ml.anomaliesTable.anomalyDetails.anomalyExplanationDetails.multiBucketTooltip.high',
{
defaultMessage:
'The difference between actual and typical values in the past 12 buckets have a high impact.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be The differences or switch have to has

Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

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

Latest changes LGTM

Copy link
Contributor

@darnautov darnautov left a comment

Choose a reason for hiding this comment

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

LGTM

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
ml 3.4MB 3.4MB +9.2KB
Unknown metric groups

API count

id before after diff
ml 251 254 +3

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @jgowdyelastic

@jgowdyelastic jgowdyelastic merged commit 6cfdd9d into elastic:main Oct 24, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Oct 24, 2022
@jgowdyelastic jgowdyelastic deleted the anomaly-score-explanation branch October 24, 2022 11:05
@peteharverson peteharverson added release_note:feature Makes this part of the condensed release notes and removed release_note:enhancement labels Nov 4, 2022
peteharverson added a commit that referenced this pull request Dec 7, 2022
…act (#146866)

## Summary

Follow-up to #142999, using the `multi_bucket_impact` field from the
`anomaly_score_explanation` data to populate the multi-bucket
information in the anomaly chart tooltip using the same visualization
style as used in the expanded table row.

<img width="1174" alt="image"
src="https://user-images.githubusercontent.com/7405507/205274876-b2007388-e37a-4f31-8c23-97fbac42f4d8.png">

The anomaly charts in the Anomaly Explorer and Single Metric Viewer, and
the severity cell in the anomalies table now use a new
`isMultiBucketAnomaly` check in `ml/common/util/anomaly_utils.ts`m to
determine whether to indicate the anomaly as multi-bucket with the
plus-shaped symbol. Note that this will result in some changes to
whether anomalies are plotted as multi-bucket anomalies. Specifically
anomalies with a 'moderate' multi-bucket impact are now likely to be
marked with a plus symbol where before they were not:

Before:
<img width="775" alt="image"
src="https://user-images.githubusercontent.com/7405507/205276861-613e0966-9041-4a77-a922-369bb0c6d3c3.png">

After:
<img width="809" alt="image"
src="https://user-images.githubusercontent.com/7405507/205277054-86895ab2-f5b1-42d4-a947-5d2cd5f3d82e.png">


### Checklist

Delete any items that are not applicable to this PR.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Anomaly Detection ML anomaly detection :ml release_note:feature Makes this part of the condensed release notes ui-copy Review of UI copy with docs team is recommended v8.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.