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] Fix sampling probability when switching between automatic and manual #150389

Merged
merged 14 commits into from
Feb 14, 2023

Conversation

qn895
Copy link
Member

@qn895 qn895 commented Feb 6, 2023

Summary

This PR fixes #146323 and addresses wrong initial label on sampling percentage slider. Change involves setting switching the EuiSlider to EuiSelect with 100% as the a new option. This means when switching from On - automatic or Off (where both are at 100%), switching to On - manual will by default switch to 0.001%.

Screen Shot 2023-02-07 at 17 20 31

Checklist

Delete any items that are not applicable to this PR.

@qn895 qn895 requested a review from a team as a code owner February 6, 2023 21:34
@qn895 qn895 self-assigned this Feb 6, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

Copy link
Member

@pheyos pheyos left a comment

Choose a reason for hiding this comment

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

Tested locally and could still produce the result described in #146323 with slightly extended steps:

  • Open an index in the data visualizer
  • In the random sampler popover switch to On - manual
    • here was the original issue and this is now working fine: displays 50% / 50
  • Select a different percentage, e.g. 25%
  • Switch the random sampling to Off
  • Switch the random sampling to On - manual again
    • => the percentage is set to 50% and the label displays 100

@peteharverson peteharverson changed the title Fix sampling probability when switching between automatic and manual [ML] Fix sampling probability when switching between automatic and manual Feb 8, 2023
@peteharverson
Copy link
Contributor

Some early feedback on using the range slider with the combined input - I like the potential the input provides for allowing more fine-grained control at the lower end of the scale (% less than 5).

  • Looks like the input currently only allows a step size of 1 so it isn't possible to e.g. edit from 1 to 0.01.
  • Edit the behavior so that an edit is only applied to the view either when the popover is closed, or by adding a 'Apply' button. Currently the view does a lot of unnecessary reloads as you move the slider or input up and down in value.

@qn895
Copy link
Member Author

qn895 commented Feb 9, 2023

Some early feedback on using the range slider with the combined input - I like the potential the input provides for allowing more fine-grained control at the lower end of the scale (% less than 5).

Thanks for the feedback. I have updated the slider & numerical input to allow any value between 0.001% to 50%. I also added an Apply button so that the value would only be updated when clicked. Once applied, switching to another mode and then back would restore the previously applied value.

Screen.Recording.2023-02-08.at.17.56.37.mov

Otherwise, for the first time switching from Off or On - automatic (where probability automatically set at 100%) to On - manual, it will default to 0.001%.

const isInvalidSamplingProbabilityInput =
!isDefined(samplingProbabilityInput) ||
isNaN(samplingProbabilityInput) ||
samplingProbabilityInput <= 0 ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the check here be <= 0.001? Currently you can enter a value less than this and see the red border on the input but the button is still enabled.

image

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for catching that. Fixed here 9dcd987 (#150389)

const prevValue = samplingProbabilityInput ? samplingProbabilityInput * 100 : value;

if (value > 0 && value <= 1) {
setSamplingProbabilityInput(value / 100);
Copy link
Contributor

Choose a reason for hiding this comment

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

I see occasional issues with the rounding here when using the up / down buttons. Not sure if this can be fixed by our code here?

Here I started at 0.01:

image

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for catching that. Updated here 9dcd987 (#150389)

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.

Overall looks good. Left a couple of comments.

@qn895 qn895 requested a review from walterra February 9, 2023 15:25
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.

Tested latest changes and LGTM.

@pheyos
Copy link
Member

pheyos commented Feb 10, 2023

Tested again locally on the latest changes and with the new control to select the sampling percentage, we don't have that originally raised label issue anymore. But I spotted another weird behavior where the marker position on the slider doesn't match the axis labeling when setting the value by clicking the axis / axis labels, while it's working fine when using the up/down buttons:
20230210_data_visualizer_sample_size

@qn895
Copy link
Member Author

qn895 commented Feb 14, 2023

@pheyos Thanks for catching that. Looks like it was an issue with the EUI show ticks & inputWithPopover setting. I've updated it to show the range on the two sides instead.

@pheyos
Copy link
Member

pheyos commented Feb 14, 2023

@qn895 Tested the latest changes locally and the above mentioned issue didn't occur anymore.
However, I have two follow-up usability observations:

  1. What is the grey bar above the slider? To me it doesn't seem to do anything and can be a bit distracting.
    image
  2. Slowly dragging the slider causes flickering on the slider label and "mini-resets" of slider values (e.g. slowly dragging it from 25 to 26 sometimes causes to show up the 26 shortly, then it's reset to 25).

Not sure if this is something we want to address at all and if we want to address it as part of this PR.

@qn895
Copy link
Member Author

qn895 commented Feb 14, 2023

@pheyos This seems to be an issue with EUI. If it's not a blocker, I think we can address this later.

Copy link
Contributor

@walterra walterra left a comment

Choose a reason for hiding this comment

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

LGTM, left just a small suggestion on possibly restructuring component nesting.

@@ -139,6 +118,18 @@ export const DocumentCountContent: FC<Props> = ({
</div>
) : null;

const CalculatingProbMessage =
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Suggest to make ProbabilityUsedMessage and CalculatingProbMessage React components on the outer level and not within that component.

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 here 1d0e2a6 (#150389)

@qn895 qn895 enabled auto-merge (squash) February 14, 2023 16:28
Copy link
Member

@pheyos pheyos left a comment

Choose a reason for hiding this comment

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

LGTM
As discussed above, we can look into the slider behavior separately.

@qn895 qn895 merged commit 7fe8154 into elastic:main Feb 14, 2023
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
dataVisualizer 303 304 +1

Async chunks

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

id before after diff
dataVisualizer 379.1KB 380.4KB +1.3KB
ml 3.5MB 3.5MB +38.0B
total +1.3KB
Unknown metric groups

ESLint disabled line counts

id before after diff
dataVisualizer 33 32 -1

Total ESLint disabled count

id before after diff
dataVisualizer 33 32 -1

History

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

cc @qn895

@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.7

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Feb 14, 2023
…and manual (#150389) (#151182)

# Backport

This will backport the following commits from `main` to `8.7`:
- [[ML] Fix sampling probability when switching between automatic and
manual (#150389)](#150389)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Quynh Nguyen
(Quinn)","email":"43350163+qn895@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-02-14T17:09:33Z","message":"[ML]
Fix sampling probability when switching between automatic and manual
(#150389)","sha":"7fe81548b3272b35d63b498e17188b9c56b1022a","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix",":ml","Feature:File
and Index Data
Viz","v8.7.0","v8.8.0"],"number":150389,"url":"#150389
Fix sampling probability when switching between automatic and manual
(#150389)","sha":"7fe81548b3272b35d63b498e17188b9c56b1022a"}},"sourceBranch":"main","suggestedTargetBranches":["8.7"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"#150389
Fix sampling probability when switching between automatic and manual
(#150389)","sha":"7fe81548b3272b35d63b498e17188b9c56b1022a"}}]}]
BACKPORT-->

Co-authored-by: Quynh Nguyen (Quinn) <43350163+qn895@users.noreply.github.com>
justinkambic pushed a commit to justinkambic/kibana that referenced this pull request Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ML] Index data visualizer - wrong initial label on sampling percentage slider
7 participants