Skip to content

[ML] fix bugs with prediction field value settings#55333

Merged
benwtrent merged 3 commits intoelastic:masterfrom
benwtrent:feature/ml-inference-fix-parameter-values
Apr 17, 2020
Merged

[ML] fix bugs with prediction field value settings#55333
benwtrent merged 3 commits intoelastic:masterfrom
benwtrent:feature/ml-inference-fix-parameter-values

Conversation

@benwtrent
Copy link
Copy Markdown
Member

@benwtrent benwtrent commented Apr 16, 2020

This fixes two unreleased bugs:

  1. Prediction value type of number might show unexpected classes

Analytics created models may have class labels like 1, 5, 10 (or some collection of discrete, whole numbers). These labels are passed to the inference model config in the classification_labels field.

When the predicted value format is numeric it should attempt to see if the classification labels are provided and are numeric. If so, use those. If not, use the underlying value.

  1. When supplying an update overwrite, inference was losing the default prediction field value. This is because it was not copied over in the copy ctor in the ClassificationConfig.Builder class.

closes #55332

@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/ml-core (:ml)

@benwtrent benwtrent requested a review from przemekwitek April 17, 2020 11:50
@benwtrent
Copy link
Copy Markdown
Member Author

@elasticmachine update branch

Copy link
Copy Markdown

@przemekwitek przemekwitek left a comment

Choose a reason for hiding this comment

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

LGTM

}
// Quick check to verify that the string rep is LIKELY a number
// Still handles the case where it throws and then returns the underlying value
if (stringRep.charAt(0) == '-' || Character.isDigit(stringRep.charAt(0))) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could we just drop it and rely solely on parseLong?
Or is this some kind of perf optimization? If so, are you sure it is really faster?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It is way faster if stringRep is consistently not a number (which could easily be the case). Every call that it is not a number throws an exception, and the JVM has to build a trace.

@benwtrent benwtrent merged commit ba5a97d into elastic:master Apr 17, 2020
@benwtrent benwtrent deleted the feature/ml-inference-fix-parameter-values branch April 17, 2020 13:13
benwtrent added a commit to benwtrent/elasticsearch that referenced this pull request Apr 17, 2020
This fixes two unreleased bugs:

1. Prediction value type of `number` might show unexpected classes

Analytics created models may have class labels like `1, 5, 10` (or some collection of discrete, whole numbers). These labels are passed to the inference model config in the `classification_labels` field.

When the predicted value format is `numeric` it should attempt to see if the classification labels are provided and are numeric. If so, use those. If not, use the underlying value.

2. When supplying an update overwrite, inference was losing the default prediction field value. This is because it was not copied over in the copy ctor in the ClassificationConfig.Builder class. 

closes elastic#55332
benwtrent added a commit that referenced this pull request Apr 17, 2020
…5394)

* [ML] fix bugs with prediction field value settings (#55333)

This fixes two unreleased bugs:

1. Prediction value type of `number` might show unexpected classes

Analytics created models may have class labels like `1, 5, 10` (or some collection of discrete, whole numbers). These labels are passed to the inference model config in the `classification_labels` field.

When the predicted value format is `numeric` it should attempt to see if the classification labels are provided and are numeric. If so, use those. If not, use the underlying value.

2. When supplying an update overwrite, inference was losing the default prediction field value. This is because it was not copied over in the copy ctor in the ClassificationConfig.Builder class. 

closes #55332
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] Inference returns different predicted_value comparing with model prediction

4 participants