-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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] Add decision path charts to exploration results table #73561
Merged
Merged
Changes from 46 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
62e8918
[ML] Add decision path charts
qn895 031415f
[ML] Remove baseline div
qn895 40ef5e6
[ML] Move baseline logic to exploration results table
qn895 7e47db9
[ML] Fix type issues
qn895 e8d0b41
[ML] Improvements to data viz charts
qn895 5ad6690
[ML] Add info text
qn895 40f17cf
Merge remote-tracking branch 'upstream/master' into feature-importance
qn895 ea12a63
[ML] Change size to pass as Chart props
qn895 49a541c
[ML] Change to 3 sigfig instead of decimals
qn895 52964e5
[ML] Fix i18n issue
qn895 efbeffd
Merge remote-tracking branch 'upstream/master' into feature-importance
qn895 8b1e8c8
[ML] Decision path popover improvement + importance summary
qn895 e029cfc
Merge remote-tracking branch 'upstream/master' into feature-importance
qn895 19a1aae
[ML] Change title to fit summary
qn895 c718437
[ML] Consolidate feature importance
qn895 d0fa245
[ML] useMemo for popoverContent
qn895 a317505
[ML] Add adjustment to baseline
qn895 973ddb9
[ML] Call /baseline only if it's a regression analysis for now
qn895 1c22df3
Merge remote-tracking branch 'upstream/master' into feature-importance
qn895 f248722
Merge remote-tracking branch 'upstream/master' into feature-importance
qn895 39e3749
[ML] Remove feature importance summary bars for now
qn895 0c57415
[ML] Update types
qn895 6b525b4
[ML] Update types for popOverContent
qn895 c7bd561
Merge remote-tracking branch 'upstream/master' into feature-importance
qn895 c9261a4
[ML] Refactor to support classification DFA
qn895 38a5e48
[ML] Update filteredFeatureImportance
qn895 c6cf181
[ML] Add improvement to decision path chart
qn895 175bfd4
[ML] Refactor feature_importance to have own model & add error handling
qn895 c5b68d5
[ML] Remove getDataFrameAnalyticsBaselineSchema and body
qn895 0970f04
Merge remote-tracking branch 'upstream/master' into feature-importance
qn895 0fa835f
[ML] Update typo at the predicted value
qn895 669c683
[ML] Remove duplicate code in dfa creation
qn895 eccdb4d
[ML] Fix datagrid popover pagination crash
qn895 049ba5a
[ML] Fix domain calc not working reliably
qn895 172a58e
Merge remote-tracking branch 'upstream/master' into feature-importance
qn895 ef815d1
[ML] Minor refactoring
qn895 74ef5fd
[ML] Fix so classification support boolean class names
qn895 eaae596
[ML] Fix better height and change to empty annotation marker
qn895 b50daae
Merge remote-tracking branch 'upstream/master' into feature-importance
qn895 9aa5d81
[ML] Adjust style & precision header for baseline
qn895 a71e190
[ML] Update grid and header
qn895 9f435f6
Merge remote-tracking branch 'upstream/master' into feature-importance
qn895 a954cc6
[ML] Update to new client & more strict conversion
qn895 09495e3
[ML] Fix type
qn895 1345cf2
[ML] Update tolerance to check for abs difference
qn895 76488b6
Merge remote-tracking branch 'upstream/master' into feature-importance
qn895 a93e740
[ML] Change to DEFAULT_RESULTS_FIELD
qn895 004518b
Merge remote-tracking branch 'upstream/master' into feature-importance
qn895 5fd5ff4
[ML] Update doc link, tick formatter, and baseline api for generic re…
qn895 b857ffe
Merge branch 'master' into feature-importance
elasticmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export interface ClassFeatureImportance { | ||
class_name: string | boolean; | ||
importance: number; | ||
} | ||
export interface FeatureImportance { | ||
feature_name: string; | ||
importance?: number; | ||
classes?: ClassFeatureImportance[]; | ||
} | ||
|
||
export interface TopClass { | ||
class_name: string; | ||
class_probability: number; | ||
class_score: number; | ||
} | ||
|
||
export type TopClasses = TopClass[]; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { | ||
AnalysisConfig, | ||
ClassificationAnalysis, | ||
OutlierAnalysis, | ||
RegressionAnalysis, | ||
ANALYSIS_CONFIG_TYPE, | ||
} from '../types/data_frame_analytics'; | ||
|
||
export const isOutlierAnalysis = (arg: any): arg is OutlierAnalysis => { | ||
const keys = Object.keys(arg); | ||
return keys.length === 1 && keys[0] === ANALYSIS_CONFIG_TYPE.OUTLIER_DETECTION; | ||
}; | ||
|
||
export const isRegressionAnalysis = (arg: any): arg is RegressionAnalysis => { | ||
const keys = Object.keys(arg); | ||
return keys.length === 1 && keys[0] === ANALYSIS_CONFIG_TYPE.REGRESSION; | ||
}; | ||
|
||
export const isClassificationAnalysis = (arg: any): arg is ClassificationAnalysis => { | ||
const keys = Object.keys(arg); | ||
return keys.length === 1 && keys[0] === ANALYSIS_CONFIG_TYPE.CLASSIFICATION; | ||
}; | ||
|
||
export const getDependentVar = ( | ||
analysis: AnalysisConfig | ||
): | ||
| RegressionAnalysis['regression']['dependent_variable'] | ||
| ClassificationAnalysis['classification']['dependent_variable'] => { | ||
let depVar = ''; | ||
|
||
if (isRegressionAnalysis(analysis)) { | ||
depVar = analysis.regression.dependent_variable; | ||
} | ||
|
||
if (isClassificationAnalysis(analysis)) { | ||
depVar = analysis.classification.dependent_variable; | ||
} | ||
return depVar; | ||
}; | ||
|
||
export const getPredictionFieldName = ( | ||
analysis: AnalysisConfig | ||
): | ||
| RegressionAnalysis['regression']['prediction_field_name'] | ||
| ClassificationAnalysis['classification']['prediction_field_name'] => { | ||
// If undefined will be defaulted to dependent_variable when config is created | ||
let predictionFieldName; | ||
if (isRegressionAnalysis(analysis) && analysis.regression.prediction_field_name !== undefined) { | ||
predictionFieldName = analysis.regression.prediction_field_name; | ||
} else if ( | ||
isClassificationAnalysis(analysis) && | ||
analysis.classification.prediction_field_name !== undefined | ||
) { | ||
predictionFieldName = analysis.classification.prediction_field_name; | ||
} | ||
return predictionFieldName; | ||
}; | ||
|
||
export const getDefaultPredictionFieldName = (analysis: AnalysisConfig) => { | ||
return `${getDependentVar(analysis)}_prediction`; | ||
}; | ||
export const getPredictedFieldName = ( | ||
resultsField: string, | ||
analysis: AnalysisConfig, | ||
forSort?: boolean | ||
) => { | ||
// default is 'ml' | ||
const predictionFieldName = getPredictionFieldName(analysis); | ||
const predictedField = `${resultsField}.${ | ||
predictionFieldName ? predictionFieldName : getDefaultPredictionFieldName(analysis) | ||
}`; | ||
return predictedField; | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,13 +119,14 @@ export const getDataGridSchemasFromFieldTypes = (fieldTypes: FieldTypes, results | |
schema = 'numeric'; | ||
} | ||
|
||
if ( | ||
field.includes(`${resultsField}.${FEATURE_IMPORTANCE}`) || | ||
field.includes(`${resultsField}.${TOP_CLASSES}`) | ||
) { | ||
if (field.includes(`${resultsField}.${TOP_CLASSES}`)) { | ||
schema = 'json'; | ||
} | ||
|
||
if (field.includes(`${resultsField}.${FEATURE_IMPORTANCE}`)) { | ||
schema = 'featureImportance'; | ||
} | ||
|
||
return { id: field, schema, isSortable }; | ||
}); | ||
}; | ||
|
@@ -250,10 +251,6 @@ export const useRenderCellValue = ( | |
return cellValue ? 'true' : 'false'; | ||
} | ||
|
||
if (typeof cellValue === 'object' && cellValue !== null) { | ||
return JSON.stringify(cellValue); | ||
} | ||
|
||
Comment on lines
-253
to
-256
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain why this is no longer necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like this line is a duplicate of line 228 of this file so I removed it. This change shouldn't cause any issue :) |
||
return cellValue; | ||
}; | ||
}, [indexPattern?.fields, pagination.pageIndex, pagination.pageSize, tableItems]); | ||
|
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider using const instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just talked to Melissa and since
ANALYSIS_CONFIG_TYPE
is used in a quite a lot of place, I think it's better to do this in a follow-up PR.