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] DF Regression: fix custom results_field and prediction_field_name not considered in eval config #48599

Merged

Conversation

alvarezmelissa87
Copy link
Contributor

@alvarezmelissa87 alvarezmelissa87 commented Oct 18, 2019

Summary

This PR takes into account a custom results_field and prediction_field_name that could be set by the user using the advanced editor when creating a regression job.

The custom fields are used if set when creating the payload for the /_evaluate endpoint. Default 'ml' results_field is used when one is not set. <dependent_variable>_prediction is used when prediction_field_name is not set.

  • Disables create button if job is regression type and dependent_variable has not been set

image

image

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

- [ ] This was checked for breaking API changes and was labeled appropriately
- [ ] This includes a feature addition or change that requires a release note and was labeled appropriately

@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@alvarezmelissa87 alvarezmelissa87 removed the request for review from jgowdyelastic October 18, 2019 02:57
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

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.

Added a question about getPredictionFieldName().

@@ -81,6 +82,15 @@ export const getDependentVar = (analysis: AnalysisConfig) => {
return depVar;
};

export const getPredictionFieldName = (analysis: AnalysisConfig) => {
// Default to dependent_variable
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment here says Default to dependent_variable but I don't see that happening, is this comment meant as a TODO or does it happen somewhere else?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd also suggest having all comments as tsdoc for functions. More convenient to look up in IDE and let us generate the code documentation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good one @walterra - I've clarified this comment in 695aaed

I just wanted to make it clear that if prediction_field_name is not defined/set it will be defaulted to dependent_variable when the config is created.

@darnautov - good suggestion, though in this case it's just more of an FYI comment for where this is used. Also I think TypeScript kind of accomplishes the same functionality by defining the parameters, return value, etc. 🤔

Comment on lines 217 to 219
const query = { term: {} };
// @ts-ignore TODO: fix types here
query.term[`${resultsField}.is_training`] = { value: isTraining };
Copy link
Contributor

Choose a reason for hiding this comment

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

You could try to do the original assignment with the computed property name:

const query = { term: { [`${resultsField}.is_training`]: { value: isTraining } } }'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice suggestion! Updated in 695aaed

@@ -81,6 +82,15 @@ export const getDependentVar = (analysis: AnalysisConfig) => {
return depVar;
};

export const getPredictionFieldName = (analysis: AnalysisConfig) => {
// Default to dependent_variable
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd also suggest having all comments as tsdoc for functions. More convenient to look up in IDE and let us generate the code documentation

getValuesFromResponse,
loadEvalData,
Eval,
} from '../../../../common';
import { isCompletedAnalyticsJob } from './common';
import { isRegressionAnalysis } from '../../../../common/analytics';
// import { ExpandedRowMessagesPane } from './expanded_row_messages_pane';
Copy link
Contributor

Choose a reason for hiding this comment

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

commented import (not part of the changes, but should be removed I guess)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this was added in the original code for when the messages become available - which I think they are now if not very soon. I think it's worth keeping in as it will be used very soon. 😄

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.

Latest changes LGTM

@alvarezmelissa87 alvarezmelissa87 mentioned this pull request Oct 18, 2019
46 tasks
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

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

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.

One comment about prediction_field_name needing to be set, but otherwise tested this and LGTM

}) => {
const results: LoadEvaluateResult = { success: false, eval: null, error: null };
const defaultPredictionField = `${dependentVariable}_prediction`;
Copy link
Contributor

Choose a reason for hiding this comment

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

When testing this I noticed that it is possible to create a job without entering the prediction_field_name. The Create button should be disabled unless they have entered a prediction_field_name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The prediction_field_name is optional (defaults to whatever <dependent_variable>_prediction) - do you mean the dependent_variable? If so that was fixed in this commit : df6b171

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@alvarezmelissa87 alvarezmelissa87 merged commit 00c21dc into elastic:master Oct 19, 2019
alvarezmelissa87 added a commit to alvarezmelissa87/kibana that referenced this pull request Oct 19, 2019
…e not considered in eval config (elastic#48599)

* consider results_field and prediction_field_name in eval congif

* temp typescript fix for evaluatePanel not being used yet

* fix typescript error. clarify comment

* Disable create button if dependentVariable not set

* ensure advancedEditor json valid at every change

* update reducer test
alvarezmelissa87 added a commit to alvarezmelissa87/kibana that referenced this pull request Oct 19, 2019
…e not considered in eval config (elastic#48599)

* consider results_field and prediction_field_name in eval congif

* temp typescript fix for evaluatePanel not being used yet

* fix typescript error. clarify comment

* Disable create button if dependentVariable not set

* ensure advancedEditor json valid at every change

* update reducer test
alvarezmelissa87 added a commit that referenced this pull request Oct 20, 2019
…e not considered in eval config (#48599) (#48714)

* consider results_field and prediction_field_name in eval congif

* temp typescript fix for evaluatePanel not being used yet

* fix typescript error. clarify comment

* Disable create button if dependentVariable not set

* ensure advancedEditor json valid at every change

* update reducer test
alvarezmelissa87 added a commit that referenced this pull request Oct 20, 2019
…e not considered in eval config (#48599) (#48713)

* consider results_field and prediction_field_name in eval congif

* temp typescript fix for evaluatePanel not being used yet

* fix typescript error. clarify comment

* Disable create button if dependentVariable not set

* ensure advancedEditor json valid at every change

* update reducer test
@alvarezmelissa87 alvarezmelissa87 deleted the ml-regression-results-field branch October 21, 2019 18:48
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.

5 participants