-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Add decision path charts to exploration results table (#73561)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
20b2e31
commit 619108c
Showing
27 changed files
with
1,083 additions
and
125 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* 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 const DEFAULT_RESULTS_FIELD = 'ml'; |
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
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.