mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[ML] Package @kbn/ml-data-frame-analytics-utils
(#155976)
Creates Package `@kbn/ml-data-frame-analytics-utils` via `node scripts/generate package @kbn/ml-data-frame-analytics-utils --web --dir ./x-pack/packages/ml/data_frame_analytics_utils`. Moves some of the constants, types and utilities for Data Frame Analytics to its own package. This is in preparation to move our data grid related code to a package too. Since this code for now is only used by our team I didn't do any renaming related to for example consistent prefixing, this should be revisited in a follow up. Another opportunity for a follow up might be a clean up of the types and check which ones can be replaced by types from `estypes`.
This commit is contained in:
parent
8d399fe3aa
commit
9febf5de21
154 changed files with 2247 additions and 1185 deletions
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
|
@ -461,6 +461,7 @@ x-pack/plugins/maps @elastic/kibana-gis
|
|||
x-pack/packages/maps/vector_tile_utils @elastic/kibana-gis
|
||||
x-pack/packages/ml/agg_utils @elastic/ml-ui
|
||||
x-pack/packages/ml/anomaly_utils @elastic/ml-ui
|
||||
x-pack/packages/ml/data_frame_analytics_utils @elastic/ml-ui
|
||||
x-pack/packages/ml/date_picker @elastic/ml-ui
|
||||
x-pack/packages/ml/error_utils @elastic/ml-ui
|
||||
x-pack/packages/ml/is_defined @elastic/ml-ui
|
||||
|
|
|
@ -477,6 +477,7 @@
|
|||
"@kbn/maps-vector-tile-utils": "link:x-pack/packages/maps/vector_tile_utils",
|
||||
"@kbn/ml-agg-utils": "link:x-pack/packages/ml/agg_utils",
|
||||
"@kbn/ml-anomaly-utils": "link:x-pack/packages/ml/anomaly_utils",
|
||||
"@kbn/ml-data-frame-analytics-utils": "link:x-pack/packages/ml/data_frame_analytics_utils",
|
||||
"@kbn/ml-date-picker": "link:x-pack/packages/ml/date_picker",
|
||||
"@kbn/ml-error-utils": "link:x-pack/packages/ml/error_utils",
|
||||
"@kbn/ml-is-defined": "link:x-pack/packages/ml/is_defined",
|
||||
|
|
|
@ -916,6 +916,8 @@
|
|||
"@kbn/ml-agg-utils/*": ["x-pack/packages/ml/agg_utils/*"],
|
||||
"@kbn/ml-anomaly-utils": ["x-pack/packages/ml/anomaly_utils"],
|
||||
"@kbn/ml-anomaly-utils/*": ["x-pack/packages/ml/anomaly_utils/*"],
|
||||
"@kbn/ml-data-frame-analytics-utils": ["x-pack/packages/ml/data_frame_analytics_utils"],
|
||||
"@kbn/ml-data-frame-analytics-utils/*": ["x-pack/packages/ml/data_frame_analytics_utils/*"],
|
||||
"@kbn/ml-date-picker": ["x-pack/packages/ml/date_picker"],
|
||||
"@kbn/ml-date-picker/*": ["x-pack/packages/ml/date_picker/*"],
|
||||
"@kbn/ml-error-utils": ["x-pack/packages/ml/error_utils"],
|
||||
|
|
3
x-pack/packages/ml/data_frame_analytics_utils/README.md
Normal file
3
x-pack/packages/ml/data_frame_analytics_utils/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# @kbn/ml-data-frame-analytics-utils
|
||||
|
||||
Utility functions, constants and types for Machine Learning's Data Frame Analytics.
|
98
x-pack/packages/ml/data_frame_analytics_utils/index.ts
Normal file
98
x-pack/packages/ml/data_frame_analytics_utils/index.ts
Normal file
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
export {
|
||||
getAnalysisType,
|
||||
getDefaultPredictionFieldName,
|
||||
getDependentVar,
|
||||
getTrainingPercent,
|
||||
getPredictionFieldName,
|
||||
isClassificationAnalysis,
|
||||
isOutlierAnalysis,
|
||||
isRegressionAnalysis,
|
||||
} from './src/analytics_utils';
|
||||
|
||||
export {
|
||||
ANALYSIS_ADVANCED_FIELDS,
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
DATA_FRAME_TASK_STATE,
|
||||
DEFAULT_RESULTS_FIELD,
|
||||
FEATURE_IMPORTANCE,
|
||||
FEATURE_INFLUENCE,
|
||||
INDEX_CREATED_BY,
|
||||
INDEX_STATUS,
|
||||
JOB_MAP_NODE_TYPES,
|
||||
NUM_TOP_FEATURE_IMPORTANCE_VALUES_MIN,
|
||||
OUTLIER_ANALYSIS_METHOD,
|
||||
OUTLIER_SCORE,
|
||||
TOP_CLASSES,
|
||||
TRAINING_PERCENT_MIN,
|
||||
TRAINING_PERCENT_MAX,
|
||||
type JobMapNodeTypes,
|
||||
} from './src/constants';
|
||||
|
||||
export {
|
||||
type ClassFeatureImportance,
|
||||
type ClassFeatureImportanceSummary,
|
||||
type ClassificationFeatureImportanceBaseline,
|
||||
type ClassificationTotalFeatureImportance,
|
||||
type FeatureImportance,
|
||||
type FeatureImportanceBaseline,
|
||||
type FeatureImportanceClassBaseline,
|
||||
type FeatureImportanceClassName,
|
||||
type RegressionFeatureImportanceBaseline,
|
||||
type RegressionFeatureImportanceSummary,
|
||||
type RegressionTotalFeatureImportance,
|
||||
type TotalFeatureImportance,
|
||||
type TopClass,
|
||||
type TopClasses,
|
||||
isClassificationFeatureImportanceBaseline,
|
||||
isClassificationTotalFeatureImportance,
|
||||
isRegressionFeatureImportanceBaseline,
|
||||
isRegressionTotalFeatureImportance,
|
||||
} from './src/feature_importance';
|
||||
|
||||
export {
|
||||
sortExplorationResultsFields,
|
||||
BASIC_NUMERICAL_TYPES,
|
||||
DEFAULT_REGRESSION_COLUMNS,
|
||||
EXTENDED_NUMERICAL_TYPES,
|
||||
ML__ID_COPY,
|
||||
ML__INCREMENTAL_ID,
|
||||
} from './src/fields';
|
||||
|
||||
export { getNumTopClasses } from './src/get_num_top_classes';
|
||||
export { getNumTopFeatureImportanceValues } from './src/get_num_top_feature_importance_values';
|
||||
|
||||
export {
|
||||
isDataFrameAnalyticsConfigs,
|
||||
type AnalysisConfig,
|
||||
type AnalyticsMapEdgeElement,
|
||||
type AnalyticsMapReturnType,
|
||||
type AnalyticsMapNodeElement,
|
||||
type ConfusionMatrix,
|
||||
type ClassificationEvaluateResponse,
|
||||
type ClassificationAnalysis,
|
||||
type DataFrameAnalyticsConfig,
|
||||
type DataFrameAnalysisConfigType,
|
||||
type DataFrameAnalyticsId,
|
||||
type DataFrameAnalyticsMeta,
|
||||
type DataFrameAnalyticsStats,
|
||||
type DataFrameTaskStateType,
|
||||
type DeleteDataFrameAnalyticsWithIndexStatus,
|
||||
type DfAnalyticsExplainResponse,
|
||||
type EvaluateMetrics,
|
||||
type FeatureProcessor,
|
||||
type FieldSelectionItem,
|
||||
type MapElements,
|
||||
type OutlierAnalysis,
|
||||
type RegressionAnalysis,
|
||||
type UpdateDataFrameAnalyticsConfig,
|
||||
type RocCurveItem,
|
||||
type TrackTotalHitsSearchResponse,
|
||||
type PredictedClass,
|
||||
} from './src/types';
|
|
@ -5,7 +5,8 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
export const FEATURE_IMPORTANCE = 'feature_importance';
|
||||
export const FEATURE_INFLUENCE = 'feature_influence';
|
||||
export const TOP_CLASSES = 'top_classes';
|
||||
export const OUTLIER_SCORE = 'outlier_score';
|
||||
module.exports = {
|
||||
preset: '@kbn/test',
|
||||
rootDir: '../../../..',
|
||||
roots: ['<rootDir>/x-pack/packages/ml/data_frame_analytics_utils'],
|
||||
};
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type": "shared-common",
|
||||
"id": "@kbn/ml-data-frame-analytics-utils",
|
||||
"owner": "@elastic/ml-ui"
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "@kbn/ml-data-frame-analytics-utils",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"license": "Elastic License 2.0"
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { getAnalysisType, isOutlierAnalysis } from './analytics_utils';
|
||||
|
||||
describe('Data Frame Analytics: Analytics utils', () => {
|
||||
test('getAnalysisType()', () => {
|
||||
const outlierAnalysis = { outlier_detection: {} };
|
||||
expect(getAnalysisType(outlierAnalysis)).toBe('outlier_detection');
|
||||
|
||||
const regressionAnalysis = { regression: {} };
|
||||
// @ts-expect-error incomplete regression analysis
|
||||
expect(getAnalysisType(regressionAnalysis)).toBe('regression');
|
||||
|
||||
// test against a job type that does not exist yet.
|
||||
const otherAnalysis = { other: {} };
|
||||
// @ts-expect-error unknown analysis type
|
||||
expect(getAnalysisType(otherAnalysis)).toBe('other');
|
||||
|
||||
// if the analysis object has a shape that is not just a single property,
|
||||
// the job type will be returned as 'unknown'.
|
||||
const unknownAnalysis = { outlier_detection: {}, regression: {} };
|
||||
// @ts-expect-error unknown analysis type
|
||||
expect(getAnalysisType(unknownAnalysis)).toBe('unknown');
|
||||
});
|
||||
|
||||
test('isOutlierAnalysis()', () => {
|
||||
const outlierAnalysis = { outlier_detection: {} };
|
||||
expect(isOutlierAnalysis(outlierAnalysis)).toBe(true);
|
||||
|
||||
const regressionAnalysis = { regression: {} };
|
||||
expect(isOutlierAnalysis(regressionAnalysis)).toBe(false);
|
||||
|
||||
const unknownAnalysis = { outlier_detection: {}, regression: {} };
|
||||
expect(isOutlierAnalysis(unknownAnalysis)).toBe(false);
|
||||
});
|
||||
});
|
|
@ -5,33 +5,57 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import {
|
||||
import { ANALYSIS_CONFIG_TYPE } from './constants';
|
||||
import type {
|
||||
AnalysisConfig,
|
||||
ClassificationAnalysis,
|
||||
OutlierAnalysis,
|
||||
RegressionAnalysis,
|
||||
} from '../types/data_frame_analytics';
|
||||
import { ANALYSIS_CONFIG_TYPE } from '../constants/data_frame_analytics';
|
||||
import { DataFrameAnalysisConfigType } from '../types/data_frame_analytics';
|
||||
DataFrameAnalysisConfigType,
|
||||
} from './types';
|
||||
|
||||
export const isOutlierAnalysis = (arg: any): arg is OutlierAnalysis => {
|
||||
/**
|
||||
* Type guard for DFA outlier analysis configurations
|
||||
*
|
||||
* @param {unknown} arg The config to identify
|
||||
* @returns {arg is OutlierAnalysis}
|
||||
*/
|
||||
export const isOutlierAnalysis = (arg: unknown): arg is OutlierAnalysis => {
|
||||
if (typeof arg !== 'object' || arg === null) return false;
|
||||
const keys = Object.keys(arg);
|
||||
return keys.length === 1 && keys[0] === ANALYSIS_CONFIG_TYPE.OUTLIER_DETECTION;
|
||||
};
|
||||
|
||||
export const isRegressionAnalysis = (arg: any): arg is RegressionAnalysis => {
|
||||
/**
|
||||
* Type guard for DFA regression analysis configurations
|
||||
*
|
||||
* @param {unknown} arg The config to identify
|
||||
* @returns {arg is RegressionAnalysis}
|
||||
*/
|
||||
export const isRegressionAnalysis = (arg: unknown): arg is RegressionAnalysis => {
|
||||
if (typeof arg !== 'object' || arg === null) return false;
|
||||
const keys = Object.keys(arg);
|
||||
return keys.length === 1 && keys[0] === ANALYSIS_CONFIG_TYPE.REGRESSION;
|
||||
};
|
||||
|
||||
export const isClassificationAnalysis = (arg: any): arg is ClassificationAnalysis => {
|
||||
/**
|
||||
* Type guard for DFA classification analysis configurations
|
||||
*
|
||||
* @param {unknown} arg The config to identify
|
||||
* @returns {arg is ClassificationAnalysis}
|
||||
*/
|
||||
export const isClassificationAnalysis = (arg: unknown): arg is ClassificationAnalysis => {
|
||||
if (typeof arg !== 'object' || arg === null) return false;
|
||||
const keys = Object.keys(arg);
|
||||
return keys.length === 1 && keys[0] === ANALYSIS_CONFIG_TYPE.CLASSIFICATION;
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function to get the dependent variable of a DFA configuration
|
||||
*
|
||||
* @param {AnalysisConfig} analysis The analysis configuration
|
||||
* @returns {(| RegressionAnalysis['regression']['dependent_variable'] | ClassificationAnalysis['classification']['dependent_variable'])}
|
||||
*/
|
||||
export const getDependentVar = (
|
||||
analysis: AnalysisConfig
|
||||
):
|
||||
|
@ -49,6 +73,12 @@ export const getDependentVar = (
|
|||
return depVar;
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function to get the prediction field name of a DFA configuration
|
||||
*
|
||||
* @param {AnalysisConfig} analysis The analysis configuration
|
||||
* @returns {(| RegressionAnalysis['regression']['prediction_field_name'] | ClassificationAnalysis['classification']['prediction_field_name'])}
|
||||
*/
|
||||
export const getPredictionFieldName = (
|
||||
analysis: AnalysisConfig
|
||||
):
|
||||
|
@ -67,9 +97,24 @@ export const getPredictionFieldName = (
|
|||
return predictionFieldName;
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function to get the default prediction field name
|
||||
*
|
||||
* @param {AnalysisConfig} analysis The analysis configuration
|
||||
* @returns {string}
|
||||
*/
|
||||
export const getDefaultPredictionFieldName = (analysis: AnalysisConfig) => {
|
||||
return `${getDependentVar(analysis)}_prediction`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function to get the predicted field name
|
||||
*
|
||||
* @param {string} resultsField
|
||||
* @param {AnalysisConfig} analysis The analysis configuration
|
||||
* @param {?boolean} [forSort]
|
||||
* @returns {string}
|
||||
*/
|
||||
export const getPredictedFieldName = (
|
||||
resultsField: string,
|
||||
analysis: AnalysisConfig,
|
||||
|
@ -83,6 +128,12 @@ export const getPredictedFieldName = (
|
|||
return predictedField;
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function to get the analysis type of a DFA configuration
|
||||
*
|
||||
* @param {AnalysisConfig} analysis The analysis configuration
|
||||
* @returns {(DataFrameAnalysisConfigType | 'unknown')}
|
||||
*/
|
||||
export const getAnalysisType = (
|
||||
analysis: AnalysisConfig
|
||||
): DataFrameAnalysisConfigType | 'unknown' => {
|
||||
|
@ -94,3 +145,27 @@ export const getAnalysisType = (
|
|||
|
||||
return 'unknown';
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function to get the training percent of a DFA configuration
|
||||
*
|
||||
* @param {AnalysisConfig} analysis The analysis configuration
|
||||
* @returns {(| RegressionAnalysis['regression']['training_percent'] | ClassificationAnalysis['classification']['training_percent'] | undefined)}
|
||||
*/
|
||||
export const getTrainingPercent = (
|
||||
analysis: AnalysisConfig
|
||||
):
|
||||
| RegressionAnalysis['regression']['training_percent']
|
||||
| ClassificationAnalysis['classification']['training_percent']
|
||||
| undefined => {
|
||||
let trainingPercent;
|
||||
|
||||
if (isRegressionAnalysis(analysis)) {
|
||||
trainingPercent = analysis.regression.training_percent;
|
||||
}
|
||||
|
||||
if (isClassificationAnalysis(analysis)) {
|
||||
trainingPercent = analysis.classification.training_percent;
|
||||
}
|
||||
return trainingPercent;
|
||||
};
|
170
x-pack/packages/ml/data_frame_analytics_utils/src/constants.ts
Normal file
170
x-pack/packages/ml/data_frame_analytics_utils/src/constants.ts
Normal file
|
@ -0,0 +1,170 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Custom enum for DFA config types
|
||||
*
|
||||
* @type {{ readonly OUTLIER_DETECTION: "outlier_detection"; readonly REGRESSION: "regression"; readonly CLASSIFICATION: "classification"; }}
|
||||
*/
|
||||
export const ANALYSIS_CONFIG_TYPE = {
|
||||
OUTLIER_DETECTION: 'outlier_detection',
|
||||
REGRESSION: 'regression',
|
||||
CLASSIFICATION: 'classification',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Custom enum for DFA task states
|
||||
*
|
||||
* @type {{ readonly ANALYZING: "analyzing"; readonly FAILED: "failed"; readonly REINDEXING: "reindexing"; readonly STARTED: "started"; readonly STARTING: "starting"; readonly STOPPED: "stopped"; }}
|
||||
*/
|
||||
export const DATA_FRAME_TASK_STATE = {
|
||||
ANALYZING: 'analyzing',
|
||||
FAILED: 'failed',
|
||||
REINDEXING: 'reindexing',
|
||||
STARTED: 'started',
|
||||
STARTING: 'starting',
|
||||
STOPPED: 'stopped',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Default results field
|
||||
*
|
||||
* @type {"ml"}
|
||||
*/
|
||||
export const DEFAULT_RESULTS_FIELD = 'ml';
|
||||
|
||||
/**
|
||||
* Custom enum for job map node types for the DFA map view
|
||||
*
|
||||
* @type {{ readonly ANALYTICS: "analytics"; readonly TRANSFORM: "transform"; readonly INDEX: "index"; readonly TRAINED_MODEL: "trainedModel"; }}
|
||||
*/
|
||||
export const JOB_MAP_NODE_TYPES = {
|
||||
ANALYTICS: 'analytics',
|
||||
TRANSFORM: 'transform',
|
||||
INDEX: 'index',
|
||||
TRAINED_MODEL: 'trainedModel',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Union type of JOB_MAP_NODE_TYPES
|
||||
*
|
||||
* @export
|
||||
* @typedef {JobMapNodeTypes}
|
||||
*/
|
||||
export type JobMapNodeTypes = typeof JOB_MAP_NODE_TYPES[keyof typeof JOB_MAP_NODE_TYPES];
|
||||
|
||||
/**
|
||||
* Custom enum for the metadata to be stored about which tool was used to create an index
|
||||
*
|
||||
* @type {{ readonly FILE_DATA_VISUALIZER: "file-data-visualizer"; readonly DATA_FRAME_ANALYTICS: "data-frame-analytics"; }}
|
||||
*/
|
||||
export const INDEX_CREATED_BY = {
|
||||
FILE_DATA_VISUALIZER: 'file-data-visualizer',
|
||||
DATA_FRAME_ANALYTICS: 'data-frame-analytics',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Feature importance constant
|
||||
*
|
||||
* @type {"feature_importance"}
|
||||
*/
|
||||
export const FEATURE_IMPORTANCE = 'feature_importance';
|
||||
|
||||
/**
|
||||
* Feature influence constant
|
||||
*
|
||||
* @type {"feature_influence"}
|
||||
*/
|
||||
export const FEATURE_INFLUENCE = 'feature_influence';
|
||||
|
||||
/**
|
||||
* Top classes constant
|
||||
*
|
||||
* @type {"top_classes"}
|
||||
*/
|
||||
export const TOP_CLASSES = 'top_classes';
|
||||
|
||||
/**
|
||||
* Outlier score constant
|
||||
*
|
||||
* @type {"outlier_score"}
|
||||
*/
|
||||
export const OUTLIER_SCORE = 'outlier_score';
|
||||
|
||||
/**
|
||||
* Enum for a DFA configuration's advanced fields
|
||||
*
|
||||
* @export
|
||||
* @enum {number}
|
||||
*/
|
||||
export enum ANALYSIS_ADVANCED_FIELDS {
|
||||
ALPHA = 'alpha',
|
||||
ETA = 'eta',
|
||||
ETA_GROWTH_RATE_PER_TREE = 'eta_growth_rate_per_tree',
|
||||
DOWNSAMPLE_FACTOR = 'downsample_factor',
|
||||
FEATURE_BAG_FRACTION = 'feature_bag_fraction',
|
||||
FEATURE_INFLUENCE_THRESHOLD = 'feature_influence_threshold',
|
||||
GAMMA = 'gamma',
|
||||
LAMBDA = 'lambda',
|
||||
MAX_TREES = 'max_trees',
|
||||
MAX_OPTIMIZATION_ROUNDS_PER_HYPERPARAMETER = 'max_optimization_rounds_per_hyperparameter',
|
||||
METHOD = 'method',
|
||||
N_NEIGHBORS = 'n_neighbors',
|
||||
NUM_TOP_CLASSES = 'num_top_classes',
|
||||
NUM_TOP_FEATURE_IMPORTANCE_VALUES = 'num_top_feature_importance_values',
|
||||
OUTLIER_FRACTION = 'outlier_fraction',
|
||||
RANDOMIZE_SEED = 'randomize_seed',
|
||||
SOFT_TREE_DEPTH_LIMIT = 'soft_tree_depth_limit',
|
||||
SOFT_TREE_DEPTH_TOLERANCE = 'soft_tree_depth_tolerance',
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum for a DFA configuration's outlier analysis method
|
||||
*
|
||||
* @export
|
||||
* @enum {number}
|
||||
*/
|
||||
export enum OUTLIER_ANALYSIS_METHOD {
|
||||
LOF = 'lof',
|
||||
LDOF = 'ldof',
|
||||
DISTANCE_KTH_NN = 'distance_kth_nn',
|
||||
DISTANCE_KNN = 'distance_knn',
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimum value for feature importance
|
||||
*
|
||||
* @type {0}
|
||||
*/
|
||||
export const NUM_TOP_FEATURE_IMPORTANCE_VALUES_MIN = 0;
|
||||
|
||||
/**
|
||||
* Minimum training percent
|
||||
*
|
||||
* @type {1}
|
||||
*/
|
||||
export const TRAINING_PERCENT_MIN = 1;
|
||||
|
||||
/**
|
||||
* Maximum training percent
|
||||
*
|
||||
* @type {100}
|
||||
*/
|
||||
export const TRAINING_PERCENT_MAX = 100;
|
||||
|
||||
/**
|
||||
* Enum for index status
|
||||
*
|
||||
* @export
|
||||
* @enum {number}
|
||||
*/
|
||||
export enum INDEX_STATUS {
|
||||
UNUSED,
|
||||
LOADING,
|
||||
LOADED,
|
||||
ERROR,
|
||||
}
|
|
@ -0,0 +1,308 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { isPopulatedObject } from '@kbn/ml-is-populated-object';
|
||||
|
||||
/**
|
||||
* Union type for ES result feature importance class name
|
||||
*
|
||||
* @export
|
||||
* @typedef {FeatureImportanceClassName}
|
||||
*/
|
||||
export type FeatureImportanceClassName = string | number | boolean;
|
||||
|
||||
/**
|
||||
* ES result class feature importance
|
||||
*
|
||||
* @export
|
||||
* @interface ClassFeatureImportance
|
||||
* @typedef {ClassFeatureImportance}
|
||||
*/
|
||||
export interface ClassFeatureImportance {
|
||||
/**
|
||||
* The class name
|
||||
* @type {FeatureImportanceClassName}
|
||||
*/
|
||||
class_name: FeatureImportanceClassName;
|
||||
/**
|
||||
* The importance
|
||||
* @type {number}
|
||||
*/
|
||||
importance: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* ES result feature importance interface
|
||||
* TODO We should separate the interface because classes/importance
|
||||
* isn't both optional but either/or.
|
||||
*
|
||||
* @export
|
||||
* @interface FeatureImportance
|
||||
* @typedef {FeatureImportance}
|
||||
*/
|
||||
export interface FeatureImportance {
|
||||
/**
|
||||
* The feature name
|
||||
* @type {string}
|
||||
*/
|
||||
feature_name: string;
|
||||
/**
|
||||
* Optional classes
|
||||
* @type {?ClassFeatureImportance[]}
|
||||
*/
|
||||
classes?: ClassFeatureImportance[];
|
||||
/**
|
||||
* Optional importance
|
||||
* @type {?number}
|
||||
*/
|
||||
importance?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* ES result top class interface
|
||||
*
|
||||
* @export
|
||||
* @interface TopClass
|
||||
* @typedef {TopClass}
|
||||
*/
|
||||
export interface TopClass {
|
||||
/**
|
||||
* The class name
|
||||
* @type {FeatureImportanceClassName}
|
||||
*/
|
||||
class_name: FeatureImportanceClassName;
|
||||
/**
|
||||
* The class probability
|
||||
* @type {number}
|
||||
*/
|
||||
class_probability: number;
|
||||
/**
|
||||
* The class score
|
||||
* @type {number}
|
||||
*/
|
||||
class_score: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of TopClass
|
||||
*
|
||||
* @export
|
||||
* @typedef {TopClasses}
|
||||
*/
|
||||
export type TopClasses = TopClass[];
|
||||
|
||||
/**
|
||||
* ES result for class feature importance summary
|
||||
*
|
||||
* @export
|
||||
* @interface ClassFeatureImportanceSummary
|
||||
* @typedef {ClassFeatureImportanceSummary}
|
||||
*/
|
||||
export interface ClassFeatureImportanceSummary {
|
||||
/**
|
||||
* The class name
|
||||
* @type {FeatureImportanceClassName}
|
||||
*/
|
||||
class_name: FeatureImportanceClassName;
|
||||
/**
|
||||
* The importance
|
||||
* @type {{
|
||||
max: number;
|
||||
min: number;
|
||||
mean_magnitude: number;
|
||||
}}
|
||||
*/
|
||||
importance: {
|
||||
max: number;
|
||||
min: number;
|
||||
mean_magnitude: number;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* ES result classification total feature importance
|
||||
*
|
||||
* @export
|
||||
* @interface ClassificationTotalFeatureImportance
|
||||
* @typedef {ClassificationTotalFeatureImportance}
|
||||
*/
|
||||
export interface ClassificationTotalFeatureImportance {
|
||||
/**
|
||||
* The feature name
|
||||
* @type {string}
|
||||
*/
|
||||
feature_name: string;
|
||||
/**
|
||||
* The classes, array of ClassFeatureImportanceSummary
|
||||
* @type {ClassFeatureImportanceSummary[]}
|
||||
*/
|
||||
classes: ClassFeatureImportanceSummary[];
|
||||
}
|
||||
|
||||
/**
|
||||
* ES result regression feature importance summary
|
||||
*
|
||||
* @export
|
||||
* @interface RegressionFeatureImportanceSummary
|
||||
* @typedef {RegressionFeatureImportanceSummary}
|
||||
*/
|
||||
export interface RegressionFeatureImportanceSummary {
|
||||
/**
|
||||
* Max feature importance
|
||||
* @type {number}
|
||||
*/
|
||||
max: number;
|
||||
/**
|
||||
* Min feature importance
|
||||
* @type {number}
|
||||
*/
|
||||
min: number;
|
||||
/**
|
||||
* Mean magnitude
|
||||
* @type {number}
|
||||
*/
|
||||
mean_magnitude: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* ES result for regression total feature importance
|
||||
*
|
||||
* @export
|
||||
* @interface RegressionTotalFeatureImportance
|
||||
* @typedef {RegressionTotalFeatureImportance}
|
||||
*/
|
||||
export interface RegressionTotalFeatureImportance {
|
||||
/**
|
||||
* Feature name
|
||||
* @type {string}
|
||||
*/
|
||||
feature_name: string;
|
||||
/**
|
||||
* Importance
|
||||
* @type {RegressionFeatureImportanceSummary}
|
||||
*/
|
||||
importance: RegressionFeatureImportanceSummary;
|
||||
}
|
||||
/**
|
||||
* Union type of total feature importance types
|
||||
*
|
||||
* @export
|
||||
* @typedef {TotalFeatureImportance}
|
||||
*/
|
||||
export type TotalFeatureImportance =
|
||||
| ClassificationTotalFeatureImportance
|
||||
| RegressionTotalFeatureImportance;
|
||||
|
||||
/**
|
||||
* Baseline interface for ES result feature importance class
|
||||
*
|
||||
* @export
|
||||
* @interface FeatureImportanceClassBaseline
|
||||
* @typedef {FeatureImportanceClassBaseline}
|
||||
*/
|
||||
export interface FeatureImportanceClassBaseline {
|
||||
/**
|
||||
* Class name
|
||||
* @type {FeatureImportanceClassName}
|
||||
*/
|
||||
class_name: FeatureImportanceClassName;
|
||||
/**
|
||||
* Baseline
|
||||
* @type {number}
|
||||
*/
|
||||
baseline: number;
|
||||
}
|
||||
/**
|
||||
* Baseline interface for ES result classification feature importance
|
||||
*
|
||||
* @export
|
||||
* @interface ClassificationFeatureImportanceBaseline
|
||||
* @typedef {ClassificationFeatureImportanceBaseline}
|
||||
*/
|
||||
export interface ClassificationFeatureImportanceBaseline {
|
||||
/**
|
||||
* Classes
|
||||
* @type {FeatureImportanceClassBaseline[]}
|
||||
*/
|
||||
classes: FeatureImportanceClassBaseline[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Baseline interface for ES result regression feature importance
|
||||
*
|
||||
* @export
|
||||
* @interface RegressionFeatureImportanceBaseline
|
||||
* @typedef {RegressionFeatureImportanceBaseline}
|
||||
*/
|
||||
export interface RegressionFeatureImportanceBaseline {
|
||||
/**
|
||||
* Baseline
|
||||
* @type {number}
|
||||
*/
|
||||
baseline: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Union type of feature importance baseline types
|
||||
*
|
||||
* @export
|
||||
* @typedef {FeatureImportanceBaseline}
|
||||
*/
|
||||
export type FeatureImportanceBaseline =
|
||||
| ClassificationFeatureImportanceBaseline
|
||||
| RegressionFeatureImportanceBaseline;
|
||||
|
||||
/**
|
||||
* Type guard for total feature importance
|
||||
*
|
||||
* @export
|
||||
* @param {unknown} arg The feature importance to identify
|
||||
* @returns {arg is ClassificationTotalFeatureImportance}
|
||||
*/
|
||||
export function isClassificationTotalFeatureImportance(
|
||||
arg: unknown
|
||||
): arg is ClassificationTotalFeatureImportance {
|
||||
return isPopulatedObject(arg, ['classes']) && Array.isArray(arg.classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Type guard for regression total feature importance
|
||||
*
|
||||
* @export
|
||||
* @param {unknown} arg The feature importance to identify
|
||||
* @returns {arg is RegressionTotalFeatureImportance}
|
||||
*/
|
||||
export function isRegressionTotalFeatureImportance(
|
||||
arg: unknown
|
||||
): arg is RegressionTotalFeatureImportance {
|
||||
return isPopulatedObject(arg, ['importance']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Type guard for classification feature importance baseline
|
||||
*
|
||||
* @export
|
||||
* @param {unknown} arg The baseline to identify
|
||||
* @returns {arg is ClassificationFeatureImportanceBaseline}
|
||||
*/
|
||||
export function isClassificationFeatureImportanceBaseline(
|
||||
arg: unknown
|
||||
): arg is ClassificationFeatureImportanceBaseline {
|
||||
return isPopulatedObject(arg, ['classes']) && Array.isArray(arg.classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Type guard for regression feature importance baseline
|
||||
*
|
||||
* @export
|
||||
* @param {unknown} arg The baseline to identify
|
||||
* @returns {arg is RegressionFeatureImportanceBaseline}
|
||||
*/
|
||||
export function isRegressionFeatureImportanceBaseline(
|
||||
arg: unknown
|
||||
): arg is RegressionFeatureImportanceBaseline {
|
||||
return isPopulatedObject(arg, ['baseline']);
|
||||
}
|
207
x-pack/packages/ml/data_frame_analytics_utils/src/fields.ts
Normal file
207
x-pack/packages/ml/data_frame_analytics_utils/src/fields.ts
Normal file
|
@ -0,0 +1,207 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { ES_FIELD_TYPES } from '@kbn/field-types';
|
||||
|
||||
import {
|
||||
getPredictedFieldName,
|
||||
getDependentVar,
|
||||
isClassificationAnalysis,
|
||||
isOutlierAnalysis,
|
||||
isRegressionAnalysis,
|
||||
} from './analytics_utils';
|
||||
import { OUTLIER_SCORE } from './constants';
|
||||
import { DataFrameAnalyticsConfig } from './types';
|
||||
|
||||
/**
|
||||
* ES id _id
|
||||
*
|
||||
* @export
|
||||
* @typedef {EsId}
|
||||
*/
|
||||
export type EsId = string;
|
||||
|
||||
/**
|
||||
* ES source _source
|
||||
*
|
||||
* @export
|
||||
* @typedef {EsDocSource}
|
||||
*/
|
||||
export type EsDocSource = Record<string, any>;
|
||||
|
||||
/**
|
||||
* ES field name
|
||||
*
|
||||
* @export
|
||||
* @typedef {EsFieldName}
|
||||
*/
|
||||
export type EsFieldName = string;
|
||||
|
||||
/**
|
||||
* ES doc
|
||||
*
|
||||
* @export
|
||||
* @interface EsDoc
|
||||
* @typedef {EsDoc}
|
||||
* @extends {Record<string, any>}
|
||||
*/
|
||||
export interface EsDoc extends Record<string, any> {
|
||||
/**
|
||||
* ES _id
|
||||
* @type {EsId}
|
||||
*/
|
||||
_id: EsId;
|
||||
/**
|
||||
* ES _source
|
||||
* @type {EsDocSource}
|
||||
*/
|
||||
_source: EsDocSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Max columns
|
||||
* @type {10}
|
||||
*/
|
||||
export const MAX_COLUMNS = 10;
|
||||
|
||||
/**
|
||||
* Default regression columns
|
||||
* @type {8}
|
||||
*/
|
||||
export const DEFAULT_REGRESSION_COLUMNS = 8;
|
||||
|
||||
/**
|
||||
* Set of basic numerical types
|
||||
* @type {*}
|
||||
*/
|
||||
export const BASIC_NUMERICAL_TYPES = new Set([
|
||||
ES_FIELD_TYPES.UNSIGNED_LONG,
|
||||
ES_FIELD_TYPES.LONG,
|
||||
ES_FIELD_TYPES.INTEGER,
|
||||
ES_FIELD_TYPES.SHORT,
|
||||
ES_FIELD_TYPES.BYTE,
|
||||
]);
|
||||
|
||||
/**
|
||||
* Set of extended numerical types
|
||||
* @type {*}
|
||||
*/
|
||||
export const EXTENDED_NUMERICAL_TYPES = new Set([
|
||||
ES_FIELD_TYPES.DOUBLE,
|
||||
ES_FIELD_TYPES.FLOAT,
|
||||
ES_FIELD_TYPES.HALF_FLOAT,
|
||||
ES_FIELD_TYPES.SCALED_FLOAT,
|
||||
]);
|
||||
|
||||
/**
|
||||
* ES field name for copy of the doc _id
|
||||
* @type {"ml__id_copy"}
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
export const ML__ID_COPY = 'ml__id_copy';
|
||||
|
||||
/**
|
||||
* ES field name for ML's incremental id
|
||||
* @type {"ml__incremental_id"}
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
export const ML__INCREMENTAL_ID = 'ml__incremental_id';
|
||||
|
||||
/**
|
||||
* Used to sort columns:
|
||||
* - Anchor on the left ml.outlier_score, ml.is_training, <predictedField>, <actual>
|
||||
* - string based columns are moved to the left
|
||||
* - feature_influence/feature_importance fields get moved next to the corresponding field column
|
||||
* - overall fields get sorted alphabetically
|
||||
*
|
||||
* @param {string} a First field name to compare for sorting
|
||||
* @param {string} b Second field name to compare for sorting
|
||||
* @param {DataFrameAnalyticsConfig} jobConfig The DFA analysis config
|
||||
* @returns {*}
|
||||
*/
|
||||
export const sortExplorationResultsFields = (
|
||||
a: string,
|
||||
b: string,
|
||||
jobConfig: DataFrameAnalyticsConfig
|
||||
) => {
|
||||
const resultsField = jobConfig.dest.results_field;
|
||||
|
||||
if (isOutlierAnalysis(jobConfig.analysis)) {
|
||||
if (a === `${resultsField}.${OUTLIER_SCORE}`) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (b === `${resultsField}.${OUTLIER_SCORE}`) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (isClassificationAnalysis(jobConfig.analysis) || isRegressionAnalysis(jobConfig.analysis)) {
|
||||
const dependentVariable = getDependentVar(jobConfig.analysis);
|
||||
const predictedField = getPredictedFieldName(resultsField!, jobConfig.analysis, true);
|
||||
|
||||
if (a === `${resultsField}.is_training`) {
|
||||
return -1;
|
||||
}
|
||||
if (b === `${resultsField}.is_training`) {
|
||||
return 1;
|
||||
}
|
||||
if (a === predictedField) {
|
||||
return -1;
|
||||
}
|
||||
if (b === predictedField) {
|
||||
return 1;
|
||||
}
|
||||
if (a === dependentVariable || a === dependentVariable.replace(/\.keyword$/, '')) {
|
||||
return -1;
|
||||
}
|
||||
if (b === dependentVariable || b === dependentVariable.replace(/\.keyword$/, '')) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (a === `${resultsField}.prediction_probability`) {
|
||||
return -1;
|
||||
}
|
||||
if (b === `${resultsField}.prediction_probability`) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
const typeofA = typeof a;
|
||||
const typeofB = typeof b;
|
||||
|
||||
const tokensA = a.split('.');
|
||||
const prefixA = tokensA[0];
|
||||
const tokensB = b.split('.');
|
||||
const prefixB = tokensB[0];
|
||||
|
||||
if (prefixA === resultsField && tokensA.length > 1 && prefixB !== resultsField) {
|
||||
tokensA.shift();
|
||||
tokensA.shift();
|
||||
if (tokensA.join('.') === b) return 1;
|
||||
return tokensA.join('.').localeCompare(b);
|
||||
}
|
||||
|
||||
if (prefixB === resultsField && tokensB.length > 1 && prefixA !== resultsField) {
|
||||
tokensB.shift();
|
||||
tokensB.shift();
|
||||
if (tokensB.join('.') === a) return -1;
|
||||
return a.localeCompare(tokensB.join('.'));
|
||||
}
|
||||
|
||||
if (typeofA !== 'string' && typeofB === 'string') {
|
||||
return 1;
|
||||
}
|
||||
if (typeofA === 'string' && typeofB !== 'string') {
|
||||
return -1;
|
||||
}
|
||||
if (typeofA === 'string' && typeofB === 'string') {
|
||||
return a.localeCompare(b);
|
||||
}
|
||||
|
||||
return a.localeCompare(b);
|
||||
};
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { isClassificationAnalysis } from './analytics_utils';
|
||||
import type { ClassificationAnalysis, AnalysisConfig } from './types';
|
||||
|
||||
/**
|
||||
* Get the `num_top_classes` attribute of a DFA classification configuration
|
||||
*
|
||||
* @param {AnalysisConfig} analysis The analysis configuration
|
||||
* @returns {ClassificationAnalysis['classification']['num_top_classes']}
|
||||
*/
|
||||
export const getNumTopClasses = (
|
||||
analysis: AnalysisConfig
|
||||
): ClassificationAnalysis['classification']['num_top_classes'] => {
|
||||
let numTopClasses;
|
||||
if (isClassificationAnalysis(analysis) && analysis.classification.num_top_classes !== undefined) {
|
||||
numTopClasses = analysis.classification.num_top_classes;
|
||||
}
|
||||
return numTopClasses;
|
||||
};
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import type { AnalysisConfig, ClassificationAnalysis, RegressionAnalysis } from './types';
|
||||
import { isClassificationAnalysis, isRegressionAnalysis } from './analytics_utils';
|
||||
|
||||
/**
|
||||
* Get the `num_top_feature_importance_values` attribute of DFA regression and classification configurations
|
||||
*
|
||||
* @param {AnalysisConfig} analysis The analysis configuration
|
||||
* @returns {(| RegressionAnalysis['regression']['num_top_feature_importance_values']
|
||||
| ClassificationAnalysis['classification']['num_top_feature_importance_values'])}
|
||||
*/
|
||||
export const getNumTopFeatureImportanceValues = (
|
||||
analysis: AnalysisConfig
|
||||
):
|
||||
| RegressionAnalysis['regression']['num_top_feature_importance_values']
|
||||
| ClassificationAnalysis['classification']['num_top_feature_importance_values'] => {
|
||||
let numTopFeatureImportanceValues;
|
||||
if (
|
||||
isRegressionAnalysis(analysis) &&
|
||||
analysis.regression.num_top_feature_importance_values !== undefined
|
||||
) {
|
||||
numTopFeatureImportanceValues = analysis.regression.num_top_feature_importance_values;
|
||||
} else if (
|
||||
isClassificationAnalysis(analysis) &&
|
||||
analysis.classification.num_top_feature_importance_values !== undefined
|
||||
) {
|
||||
numTopFeatureImportanceValues = analysis.classification.num_top_feature_importance_values;
|
||||
}
|
||||
return numTopFeatureImportanceValues;
|
||||
};
|
634
x-pack/packages/ml/data_frame_analytics_utils/src/types.ts
Normal file
634
x-pack/packages/ml/data_frame_analytics_utils/src/types.ts
Normal file
|
@ -0,0 +1,634 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import Boom from '@hapi/boom';
|
||||
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { isPopulatedObject } from '@kbn/ml-is-populated-object';
|
||||
|
||||
import { EsErrorBody } from '@kbn/ml-error-utils';
|
||||
import type { MlUrlConfig } from '@kbn/ml-anomaly-utils';
|
||||
import { ANALYSIS_CONFIG_TYPE } from './constants';
|
||||
|
||||
/**
|
||||
* Interface for DFA API response for deletion status
|
||||
*
|
||||
* @export
|
||||
* @interface DeleteDataFrameAnalyticsWithIndexStatus
|
||||
* @typedef {DeleteDataFrameAnalyticsWithIndexStatus}
|
||||
*/
|
||||
export interface DeleteDataFrameAnalyticsWithIndexStatus {
|
||||
/**
|
||||
* Success
|
||||
* @type {boolean}
|
||||
*/
|
||||
success: boolean;
|
||||
/**
|
||||
* Optional error
|
||||
* @type {?(EsErrorBody | Boom.Boom)}
|
||||
*/
|
||||
error?: EsErrorBody | Boom.Boom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Index name
|
||||
* @export
|
||||
* @typedef {IndexName}
|
||||
*/
|
||||
export type IndexName = string;
|
||||
|
||||
/**
|
||||
* Data frame analytics id
|
||||
* @export
|
||||
* @typedef {DataFrameAnalyticsId}
|
||||
*/
|
||||
export type DataFrameAnalyticsId = string;
|
||||
|
||||
/**
|
||||
* Interface for outlier analysis job configuation
|
||||
*
|
||||
* @export
|
||||
* @interface OutlierAnalysis
|
||||
* @typedef {OutlierAnalysis}
|
||||
*/
|
||||
export interface OutlierAnalysis {
|
||||
/**
|
||||
* Key spec for interface
|
||||
*/
|
||||
[key: string]: {};
|
||||
|
||||
/**
|
||||
* Outlier detection options
|
||||
* @type {{
|
||||
compute_feature_influence?: boolean;
|
||||
}}
|
||||
*/
|
||||
outlier_detection: {
|
||||
compute_feature_influence?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Inner interface for regression job configuration options
|
||||
*
|
||||
* @interface Regression
|
||||
* @typedef {Regression}
|
||||
*/
|
||||
interface Regression {
|
||||
/**
|
||||
* Dependent variable
|
||||
* @type {string}
|
||||
*/
|
||||
dependent_variable: string;
|
||||
/**
|
||||
* Training percent
|
||||
* @type {number}
|
||||
*/
|
||||
training_percent: number;
|
||||
/**
|
||||
* Optional number of top feature importance values
|
||||
* @type {?number}
|
||||
*/
|
||||
num_top_feature_importance_values?: number;
|
||||
/**
|
||||
* Prediction field name
|
||||
* @type {?string}
|
||||
*/
|
||||
prediction_field_name?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inner interface for classification job configuration options
|
||||
*
|
||||
* @interface Classification
|
||||
* @typedef {Classification}
|
||||
*/
|
||||
interface Classification {
|
||||
/**
|
||||
* Optional class assignment objective
|
||||
* @type {?string}
|
||||
*/
|
||||
class_assignment_objective?: string;
|
||||
/**
|
||||
* Dependent variable
|
||||
* @type {string}
|
||||
*/
|
||||
dependent_variable: string;
|
||||
/**
|
||||
* Training percent
|
||||
* @type {number}
|
||||
*/
|
||||
training_percent: number;
|
||||
/**
|
||||
* Optional number of top classes
|
||||
* @type {?number}
|
||||
*/
|
||||
num_top_classes?: number;
|
||||
/**
|
||||
* Optional number of top feature importance values
|
||||
* @type {?number}
|
||||
*/
|
||||
num_top_feature_importance_values?: number;
|
||||
/**
|
||||
* Optional prediction field name
|
||||
* @type {?string}
|
||||
*/
|
||||
prediction_field_name?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for regression analysis job configuation
|
||||
*
|
||||
* @export
|
||||
* @interface RegressionAnalysis
|
||||
* @typedef {RegressionAnalysis}
|
||||
*/
|
||||
export interface RegressionAnalysis {
|
||||
/**
|
||||
* Key spec for interface
|
||||
*/
|
||||
[key: string]: Regression;
|
||||
|
||||
/**
|
||||
* Regression options
|
||||
* @type {Regression}
|
||||
*/
|
||||
regression: Regression;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for classification job configuation
|
||||
*
|
||||
* @export
|
||||
* @interface ClassificationAnalysis
|
||||
* @typedef {ClassificationAnalysis}
|
||||
*/
|
||||
export interface ClassificationAnalysis {
|
||||
/**
|
||||
* Key spec for interface
|
||||
*/
|
||||
[key: string]: Classification;
|
||||
|
||||
/**
|
||||
* Outlier detection options
|
||||
* @type {Classification}
|
||||
*/
|
||||
classification: Classification;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias of estypes.MlDataframeAnalysisContainer
|
||||
*
|
||||
* @export
|
||||
* @typedef {AnalysisConfig}
|
||||
*/
|
||||
export type AnalysisConfig = estypes.MlDataframeAnalysisContainer;
|
||||
|
||||
/**
|
||||
* Meta data for a DFA job
|
||||
*
|
||||
* @export
|
||||
* @interface DataFrameAnalyticsMeta
|
||||
* @typedef {DataFrameAnalyticsMeta}
|
||||
*/
|
||||
export interface DataFrameAnalyticsMeta {
|
||||
/**
|
||||
* Optional custom urls
|
||||
* @type {?MlUrlConfig[]}
|
||||
*/
|
||||
custom_urls?: MlUrlConfig[];
|
||||
/**
|
||||
* Key spec for interface
|
||||
*/
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for a DFA config with fix for estypes provided types
|
||||
*
|
||||
* @export
|
||||
* @interface DataFrameAnalyticsConfig
|
||||
* @typedef {DataFrameAnalyticsConfig}
|
||||
* @extends {Omit<estypes.MlDataframeAnalyticsSummary, 'analyzed_fields'>}
|
||||
*/
|
||||
export interface DataFrameAnalyticsConfig
|
||||
extends Omit<estypes.MlDataframeAnalyticsSummary, 'analyzed_fields'> {
|
||||
/**
|
||||
* Optional analyzed fields
|
||||
* @type {?estypes.MlDataframeAnalysisAnalyzedFields}
|
||||
*/
|
||||
analyzed_fields?: estypes.MlDataframeAnalysisAnalyzedFields;
|
||||
/**
|
||||
* Optional meta data
|
||||
* @type {?DataFrameAnalyticsMeta}
|
||||
*/
|
||||
_meta?: DataFrameAnalyticsMeta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for a requect object to update a DFA job
|
||||
*
|
||||
* @export
|
||||
* @interface UpdateDataFrameAnalyticsConfig
|
||||
* @typedef {UpdateDataFrameAnalyticsConfig}
|
||||
*/
|
||||
export interface UpdateDataFrameAnalyticsConfig {
|
||||
/**
|
||||
* Optional allow lazy start
|
||||
* @type {?string}
|
||||
*/
|
||||
allow_lazy_start?: string;
|
||||
/**
|
||||
* Optional description
|
||||
* @type {?string}
|
||||
*/
|
||||
description?: string;
|
||||
/**
|
||||
* Optional model memory limit
|
||||
* @type {?string}
|
||||
*/
|
||||
model_memory_limit?: string;
|
||||
/**
|
||||
* Optional max num threads
|
||||
* @type {?number}
|
||||
*/
|
||||
max_num_threads?: number;
|
||||
/**
|
||||
* Optional meta data
|
||||
* @type {?DataFrameAnalyticsMeta}
|
||||
*/
|
||||
_meta?: DataFrameAnalyticsMeta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Type guard for a DFA config
|
||||
*
|
||||
* @export
|
||||
* @param {unknown} arg The config to identify
|
||||
* @returns {arg is DataFrameAnalyticsConfig}
|
||||
*/
|
||||
export function isDataFrameAnalyticsConfigs(arg: unknown): arg is DataFrameAnalyticsConfig {
|
||||
return isPopulatedObject(arg, ['dest', 'analysis', 'id']) && typeof arg.id === 'string';
|
||||
}
|
||||
|
||||
/**
|
||||
* Union type of DFA anlaysis config types
|
||||
*
|
||||
* @export
|
||||
* @typedef {DataFrameAnalysisConfigType}
|
||||
*/
|
||||
export type DataFrameAnalysisConfigType =
|
||||
typeof ANALYSIS_CONFIG_TYPE[keyof typeof ANALYSIS_CONFIG_TYPE];
|
||||
|
||||
/**
|
||||
* Union type of DFA task states
|
||||
*
|
||||
* @export
|
||||
* @typedef {DataFrameTaskStateType}
|
||||
*/
|
||||
export type DataFrameTaskStateType = estypes.MlDataframeState | 'analyzing' | 'reindexing';
|
||||
|
||||
/**
|
||||
* Interface for DFA stats
|
||||
*
|
||||
* @export
|
||||
* @interface DataFrameAnalyticsStats
|
||||
* @typedef {DataFrameAnalyticsStats}
|
||||
* @extends {Omit<estypes.MlDataframeAnalytics, 'state'>}
|
||||
*/
|
||||
export interface DataFrameAnalyticsStats extends Omit<estypes.MlDataframeAnalytics, 'state'> {
|
||||
/**
|
||||
* Optional failure reason
|
||||
* @type {?string}
|
||||
*/
|
||||
failure_reason?: string;
|
||||
/**
|
||||
* Task state
|
||||
* @type {DataFrameTaskStateType}
|
||||
*/
|
||||
state: DataFrameTaskStateType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for estypes.MlExplainDataFrameAnalyticsResponse
|
||||
*
|
||||
* @export
|
||||
* @typedef {DfAnalyticsExplainResponse}
|
||||
*/
|
||||
export type DfAnalyticsExplainResponse = estypes.MlExplainDataFrameAnalyticsResponse;
|
||||
|
||||
/**
|
||||
* Interface for predicted class
|
||||
*
|
||||
* @export
|
||||
* @interface PredictedClass
|
||||
* @typedef {PredictedClass}
|
||||
*/
|
||||
export interface PredictedClass {
|
||||
/**
|
||||
* Predicted class
|
||||
* @type {string}
|
||||
*/
|
||||
predicted_class: string;
|
||||
/**
|
||||
* Count
|
||||
* @type {number}
|
||||
*/
|
||||
count: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for confusion matrix
|
||||
*
|
||||
* @export
|
||||
* @interface ConfusionMatrix
|
||||
* @typedef {ConfusionMatrix}
|
||||
*/
|
||||
export interface ConfusionMatrix {
|
||||
/**
|
||||
* Actual class
|
||||
* @type {string}
|
||||
*/
|
||||
actual_class: string;
|
||||
/**
|
||||
* Actual class doc count
|
||||
* @type {number}
|
||||
*/
|
||||
actual_class_doc_count: number;
|
||||
/**
|
||||
* Array of predicted classes
|
||||
* @type {PredictedClass[]}
|
||||
*/
|
||||
predicted_classes: PredictedClass[];
|
||||
/**
|
||||
* Doc count of other predicted classes
|
||||
* @type {number}
|
||||
*/
|
||||
other_predicted_class_doc_count: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Data item for ROC curve
|
||||
*
|
||||
* @export
|
||||
* @interface RocCurveItem
|
||||
* @typedef {RocCurveItem}
|
||||
*/
|
||||
export interface RocCurveItem {
|
||||
/**
|
||||
* FPR
|
||||
* @type {number}
|
||||
*/
|
||||
fpr: number;
|
||||
/**
|
||||
* Threshold
|
||||
* @type {number}
|
||||
*/
|
||||
threshold: number;
|
||||
/**
|
||||
* TPR
|
||||
* @type {number}
|
||||
*/
|
||||
tpr: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Eval Class
|
||||
* @interface EvalClass
|
||||
* @typedef {EvalClass}
|
||||
*/
|
||||
interface EvalClass {
|
||||
/**
|
||||
* Class name
|
||||
* @type {string}
|
||||
*/
|
||||
class_name: string;
|
||||
/**
|
||||
* Value
|
||||
* @type {number}
|
||||
*/
|
||||
value: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for classification evaluate response
|
||||
*
|
||||
* @export
|
||||
* @interface ClassificationEvaluateResponse
|
||||
* @typedef {ClassificationEvaluateResponse}
|
||||
*/
|
||||
export interface ClassificationEvaluateResponse {
|
||||
/**
|
||||
* Classificatio evaluation
|
||||
* @type {{
|
||||
multiclass_confusion_matrix?: {
|
||||
confusion_matrix: ConfusionMatrix[];
|
||||
};
|
||||
recall?: {
|
||||
classes: EvalClass[];
|
||||
avg_recall: number;
|
||||
};
|
||||
accuracy?: {
|
||||
classes: EvalClass[];
|
||||
overall_accuracy: number;
|
||||
};
|
||||
auc_roc?: {
|
||||
curve?: RocCurveItem[];
|
||||
value: number;
|
||||
};
|
||||
}}
|
||||
*/
|
||||
classification: {
|
||||
multiclass_confusion_matrix?: {
|
||||
confusion_matrix: ConfusionMatrix[];
|
||||
};
|
||||
recall?: {
|
||||
classes: EvalClass[];
|
||||
avg_recall: number;
|
||||
};
|
||||
accuracy?: {
|
||||
classes: EvalClass[];
|
||||
overall_accuracy: number;
|
||||
};
|
||||
auc_roc?: {
|
||||
curve?: RocCurveItem[];
|
||||
value: number;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for evalute metrics
|
||||
*
|
||||
* @export
|
||||
* @interface EvaluateMetrics
|
||||
* @typedef {EvaluateMetrics}
|
||||
*/
|
||||
export interface EvaluateMetrics {
|
||||
/**
|
||||
* Classification evalute metrics
|
||||
* @type {{
|
||||
accuracy?: object;
|
||||
recall?: object;
|
||||
multiclass_confusion_matrix?: object;
|
||||
auc_roc?: { include_curve: boolean; class_name: string };
|
||||
}}
|
||||
*/
|
||||
classification: {
|
||||
accuracy?: object;
|
||||
recall?: object;
|
||||
multiclass_confusion_matrix?: object;
|
||||
auc_roc?: { include_curve: boolean; class_name: string };
|
||||
};
|
||||
/**
|
||||
* Regression evaluate metrics
|
||||
* @type {{
|
||||
r_squared: object;
|
||||
mse: object;
|
||||
msle: object;
|
||||
huber: object;
|
||||
}}
|
||||
*/
|
||||
regression: {
|
||||
r_squared: object;
|
||||
mse: object;
|
||||
msle: object;
|
||||
huber: object;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for field selection item
|
||||
*
|
||||
* @export
|
||||
* @interface FieldSelectionItem
|
||||
* @typedef {FieldSelectionItem}
|
||||
* @extends {Omit<estypes.MlDataframeAnalyticsFieldSelection, 'mapping_types'>}
|
||||
*/
|
||||
export interface FieldSelectionItem
|
||||
extends Omit<estypes.MlDataframeAnalyticsFieldSelection, 'mapping_types'> {
|
||||
/**
|
||||
* Optional mapping types
|
||||
* @type {?string[]}
|
||||
*/
|
||||
mapping_types?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for a node element for the map view
|
||||
*
|
||||
* @export
|
||||
* @interface AnalyticsMapNodeElement
|
||||
* @typedef {AnalyticsMapNodeElement}
|
||||
*/
|
||||
export interface AnalyticsMapNodeElement {
|
||||
/**
|
||||
* Inner data of the node element
|
||||
* @type {{
|
||||
id: string;
|
||||
label: string;
|
||||
type: string;
|
||||
analysisType?: string;
|
||||
}}
|
||||
*/
|
||||
data: {
|
||||
id: string;
|
||||
label: string;
|
||||
type: string;
|
||||
analysisType?: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for an edge element for the map view
|
||||
*
|
||||
* @export
|
||||
* @interface AnalyticsMapEdgeElement
|
||||
* @typedef {AnalyticsMapEdgeElement}
|
||||
*/
|
||||
export interface AnalyticsMapEdgeElement {
|
||||
/**
|
||||
* Inner data of the edge element
|
||||
* @type {{
|
||||
id: string;
|
||||
source: string;
|
||||
target: string;
|
||||
}}
|
||||
*/
|
||||
data: {
|
||||
id: string;
|
||||
source: string;
|
||||
target: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Union type of map node and edge elements
|
||||
*
|
||||
* @export
|
||||
* @typedef {MapElements}
|
||||
*/
|
||||
export type MapElements = AnalyticsMapNodeElement | AnalyticsMapEdgeElement;
|
||||
|
||||
/**
|
||||
* Interface for DFA map return type
|
||||
*
|
||||
* @export
|
||||
* @interface AnalyticsMapReturnType
|
||||
* @typedef {AnalyticsMapReturnType}
|
||||
*/
|
||||
export interface AnalyticsMapReturnType {
|
||||
/**
|
||||
* Map elements
|
||||
* @type {MapElements[]}
|
||||
*/
|
||||
elements: MapElements[];
|
||||
/**
|
||||
* Transform, job or index details
|
||||
* @type {Record<string, any>}
|
||||
*/
|
||||
details: Record<string, any>;
|
||||
/**
|
||||
* Error
|
||||
* @type {(null | any)}
|
||||
*/
|
||||
error: null | any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for estypes.MlDataframeAnalysisFeatureProcessor
|
||||
*
|
||||
* @export
|
||||
* @typedef {FeatureProcessor}
|
||||
*/
|
||||
export type FeatureProcessor = estypes.MlDataframeAnalysisFeatureProcessor;
|
||||
|
||||
/**
|
||||
* Interface for a search response's track total hits option
|
||||
*
|
||||
* @export
|
||||
* @interface TrackTotalHitsSearchResponse
|
||||
* @typedef {TrackTotalHitsSearchResponse}
|
||||
*/
|
||||
export interface TrackTotalHitsSearchResponse {
|
||||
/**
|
||||
* Inner structure of the response
|
||||
* @type {{
|
||||
total: {
|
||||
value: number;
|
||||
relation: string;
|
||||
};
|
||||
hits: any[];
|
||||
}}
|
||||
*/
|
||||
hits: {
|
||||
total: {
|
||||
value: number;
|
||||
relation: string;
|
||||
};
|
||||
hits: any[];
|
||||
};
|
||||
}
|
24
x-pack/packages/ml/data_frame_analytics_utils/tsconfig.json
Normal file
24
x-pack/packages/ml/data_frame_analytics_utils/tsconfig.json
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"extends": "../../../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "target/types",
|
||||
"types": [
|
||||
"jest",
|
||||
"node",
|
||||
"react"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*"
|
||||
],
|
||||
"kbn_references": [
|
||||
"@kbn/ml-is-populated-object",
|
||||
"@kbn/field-types",
|
||||
"@kbn/ml-error-utils",
|
||||
"@kbn/ml-anomaly-utils",
|
||||
]
|
||||
}
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
import React, { FC, useMemo } from 'react';
|
||||
import type { EuiDataGridColumn } from '@elastic/eui/src/components/datagrid/data_grid_types';
|
||||
import type { OrdinalChartData } from './field_histograms';
|
||||
import { getTFPercentage } from '../../utils';
|
||||
import { ColumnChart } from './column_chart';
|
||||
import type { OrdinalChartData } from './field_histograms';
|
||||
import type { FieldDataRowProps } from '../../types';
|
||||
|
||||
export const BooleanContentPreview: FC<FieldDataRowProps> = ({ config }) => {
|
||||
|
|
|
@ -13,7 +13,7 @@ import { EuiDataGridColumn } from '@elastic/eui';
|
|||
|
||||
import './column_chart.scss';
|
||||
|
||||
import { isUnsupportedChartData, ChartData } from './field_histograms';
|
||||
import { isUnsupportedChartData, type ChartData } from './field_histograms';
|
||||
|
||||
import { useColumnChart } from './use_column_chart';
|
||||
|
||||
|
|
|
@ -14,16 +14,14 @@ import useObservable from 'react-use/lib/useObservable';
|
|||
import { euiPaletteColorBlind, EuiDataGridColumn } from '@elastic/eui';
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { KBN_FIELD_TYPES } from '@kbn/data-plugin/public';
|
||||
|
||||
import {
|
||||
isNumericChartData,
|
||||
isOrdinalChartData,
|
||||
ChartData,
|
||||
ChartDataItem,
|
||||
NumericDataItem,
|
||||
OrdinalDataItem,
|
||||
type ChartData,
|
||||
type ChartDataItem,
|
||||
type NumericDataItem,
|
||||
type OrdinalDataItem,
|
||||
} from './field_histograms';
|
||||
|
||||
const NON_AGGREGATABLE = 'non-aggregatable';
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
export const ANALYSIS_CONFIG_TYPE = {
|
||||
OUTLIER_DETECTION: 'outlier_detection',
|
||||
REGRESSION: 'regression',
|
||||
CLASSIFICATION: 'classification',
|
||||
} as const;
|
||||
|
||||
export const DATA_FRAME_TASK_STATE = {
|
||||
ANALYZING: 'analyzing',
|
||||
FAILED: 'failed',
|
||||
REINDEXING: 'reindexing',
|
||||
STARTED: 'started',
|
||||
STARTING: 'starting',
|
||||
STOPPED: 'stopped',
|
||||
} as const;
|
||||
|
||||
export const DEFAULT_RESULTS_FIELD = 'ml';
|
||||
|
||||
export const JOB_MAP_NODE_TYPES = {
|
||||
ANALYTICS: 'analytics',
|
||||
TRANSFORM: 'transform',
|
||||
INDEX: 'index',
|
||||
TRAINED_MODEL: 'trainedModel',
|
||||
} as const;
|
||||
|
||||
export const INDEX_CREATED_BY = {
|
||||
FILE_DATA_VISUALIZER: 'file-data-visualizer',
|
||||
DATA_FRAME_ANALYTICS: 'data-frame-analytics',
|
||||
} as const;
|
||||
|
||||
export type JobMapNodeTypes = typeof JOB_MAP_NODE_TYPES[keyof typeof JOB_MAP_NODE_TYPES];
|
|
@ -1,190 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import Boom from '@hapi/boom';
|
||||
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { isPopulatedObject } from '@kbn/ml-is-populated-object';
|
||||
|
||||
import { EsErrorBody } from '@kbn/ml-error-utils';
|
||||
import type { MlUrlConfig } from '@kbn/ml-anomaly-utils';
|
||||
import { ANALYSIS_CONFIG_TYPE } from '../constants/data_frame_analytics';
|
||||
|
||||
export interface DeleteDataFrameAnalyticsWithIndexStatus {
|
||||
success: boolean;
|
||||
error?: EsErrorBody | Boom.Boom;
|
||||
}
|
||||
|
||||
export type IndexName = string;
|
||||
export type DataFrameAnalyticsId = string;
|
||||
|
||||
export interface OutlierAnalysis {
|
||||
[key: string]: {};
|
||||
|
||||
outlier_detection: {
|
||||
compute_feature_influence?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
interface Regression {
|
||||
dependent_variable: string;
|
||||
training_percent: number;
|
||||
num_top_feature_importance_values?: number;
|
||||
prediction_field_name?: string;
|
||||
}
|
||||
|
||||
interface Classification {
|
||||
class_assignment_objective?: string;
|
||||
dependent_variable: string;
|
||||
training_percent: number;
|
||||
num_top_classes?: number;
|
||||
num_top_feature_importance_values?: number;
|
||||
prediction_field_name?: string;
|
||||
}
|
||||
|
||||
export interface RegressionAnalysis {
|
||||
[key: string]: Regression;
|
||||
|
||||
regression: Regression;
|
||||
}
|
||||
|
||||
export interface ClassificationAnalysis {
|
||||
[key: string]: Classification;
|
||||
|
||||
classification: Classification;
|
||||
}
|
||||
|
||||
export type AnalysisConfig = estypes.MlDataframeAnalysisContainer;
|
||||
export interface DataFrameAnalyticsMeta {
|
||||
custom_urls?: MlUrlConfig[];
|
||||
[key: string]: any;
|
||||
}
|
||||
export interface DataFrameAnalyticsConfig
|
||||
extends Omit<estypes.MlDataframeAnalyticsSummary, 'analyzed_fields'> {
|
||||
analyzed_fields?: estypes.MlDataframeAnalysisAnalyzedFields;
|
||||
_meta?: DataFrameAnalyticsMeta;
|
||||
}
|
||||
|
||||
export interface UpdateDataFrameAnalyticsConfig {
|
||||
allow_lazy_start?: string;
|
||||
description?: string;
|
||||
model_memory_limit?: string;
|
||||
max_num_threads?: number;
|
||||
_meta?: DataFrameAnalyticsMeta;
|
||||
}
|
||||
|
||||
export function isDataFrameAnalyticsConfigs(arg: unknown): arg is DataFrameAnalyticsConfig {
|
||||
return isPopulatedObject(arg, ['dest', 'analysis', 'id']) && typeof arg.id === 'string';
|
||||
}
|
||||
|
||||
export type DataFrameAnalysisConfigType =
|
||||
typeof ANALYSIS_CONFIG_TYPE[keyof typeof ANALYSIS_CONFIG_TYPE];
|
||||
|
||||
export type DataFrameTaskStateType = estypes.MlDataframeState | 'analyzing' | 'reindexing';
|
||||
|
||||
export interface DataFrameAnalyticsStats extends Omit<estypes.MlDataframeAnalytics, 'state'> {
|
||||
failure_reason?: string;
|
||||
state: DataFrameTaskStateType;
|
||||
}
|
||||
|
||||
export type DfAnalyticsExplainResponse = estypes.MlExplainDataFrameAnalyticsResponse;
|
||||
|
||||
export interface PredictedClass {
|
||||
predicted_class: string;
|
||||
count: number;
|
||||
}
|
||||
export interface ConfusionMatrix {
|
||||
actual_class: string;
|
||||
actual_class_doc_count: number;
|
||||
predicted_classes: PredictedClass[];
|
||||
other_predicted_class_doc_count: number;
|
||||
}
|
||||
|
||||
export interface RocCurveItem {
|
||||
fpr: number;
|
||||
threshold: number;
|
||||
tpr: number;
|
||||
}
|
||||
|
||||
interface EvalClass {
|
||||
class_name: string;
|
||||
value: number;
|
||||
}
|
||||
export interface ClassificationEvaluateResponse {
|
||||
classification: {
|
||||
multiclass_confusion_matrix?: {
|
||||
confusion_matrix: ConfusionMatrix[];
|
||||
};
|
||||
recall?: {
|
||||
classes: EvalClass[];
|
||||
avg_recall: number;
|
||||
};
|
||||
accuracy?: {
|
||||
classes: EvalClass[];
|
||||
overall_accuracy: number;
|
||||
};
|
||||
auc_roc?: {
|
||||
curve?: RocCurveItem[];
|
||||
value: number;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export interface EvaluateMetrics {
|
||||
classification: {
|
||||
accuracy?: object;
|
||||
recall?: object;
|
||||
multiclass_confusion_matrix?: object;
|
||||
auc_roc?: { include_curve: boolean; class_name: string };
|
||||
};
|
||||
regression: {
|
||||
r_squared: object;
|
||||
mse: object;
|
||||
msle: object;
|
||||
huber: object;
|
||||
};
|
||||
}
|
||||
|
||||
export interface FieldSelectionItem
|
||||
extends Omit<estypes.MlDataframeAnalyticsFieldSelection, 'mapping_types'> {
|
||||
mapping_types?: string[];
|
||||
}
|
||||
|
||||
export interface AnalyticsMapNodeElement {
|
||||
data: {
|
||||
id: string;
|
||||
label: string;
|
||||
type: string;
|
||||
analysisType?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface AnalyticsMapEdgeElement {
|
||||
data: {
|
||||
id: string;
|
||||
source: string;
|
||||
target: string;
|
||||
};
|
||||
}
|
||||
|
||||
export type MapElements = AnalyticsMapNodeElement | AnalyticsMapEdgeElement;
|
||||
export interface AnalyticsMapReturnType {
|
||||
elements: MapElements[];
|
||||
details: Record<string, any>; // transform, job, or index details
|
||||
error: null | any;
|
||||
}
|
||||
|
||||
export type FeatureProcessor = estypes.MlDataframeAnalysisFeatureProcessor;
|
||||
|
||||
export interface TrackTotalHitsSearchResponse {
|
||||
hits: {
|
||||
total: {
|
||||
value: number;
|
||||
relation: string;
|
||||
};
|
||||
hits: any[];
|
||||
};
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { isPopulatedObject } from '@kbn/ml-is-populated-object';
|
||||
|
||||
export type FeatureImportanceClassName = string | number | boolean;
|
||||
|
||||
export interface ClassFeatureImportance {
|
||||
class_name: FeatureImportanceClassName;
|
||||
importance: number;
|
||||
}
|
||||
|
||||
// TODO We should separate the interface because classes/importance
|
||||
// isn't both optional but either/or.
|
||||
export interface FeatureImportance {
|
||||
feature_name: string;
|
||||
classes?: ClassFeatureImportance[];
|
||||
importance?: number;
|
||||
}
|
||||
|
||||
export interface TopClass {
|
||||
class_name: FeatureImportanceClassName;
|
||||
class_probability: number;
|
||||
class_score: number;
|
||||
}
|
||||
|
||||
export type TopClasses = TopClass[];
|
||||
|
||||
export interface ClassFeatureImportanceSummary {
|
||||
class_name: FeatureImportanceClassName;
|
||||
importance: {
|
||||
max: number;
|
||||
min: number;
|
||||
mean_magnitude: number;
|
||||
};
|
||||
}
|
||||
export interface ClassificationTotalFeatureImportance {
|
||||
feature_name: string;
|
||||
classes: ClassFeatureImportanceSummary[];
|
||||
}
|
||||
|
||||
export interface RegressionFeatureImportanceSummary {
|
||||
max: number;
|
||||
min: number;
|
||||
mean_magnitude: number;
|
||||
}
|
||||
|
||||
export interface RegressionTotalFeatureImportance {
|
||||
feature_name: string;
|
||||
importance: RegressionFeatureImportanceSummary;
|
||||
}
|
||||
export type TotalFeatureImportance =
|
||||
| ClassificationTotalFeatureImportance
|
||||
| RegressionTotalFeatureImportance;
|
||||
|
||||
export interface FeatureImportanceClassBaseline {
|
||||
class_name: FeatureImportanceClassName;
|
||||
baseline: number;
|
||||
}
|
||||
export interface ClassificationFeatureImportanceBaseline {
|
||||
classes: FeatureImportanceClassBaseline[];
|
||||
}
|
||||
|
||||
export interface RegressionFeatureImportanceBaseline {
|
||||
baseline: number;
|
||||
}
|
||||
|
||||
export type FeatureImportanceBaseline =
|
||||
| ClassificationFeatureImportanceBaseline
|
||||
| RegressionFeatureImportanceBaseline;
|
||||
|
||||
export function isClassificationTotalFeatureImportance(
|
||||
summary: ClassificationTotalFeatureImportance | RegressionTotalFeatureImportance
|
||||
): summary is ClassificationTotalFeatureImportance {
|
||||
return (summary as ClassificationTotalFeatureImportance).classes !== undefined;
|
||||
}
|
||||
|
||||
export function isRegressionTotalFeatureImportance(
|
||||
summary: ClassificationTotalFeatureImportance | RegressionTotalFeatureImportance
|
||||
): summary is RegressionTotalFeatureImportance {
|
||||
return (summary as RegressionTotalFeatureImportance).importance !== undefined;
|
||||
}
|
||||
|
||||
export function isClassificationFeatureImportanceBaseline(
|
||||
baselineData: any
|
||||
): baselineData is ClassificationFeatureImportanceBaseline {
|
||||
return isPopulatedObject(baselineData, ['classes']) && Array.isArray(baselineData.classes);
|
||||
}
|
||||
|
||||
export function isRegressionFeatureImportanceBaseline(
|
||||
baselineData: any
|
||||
): baselineData is RegressionFeatureImportanceBaseline {
|
||||
return isPopulatedObject(baselineData, ['baseline']);
|
||||
}
|
|
@ -8,8 +8,8 @@
|
|||
import type { SerializableRecord } from '@kbn/utility-types';
|
||||
import type { LocatorPublic } from '@kbn/share-plugin/public';
|
||||
import type { RefreshInterval, TimeRange } from '@kbn/data-plugin/common/query';
|
||||
import type { DataFrameAnalysisConfigType } from '@kbn/ml-data-frame-analytics-utils';
|
||||
import type { JobId } from './anomaly_detection_jobs/job';
|
||||
import type { DataFrameAnalysisConfigType } from './data_frame_analytics';
|
||||
import type { SearchQueryLanguage } from '../constants/search';
|
||||
import type { ListingPageUrlState } from './common';
|
||||
import type { InfluencersFilterQuery } from './es_client';
|
||||
|
|
|
@ -6,8 +6,11 @@
|
|||
*/
|
||||
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import type { DeploymentState, TrainedModelType } from '@kbn/ml-trained-models-utils';
|
||||
import type { DataFrameAnalyticsConfig } from './data_frame_analytics';
|
||||
import type { FeatureImportanceBaseline, TotalFeatureImportance } from './feature_importance';
|
||||
import type {
|
||||
DataFrameAnalyticsConfig,
|
||||
FeatureImportanceBaseline,
|
||||
TotalFeatureImportance,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
import type { XOR } from './common';
|
||||
import type { MlSavedObjectType } from './saved_objects';
|
||||
|
||||
|
|
|
@ -28,9 +28,9 @@ import { FormattedMessage } from '@kbn/i18n-react';
|
|||
import { DataViewListItem } from '@kbn/data-views-plugin/common';
|
||||
import { DataView } from '@kbn/data-views-plugin/public';
|
||||
import type { MlUrlConfig } from '@kbn/ml-anomaly-utils';
|
||||
import type { DataFrameAnalyticsConfig } from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { CustomUrlSettings, isValidCustomUrlSettingsTimeRange } from './utils';
|
||||
import { isValidLabel } from '../../../util/custom_url_utils';
|
||||
import { type DataFrameAnalyticsConfig } from '../../../../../common/types/data_frame_analytics';
|
||||
import { type Job } from '../../../../../common/types/anomaly_detection_jobs';
|
||||
|
||||
import { TIME_RANGE_TYPE, TimeRangeType, URL_TYPE } from './constants';
|
||||
|
|
|
@ -9,7 +9,7 @@ import { DataView } from '@kbn/data-views-plugin/public';
|
|||
import {
|
||||
isDataFrameAnalyticsConfigs,
|
||||
type DataFrameAnalyticsConfig,
|
||||
} from '../../../../../common/types/data_frame_analytics';
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { Job, isAnomalyDetectionJob } from '../../../../../common/types/anomaly_detection_jobs';
|
||||
import { getQueryEntityFieldNames, getSupportedFieldNames } from './utils';
|
||||
|
||||
|
|
|
@ -21,12 +21,13 @@ import {
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import type { MlUrlConfig, MlKibanaUrlConfig } from '@kbn/ml-anomaly-utils';
|
||||
import type { DataFrameAnalyticsConfig } from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { useMlKibana } from '../../../contexts/kibana';
|
||||
import { isValidLabel, openCustomUrlWindow } from '../../../util/custom_url_utils';
|
||||
import { getTestUrl } from './utils';
|
||||
|
||||
import { parseInterval } from '../../../../../common/util/parse_interval';
|
||||
import { type DataFrameAnalyticsConfig } from '../../../../../common/types/data_frame_analytics';
|
||||
import { TIME_RANGE_TYPE } from './constants';
|
||||
import { Job, isAnomalyDetectionJob } from '../../../../../common/types/anomaly_detection_jobs';
|
||||
|
||||
|
|
|
@ -17,11 +17,12 @@ import { isFilterPinned, Filter } from '@kbn/es-query';
|
|||
import { DataViewListItem } from '@kbn/data-views-plugin/common';
|
||||
import { TimeRange as EsQueryTimeRange } from '@kbn/es-query';
|
||||
import type { MlKibanaUrlConfig, MlUrlConfig } from '@kbn/ml-anomaly-utils';
|
||||
import { DEFAULT_RESULTS_FIELD } from '../../../../../common/constants/data_frame_analytics';
|
||||
import {
|
||||
isDataFrameAnalyticsConfigs,
|
||||
type DataFrameAnalyticsConfig,
|
||||
} from '../../../../../common/types/data_frame_analytics';
|
||||
DEFAULT_RESULTS_FIELD,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { categoryFieldTypes } from '../../../../../common/util/fields_utils';
|
||||
import { TIME_RANGE_TYPE, URL_TYPE } from './constants';
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import { i18n } from '@kbn/i18n';
|
|||
import { withKibana } from '@kbn/kibana-react-plugin/public';
|
||||
import { DataViewListItem } from '@kbn/data-views-plugin/common';
|
||||
import type { MlUrlConfig } from '@kbn/ml-anomaly-utils';
|
||||
import { isDataFrameAnalyticsConfigs } from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { MlKibanaReactContextValue } from '../../contexts/kibana';
|
||||
import { CustomUrlEditor, CustomUrlList } from './custom_url_editor';
|
||||
import {
|
||||
|
@ -43,7 +44,6 @@ import {
|
|||
import { openCustomUrlWindow } from '../../util/custom_url_utils';
|
||||
import type { CustomUrlsWrapperProps } from './custom_urls_wrapper';
|
||||
import { isAnomalyDetectionJob } from '../../../../common/types/anomaly_detection_jobs';
|
||||
import { isDataFrameAnalyticsConfigs } from '../../../../common/types/data_frame_analytics';
|
||||
|
||||
const MAX_NUMBER_DASHBOARDS = 1000;
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
import React, { FC } from 'react';
|
||||
import type { MlUrlConfig } from '@kbn/ml-anomaly-utils';
|
||||
import type { DataFrameAnalyticsConfig } from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { useMlKibana } from '../../contexts/kibana';
|
||||
import { Job } from '../../../../common/types/anomaly_detection_jobs';
|
||||
import { type DataFrameAnalyticsConfig } from '../../../../common/types/data_frame_analytics';
|
||||
import { CustomUrls } from './custom_urls';
|
||||
|
||||
export interface CustomUrlsWrapperProps {
|
||||
|
|
|
@ -19,24 +19,19 @@ import { getNestedProperty } from '@kbn/ml-nested-property';
|
|||
import { isCounterTimeSeriesMetric } from '@kbn/ml-agg-utils';
|
||||
import { extractErrorMessage } from '@kbn/ml-error-utils';
|
||||
|
||||
import { DEFAULT_RESULTS_FIELD } from '../../../../common/constants/data_frame_analytics';
|
||||
import {
|
||||
FeatureImportance,
|
||||
FeatureImportanceClassName,
|
||||
TopClasses,
|
||||
} from '../../../../common/types/feature_importance';
|
||||
|
||||
import {
|
||||
type FeatureImportance,
|
||||
type FeatureImportanceClassName,
|
||||
type TopClasses,
|
||||
BASIC_NUMERICAL_TYPES,
|
||||
DEFAULT_RESULTS_FIELD,
|
||||
EXTENDED_NUMERICAL_TYPES,
|
||||
} from '../../data_frame_analytics/common/fields';
|
||||
|
||||
import {
|
||||
FEATURE_IMPORTANCE,
|
||||
FEATURE_INFLUENCE,
|
||||
OUTLIER_SCORE,
|
||||
TOP_CLASSES,
|
||||
} from '../../data_frame_analytics/common/constants';
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { formatHumanReadableDateTimeSeconds } from '../../../../common/util/date_utils';
|
||||
import { mlFieldFormatService } from '../../services/field_format_service';
|
||||
|
||||
|
|
|
@ -30,11 +30,18 @@ import { i18n } from '@kbn/i18n';
|
|||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { CoreSetup } from '@kbn/core/public';
|
||||
import { isPopulatedObject } from '@kbn/ml-is-populated-object';
|
||||
import {
|
||||
type DataFrameAnalysisConfigType,
|
||||
type FeatureImportanceBaseline,
|
||||
type FeatureImportance,
|
||||
type TopClasses,
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
DEFAULT_RESULTS_FIELD,
|
||||
INDEX_STATUS,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { DEFAULT_SAMPLER_SHARD_SIZE } from '../../../../common/constants/field_histograms';
|
||||
|
||||
import { ANALYSIS_CONFIG_TYPE, INDEX_STATUS } from '../../data_frame_analytics/common';
|
||||
|
||||
import {
|
||||
euiDataGridStyle,
|
||||
euiDataGridToolbarSettings,
|
||||
|
@ -43,13 +50,6 @@ import {
|
|||
} from './common';
|
||||
import { UseIndexDataReturnType } from './types';
|
||||
import { DecisionPathPopover } from '../../data_frame_analytics/pages/analytics_exploration/components/feature_importance/decision_path_popover';
|
||||
import {
|
||||
FeatureImportanceBaseline,
|
||||
FeatureImportance,
|
||||
TopClasses,
|
||||
} from '../../../../common/types/feature_importance';
|
||||
import { DEFAULT_RESULTS_FIELD } from '../../../../common/constants/data_frame_analytics';
|
||||
import { DataFrameAnalysisConfigType } from '../../../../common/types/data_frame_analytics';
|
||||
|
||||
// TODO Fix row hovering + bar highlighting
|
||||
// import { hoveredRow$ } from './column_chart';
|
||||
|
|
|
@ -16,13 +16,11 @@ import {
|
|||
} from '@elastic/eui';
|
||||
|
||||
import type { TimeRange as TimeRangeMs } from '@kbn/ml-date-picker';
|
||||
import { FeatureImportanceBaseline, INDEX_STATUS } from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { Dictionary } from '../../../../common/types/common';
|
||||
import { ChartData } from '../../../../common/types/field_histograms';
|
||||
|
||||
import { INDEX_STATUS } from '../../data_frame_analytics/common/analytics';
|
||||
|
||||
import { FeatureImportanceBaseline } from '../../../../common/types/feature_importance';
|
||||
|
||||
export type ColumnId = string;
|
||||
export type DataGridItem = Record<string, any>;
|
||||
|
||||
|
|
|
@ -9,11 +9,11 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|||
|
||||
import { EuiDataGridSorting, EuiDataGridColumn } from '@elastic/eui';
|
||||
|
||||
import { INDEX_STATUS } from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { ES_CLIENT_TOTAL_HITS_RELATION } from '../../../../common/types/es_client';
|
||||
import { ChartData } from '../../../../common/types/field_histograms';
|
||||
|
||||
import { INDEX_STATUS } from '../../data_frame_analytics/common';
|
||||
|
||||
import { ColumnChart } from './column_chart';
|
||||
import { COLUMN_CHART_DEFAULT_VISIBILITY_ROWS_THRESHOLD, INIT_MAX_COLUMNS } from './common';
|
||||
import {
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
|
||||
// @ts-expect-error
|
||||
import { saveAs } from '@elastic/filesaver';
|
||||
import type { DataFrameAnalyticsConfig } from '@kbn/ml-data-frame-analytics-utils';
|
||||
import type { MlApiServices } from '../../../services/ml_api_service';
|
||||
import type { JobType } from '../../../../../common/types/saved_objects';
|
||||
import type { Job, Datafeed } from '../../../../../common/types/anomaly_detection_jobs';
|
||||
import type { DataFrameAnalyticsConfig } from '../../../../../common/types/data_frame_analytics';
|
||||
import { GLOBAL_CALENDAR } from '../../../../../common/constants/calendars';
|
||||
|
||||
export type JobDependencies = Array<{ jobId: string; calendarIds: string[]; filterIds: string[] }>;
|
||||
|
|
|
@ -31,7 +31,7 @@ import { i18n } from '@kbn/i18n';
|
|||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { type ErrorType, extractErrorProperties } from '@kbn/ml-error-utils';
|
||||
|
||||
import type { DataFrameAnalyticsConfig } from '../../../data_frame_analytics/common';
|
||||
import type { DataFrameAnalyticsConfig } from '@kbn/ml-data-frame-analytics-utils';
|
||||
import type { JobType } from '../../../../../common/types/saved_objects';
|
||||
import { useMlApiContext, useMlKibana } from '../../../contexts/kibana';
|
||||
import { CannotImportJobsCallout } from './cannot_import_jobs_callout';
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import type { DataFrameAnalyticsConfig } from '@kbn/ml-data-frame-analytics-utils';
|
||||
import type { JobType } from '../../../../../common/types/saved_objects';
|
||||
import type { Job, Datafeed } from '../../../../../common/types/anomaly_detection_jobs';
|
||||
import type { Filter } from '../../../../../common/types/filters';
|
||||
import type { DataFrameAnalyticsConfig } from '../../../data_frame_analytics/common';
|
||||
|
||||
export interface ImportedAdJob {
|
||||
job: Job;
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
import { useMemo } from 'react';
|
||||
|
||||
import type { DataView } from '@kbn/data-views-plugin/public';
|
||||
|
||||
import { ML__INCREMENTAL_ID } from '../../data_frame_analytics/common/fields';
|
||||
import { ML__INCREMENTAL_ID } from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
export const useScatterplotFieldOptions = (
|
||||
indexPattern?: DataView,
|
||||
|
|
|
@ -5,40 +5,9 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { getAnalysisType, getValuesFromResponse, isOutlierAnalysis } from './analytics';
|
||||
import { getValuesFromResponse } from './analytics';
|
||||
|
||||
describe('Data Frame Analytics: Analytics utils', () => {
|
||||
test('getAnalysisType()', () => {
|
||||
const outlierAnalysis = { outlier_detection: {} };
|
||||
expect(getAnalysisType(outlierAnalysis)).toBe('outlier_detection');
|
||||
|
||||
const regressionAnalysis = { regression: {} };
|
||||
// @ts-expect-error incomplete regression analysis
|
||||
expect(getAnalysisType(regressionAnalysis)).toBe('regression');
|
||||
|
||||
// test against a job type that does not exist yet.
|
||||
const otherAnalysis = { other: {} };
|
||||
// @ts-expect-error unkown analysis type
|
||||
expect(getAnalysisType(otherAnalysis)).toBe('other');
|
||||
|
||||
// if the analysis object has a shape that is not just a single property,
|
||||
// the job type will be returned as 'unknown'.
|
||||
const unknownAnalysis = { outlier_detection: {}, regression: {} };
|
||||
// @ts-expect-error unkown analysis type
|
||||
expect(getAnalysisType(unknownAnalysis)).toBe('unknown');
|
||||
});
|
||||
|
||||
test('isOutlierAnalysis()', () => {
|
||||
const outlierAnalysis = { outlier_detection: {} };
|
||||
expect(isOutlierAnalysis(outlierAnalysis)).toBe(true);
|
||||
|
||||
const regressionAnalysis = { regression: {} };
|
||||
expect(isOutlierAnalysis(regressionAnalysis)).toBe(false);
|
||||
|
||||
const unknownAnalysis = { outlier_detection: {}, regression: {} };
|
||||
expect(isOutlierAnalysis(unknownAnalysis)).toBe(false);
|
||||
});
|
||||
|
||||
test('getValuesFromResponse()', () => {
|
||||
const evalResponse: any = {
|
||||
regression: {
|
||||
|
|
|
@ -10,61 +10,19 @@ import { BehaviorSubject, Subscription } from 'rxjs';
|
|||
import { distinctUntilChanged, filter } from 'rxjs/operators';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { extractErrorMessage } from '@kbn/ml-error-utils';
|
||||
import {
|
||||
type ClassificationEvaluateResponse,
|
||||
type DataFrameAnalysisConfigType,
|
||||
type EvaluateMetrics,
|
||||
type TrackTotalHitsSearchResponse,
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { ml } from '../../services/ml_api_service';
|
||||
import { Dictionary } from '../../../../common/types/common';
|
||||
import {
|
||||
ClassificationEvaluateResponse,
|
||||
EvaluateMetrics,
|
||||
TrackTotalHitsSearchResponse,
|
||||
} from '../../../../common/types/data_frame_analytics';
|
||||
import { SavedSearchQuery } from '../../contexts/ml';
|
||||
import {
|
||||
AnalysisConfig,
|
||||
ClassificationAnalysis,
|
||||
DataFrameAnalysisConfigType,
|
||||
RegressionAnalysis,
|
||||
} from '../../../../common/types/data_frame_analytics';
|
||||
import {
|
||||
isOutlierAnalysis,
|
||||
isRegressionAnalysis,
|
||||
isClassificationAnalysis,
|
||||
getPredictionFieldName,
|
||||
getDependentVar,
|
||||
getPredictedFieldName,
|
||||
} from '../../../../common/util/analytics_utils';
|
||||
import { ANALYSIS_CONFIG_TYPE } from '../../../../common/constants/data_frame_analytics';
|
||||
|
||||
export { getAnalysisType } from '../../../../common/util/analytics_utils';
|
||||
export type IndexPattern = string;
|
||||
|
||||
export enum ANALYSIS_ADVANCED_FIELDS {
|
||||
ALPHA = 'alpha',
|
||||
ETA = 'eta',
|
||||
ETA_GROWTH_RATE_PER_TREE = 'eta_growth_rate_per_tree',
|
||||
DOWNSAMPLE_FACTOR = 'downsample_factor',
|
||||
FEATURE_BAG_FRACTION = 'feature_bag_fraction',
|
||||
FEATURE_INFLUENCE_THRESHOLD = 'feature_influence_threshold',
|
||||
GAMMA = 'gamma',
|
||||
LAMBDA = 'lambda',
|
||||
MAX_TREES = 'max_trees',
|
||||
MAX_OPTIMIZATION_ROUNDS_PER_HYPERPARAMETER = 'max_optimization_rounds_per_hyperparameter',
|
||||
METHOD = 'method',
|
||||
N_NEIGHBORS = 'n_neighbors',
|
||||
NUM_TOP_CLASSES = 'num_top_classes',
|
||||
NUM_TOP_FEATURE_IMPORTANCE_VALUES = 'num_top_feature_importance_values',
|
||||
OUTLIER_FRACTION = 'outlier_fraction',
|
||||
RANDOMIZE_SEED = 'randomize_seed',
|
||||
SOFT_TREE_DEPTH_LIMIT = 'soft_tree_depth_limit',
|
||||
SOFT_TREE_DEPTH_TOLERANCE = 'soft_tree_depth_tolerance',
|
||||
}
|
||||
|
||||
export enum OUTLIER_ANALYSIS_METHOD {
|
||||
LOF = 'lof',
|
||||
LDOF = 'ldof',
|
||||
DISTANCE_KTH_NN = 'distance_kth_nn',
|
||||
DISTANCE_KNN = 'distance_knn',
|
||||
}
|
||||
|
||||
export interface LoadExploreDataArg {
|
||||
filterByIsTraining?: boolean;
|
||||
searchQuery: SavedSearchQuery;
|
||||
|
@ -78,11 +36,6 @@ export interface ClassificationMetricItem {
|
|||
|
||||
export const SEARCH_SIZE = 1000;
|
||||
|
||||
export const TRAINING_PERCENT_MIN = 1;
|
||||
export const TRAINING_PERCENT_MAX = 100;
|
||||
|
||||
export const NUM_TOP_FEATURE_IMPORTANCE_VALUES_MIN = 0;
|
||||
|
||||
export const defaultSearchQuery = {
|
||||
match_all: {},
|
||||
};
|
||||
|
@ -104,13 +57,6 @@ export interface SearchQuery {
|
|||
sort?: any;
|
||||
}
|
||||
|
||||
export enum INDEX_STATUS {
|
||||
UNUSED,
|
||||
LOADING,
|
||||
LOADED,
|
||||
ERROR,
|
||||
}
|
||||
|
||||
export interface Eval {
|
||||
mse: number | string;
|
||||
msle: number | string;
|
||||
|
@ -142,54 +88,6 @@ interface LoadEvaluateResult {
|
|||
error: string | null;
|
||||
}
|
||||
|
||||
export const getTrainingPercent = (
|
||||
analysis: AnalysisConfig
|
||||
):
|
||||
| RegressionAnalysis['regression']['training_percent']
|
||||
| ClassificationAnalysis['classification']['training_percent']
|
||||
| undefined => {
|
||||
let trainingPercent;
|
||||
|
||||
if (isRegressionAnalysis(analysis)) {
|
||||
trainingPercent = analysis.regression.training_percent;
|
||||
}
|
||||
|
||||
if (isClassificationAnalysis(analysis)) {
|
||||
trainingPercent = analysis.classification.training_percent;
|
||||
}
|
||||
return trainingPercent;
|
||||
};
|
||||
|
||||
export const getNumTopClasses = (
|
||||
analysis: AnalysisConfig
|
||||
): ClassificationAnalysis['classification']['num_top_classes'] => {
|
||||
let numTopClasses;
|
||||
if (isClassificationAnalysis(analysis) && analysis.classification.num_top_classes !== undefined) {
|
||||
numTopClasses = analysis.classification.num_top_classes;
|
||||
}
|
||||
return numTopClasses;
|
||||
};
|
||||
|
||||
export const getNumTopFeatureImportanceValues = (
|
||||
analysis: AnalysisConfig
|
||||
):
|
||||
| RegressionAnalysis['regression']['num_top_feature_importance_values']
|
||||
| ClassificationAnalysis['classification']['num_top_feature_importance_values'] => {
|
||||
let numTopFeatureImportanceValues;
|
||||
if (
|
||||
isRegressionAnalysis(analysis) &&
|
||||
analysis.regression.num_top_feature_importance_values !== undefined
|
||||
) {
|
||||
numTopFeatureImportanceValues = analysis.regression.num_top_feature_importance_values;
|
||||
} else if (
|
||||
isClassificationAnalysis(analysis) &&
|
||||
analysis.classification.num_top_feature_importance_values !== undefined
|
||||
) {
|
||||
numTopFeatureImportanceValues = analysis.classification.num_top_feature_importance_values;
|
||||
}
|
||||
return numTopFeatureImportanceValues;
|
||||
};
|
||||
|
||||
export const isResultsSearchBoolQuery = (arg: any): arg is ResultsSearchBoolQuery => {
|
||||
if (arg === undefined) return false;
|
||||
const keys = Object.keys(arg);
|
||||
|
@ -511,13 +409,3 @@ export const loadDocsCount = async ({
|
|||
};
|
||||
}
|
||||
};
|
||||
|
||||
export {
|
||||
isOutlierAnalysis,
|
||||
isRegressionAnalysis,
|
||||
isClassificationAnalysis,
|
||||
getPredictionFieldName,
|
||||
getDependentVar,
|
||||
getPredictedFieldName,
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
};
|
||||
|
|
|
@ -1,277 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/field-types';
|
||||
import { getNumTopClasses, getNumTopFeatureImportanceValues } from './analytics';
|
||||
import { Field } from '../../../../common/types/fields';
|
||||
import {
|
||||
getPredictedFieldName,
|
||||
getDependentVar,
|
||||
getPredictionFieldName,
|
||||
isClassificationAnalysis,
|
||||
isOutlierAnalysis,
|
||||
isRegressionAnalysis,
|
||||
} from '../../../../common/util/analytics_utils';
|
||||
import { newJobCapsServiceAnalytics } from '../../services/new_job_capabilities/new_job_capabilities_service_analytics';
|
||||
|
||||
import { FEATURE_IMPORTANCE, FEATURE_INFLUENCE, OUTLIER_SCORE, TOP_CLASSES } from './constants';
|
||||
import { DataFrameAnalyticsConfig } from '../../../../common/types/data_frame_analytics';
|
||||
|
||||
export type EsId = string;
|
||||
export type EsDocSource = Record<string, any>;
|
||||
export type EsFieldName = string;
|
||||
|
||||
export interface EsDoc extends Record<string, any> {
|
||||
_id: EsId;
|
||||
_source: EsDocSource;
|
||||
}
|
||||
|
||||
export const MAX_COLUMNS = 10;
|
||||
export const DEFAULT_REGRESSION_COLUMNS = 8;
|
||||
|
||||
export const BASIC_NUMERICAL_TYPES = new Set([
|
||||
ES_FIELD_TYPES.UNSIGNED_LONG,
|
||||
ES_FIELD_TYPES.LONG,
|
||||
ES_FIELD_TYPES.INTEGER,
|
||||
ES_FIELD_TYPES.SHORT,
|
||||
ES_FIELD_TYPES.BYTE,
|
||||
]);
|
||||
|
||||
export const EXTENDED_NUMERICAL_TYPES = new Set([
|
||||
ES_FIELD_TYPES.DOUBLE,
|
||||
ES_FIELD_TYPES.FLOAT,
|
||||
ES_FIELD_TYPES.HALF_FLOAT,
|
||||
ES_FIELD_TYPES.SCALED_FLOAT,
|
||||
]);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
export const ML__ID_COPY = 'ml__id_copy';
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
export const ML__INCREMENTAL_ID = 'ml__incremental_id';
|
||||
|
||||
export const isKeywordAndTextType = (fieldName: string): boolean => {
|
||||
const { fields } = newJobCapsServiceAnalytics;
|
||||
|
||||
const fieldType = fields.find((field) => field.name === fieldName)?.type;
|
||||
let isBothTypes = false;
|
||||
|
||||
// If it's a keyword type - check if it has a corresponding text type
|
||||
if (fieldType !== undefined && fieldType === ES_FIELD_TYPES.KEYWORD) {
|
||||
const field = newJobCapsServiceAnalytics.getFieldById(fieldName.replace(/\.keyword$/, ''));
|
||||
isBothTypes = field !== null && field.type === ES_FIELD_TYPES.TEXT;
|
||||
} else if (fieldType !== undefined && fieldType === ES_FIELD_TYPES.TEXT) {
|
||||
// If text, check if has corresponding keyword type
|
||||
const field = newJobCapsServiceAnalytics.getFieldById(`${fieldName}.keyword`);
|
||||
isBothTypes = field !== null && field.type === ES_FIELD_TYPES.KEYWORD;
|
||||
}
|
||||
|
||||
return isBothTypes;
|
||||
};
|
||||
|
||||
// Used to sort columns:
|
||||
// - Anchor on the left ml.outlier_score, ml.is_training, <predictedField>, <actual>
|
||||
// - string based columns are moved to the left
|
||||
// - feature_influence/feature_importance fields get moved next to the corresponding field column
|
||||
// - overall fields get sorted alphabetically
|
||||
export const sortExplorationResultsFields = (
|
||||
a: string,
|
||||
b: string,
|
||||
jobConfig: DataFrameAnalyticsConfig
|
||||
) => {
|
||||
const resultsField = jobConfig.dest.results_field;
|
||||
|
||||
if (isOutlierAnalysis(jobConfig.analysis)) {
|
||||
if (a === `${resultsField}.${OUTLIER_SCORE}`) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (b === `${resultsField}.${OUTLIER_SCORE}`) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (isClassificationAnalysis(jobConfig.analysis) || isRegressionAnalysis(jobConfig.analysis)) {
|
||||
const dependentVariable = getDependentVar(jobConfig.analysis);
|
||||
const predictedField = getPredictedFieldName(resultsField!, jobConfig.analysis, true);
|
||||
|
||||
if (a === `${resultsField}.is_training`) {
|
||||
return -1;
|
||||
}
|
||||
if (b === `${resultsField}.is_training`) {
|
||||
return 1;
|
||||
}
|
||||
if (a === predictedField) {
|
||||
return -1;
|
||||
}
|
||||
if (b === predictedField) {
|
||||
return 1;
|
||||
}
|
||||
if (a === dependentVariable || a === dependentVariable.replace(/\.keyword$/, '')) {
|
||||
return -1;
|
||||
}
|
||||
if (b === dependentVariable || b === dependentVariable.replace(/\.keyword$/, '')) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (a === `${resultsField}.prediction_probability`) {
|
||||
return -1;
|
||||
}
|
||||
if (b === `${resultsField}.prediction_probability`) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
const typeofA = typeof a;
|
||||
const typeofB = typeof b;
|
||||
|
||||
const tokensA = a.split('.');
|
||||
const prefixA = tokensA[0];
|
||||
const tokensB = b.split('.');
|
||||
const prefixB = tokensB[0];
|
||||
|
||||
if (prefixA === resultsField && tokensA.length > 1 && prefixB !== resultsField) {
|
||||
tokensA.shift();
|
||||
tokensA.shift();
|
||||
if (tokensA.join('.') === b) return 1;
|
||||
return tokensA.join('.').localeCompare(b);
|
||||
}
|
||||
|
||||
if (prefixB === resultsField && tokensB.length > 1 && prefixA !== resultsField) {
|
||||
tokensB.shift();
|
||||
tokensB.shift();
|
||||
if (tokensB.join('.') === a) return -1;
|
||||
return a.localeCompare(tokensB.join('.'));
|
||||
}
|
||||
|
||||
if (typeofA !== 'string' && typeofB === 'string') {
|
||||
return 1;
|
||||
}
|
||||
if (typeofA === 'string' && typeofB !== 'string') {
|
||||
return -1;
|
||||
}
|
||||
if (typeofA === 'string' && typeofB === 'string') {
|
||||
return a.localeCompare(b);
|
||||
}
|
||||
|
||||
return a.localeCompare(b);
|
||||
};
|
||||
|
||||
export const getDefaultFieldsFromJobCaps = (
|
||||
fields: Field[],
|
||||
jobConfig: DataFrameAnalyticsConfig,
|
||||
needsDestIndexFields: boolean
|
||||
): {
|
||||
selectedFields: Field[];
|
||||
docFields: Field[];
|
||||
depVarType?: ES_FIELD_TYPES;
|
||||
} => {
|
||||
const fieldsObj = {
|
||||
selectedFields: [],
|
||||
docFields: [],
|
||||
};
|
||||
if (fields.length === 0) {
|
||||
return fieldsObj;
|
||||
}
|
||||
|
||||
// default is 'ml'
|
||||
const resultsField = jobConfig.dest.results_field;
|
||||
|
||||
const allFields: any = [];
|
||||
let type: ES_FIELD_TYPES | undefined;
|
||||
let predictedField: string | undefined;
|
||||
|
||||
if (isOutlierAnalysis(jobConfig.analysis)) {
|
||||
if (!jobConfig.analysis.outlier_detection.compute_feature_influence) {
|
||||
// remove all feature influence fields
|
||||
fields = fields.filter(
|
||||
(field) => !field.name.includes(`${resultsField}.${FEATURE_INFLUENCE}`)
|
||||
);
|
||||
} else {
|
||||
// remove flattened feature influence fields
|
||||
fields = fields.filter(
|
||||
(field: any) => !field.name.includes(`${resultsField}.${FEATURE_INFLUENCE}.`)
|
||||
);
|
||||
}
|
||||
|
||||
// Only need to add these fields if we didn't use dest data view to get the fields
|
||||
if (needsDestIndexFields === true) {
|
||||
allFields.push({
|
||||
id: `${resultsField}.${OUTLIER_SCORE}`,
|
||||
name: `${resultsField}.${OUTLIER_SCORE}`,
|
||||
type: KBN_FIELD_TYPES.NUMBER,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (isClassificationAnalysis(jobConfig.analysis) || isRegressionAnalysis(jobConfig.analysis)) {
|
||||
const dependentVariable = getDependentVar(jobConfig.analysis);
|
||||
type = newJobCapsServiceAnalytics.getFieldById(dependentVariable)?.type;
|
||||
const predictionFieldName = getPredictionFieldName(jobConfig.analysis);
|
||||
const numTopFeatureImportanceValues = getNumTopFeatureImportanceValues(jobConfig.analysis);
|
||||
const numTopClasses = getNumTopClasses(jobConfig.analysis);
|
||||
|
||||
const defaultPredictionField = `${dependentVariable}_prediction`;
|
||||
predictedField = `${resultsField}.${
|
||||
predictionFieldName ? predictionFieldName : defaultPredictionField
|
||||
}`;
|
||||
|
||||
if ((numTopFeatureImportanceValues ?? 0) === 0) {
|
||||
// remove all feature importance fields
|
||||
fields = fields.filter(
|
||||
(field: any) => !field.name.includes(`${resultsField}.${FEATURE_IMPORTANCE}`)
|
||||
);
|
||||
} else {
|
||||
// remove flattened feature importance fields
|
||||
fields = fields.filter(
|
||||
(field: any) => !field.name.includes(`${resultsField}.${FEATURE_IMPORTANCE}.`)
|
||||
);
|
||||
}
|
||||
|
||||
if ((numTopClasses ?? 0) === 0) {
|
||||
// remove all top classes fields
|
||||
fields = fields.filter(
|
||||
(field: any) => !field.name.includes(`${resultsField}.${TOP_CLASSES}`)
|
||||
);
|
||||
} else {
|
||||
// remove flattened top classes fields
|
||||
fields = fields.filter(
|
||||
(field: any) => !field.name.includes(`${resultsField}.${TOP_CLASSES}.`)
|
||||
);
|
||||
}
|
||||
|
||||
// Only need to add these fields if we didn't use dest data view to get the fields
|
||||
if (needsDestIndexFields === true) {
|
||||
allFields.push(
|
||||
{
|
||||
id: `${resultsField}.is_training`,
|
||||
name: `${resultsField}.is_training`,
|
||||
type: ES_FIELD_TYPES.BOOLEAN,
|
||||
},
|
||||
{ id: predictedField, name: predictedField, type }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
allFields.push(...fields);
|
||||
allFields.sort(({ name: a }: { name: string }, { name: b }: { name: string }) =>
|
||||
sortExplorationResultsFields(a, b, jobConfig)
|
||||
);
|
||||
|
||||
let selectedFields = allFields.filter(
|
||||
(field: any) => field.name === predictedField || !field.name.includes('.keyword')
|
||||
);
|
||||
|
||||
if (selectedFields.length > DEFAULT_REGRESSION_COLUMNS) {
|
||||
selectedFields = selectedFields.slice(0, DEFAULT_REGRESSION_COLUMNS);
|
||||
}
|
||||
|
||||
return {
|
||||
selectedFields,
|
||||
docFields: allFields,
|
||||
depVarType: type,
|
||||
};
|
||||
};
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { DataFrameAnalyticsConfig } from '../../../../common/types/data_frame_analytics';
|
||||
import type { DataFrameAnalyticsConfig } from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
export const getDestinationIndex = (jobConfig: DataFrameAnalyticsConfig | undefined) =>
|
||||
(Array.isArray(jobConfig?.dest.index) ? jobConfig?.dest.index[0] : jobConfig?.dest.index) ?? '';
|
||||
|
|
|
@ -7,16 +7,14 @@
|
|||
|
||||
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { extractErrorMessage } from '@kbn/ml-error-utils';
|
||||
import { type DataFrameAnalyticsConfig, INDEX_STATUS } from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { EsSorting, UseDataGridReturnType, getProcessedFields } from '../../components/data_grid';
|
||||
import { ml } from '../../services/ml_api_service';
|
||||
import { newJobCapsServiceAnalytics } from '../../services/new_job_capabilities/new_job_capabilities_service_analytics';
|
||||
|
||||
import { isKeywordAndTextType } from './fields';
|
||||
import { SavedSearchQuery } from '../../contexts/ml';
|
||||
|
||||
import { INDEX_STATUS } from './analytics';
|
||||
import { DataFrameAnalyticsConfig } from '../../../../common/types/data_frame_analytics';
|
||||
|
||||
export const getIndexData = async (
|
||||
jobConfig: DataFrameAnalyticsConfig | undefined,
|
||||
dataGrid: UseDataGridReturnType,
|
||||
|
@ -40,7 +38,7 @@ export const getIndexData = async (
|
|||
const sort: EsSorting = sortingColumns
|
||||
.map((column) => {
|
||||
const { id } = column;
|
||||
column.id = isKeywordAndTextType(id) ? `${id}.keyword` : id;
|
||||
column.id = newJobCapsServiceAnalytics.isKeywordAndTextType(id) ? `${id}.keyword` : id;
|
||||
return column;
|
||||
})
|
||||
.reduce((s, column) => {
|
||||
|
|
|
@ -7,10 +7,9 @@
|
|||
|
||||
import { ES_FIELD_TYPES } from '@kbn/field-types';
|
||||
|
||||
import { DataFrameAnalyticsConfig } from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { newJobCapsServiceAnalytics } from '../../services/new_job_capabilities/new_job_capabilities_service_analytics';
|
||||
|
||||
import { getDefaultFieldsFromJobCaps, DataFrameAnalyticsConfig } from '.';
|
||||
|
||||
export interface FieldTypes {
|
||||
[key: string]: ES_FIELD_TYPES;
|
||||
}
|
||||
|
@ -19,13 +18,9 @@ export const getIndexFields = (
|
|||
jobConfig: DataFrameAnalyticsConfig | undefined,
|
||||
needsDestIndexFields: boolean
|
||||
) => {
|
||||
const { fields } = newJobCapsServiceAnalytics;
|
||||
if (jobConfig !== undefined) {
|
||||
const { selectedFields: defaultSelected, docFields } = getDefaultFieldsFromJobCaps(
|
||||
fields,
|
||||
jobConfig,
|
||||
needsDestIndexFields
|
||||
);
|
||||
const { selectedFields: defaultSelected, docFields } =
|
||||
newJobCapsServiceAnalytics.getDefaultFields(jobConfig, needsDestIndexFields);
|
||||
|
||||
const types: FieldTypes = {};
|
||||
const allFields: string[] = [];
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { ANALYSIS_CONFIG_TYPE } from './analytics';
|
||||
import { ANALYSIS_CONFIG_TYPE } from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { AnalyticsJobType } from '../pages/analytics_management/hooks/use_create_analytics_form/state';
|
||||
|
||||
|
|
|
@ -7,34 +7,20 @@
|
|||
|
||||
export type { IndexPattern, RegressionEvaluateResponse, Eval, SearchQuery } from './analytics';
|
||||
export {
|
||||
getAnalysisType,
|
||||
getDependentVar,
|
||||
getPredictionFieldName,
|
||||
getDefaultTrainingFilterQuery,
|
||||
isOutlierAnalysis,
|
||||
refreshAnalyticsList$,
|
||||
useRefreshAnalyticsList,
|
||||
REFRESH_ANALYTICS_LIST_STATE,
|
||||
OUTLIER_ANALYSIS_METHOD,
|
||||
getValuesFromResponse,
|
||||
loadEvalData,
|
||||
loadDocsCount,
|
||||
getPredictedFieldName,
|
||||
INDEX_STATUS,
|
||||
SEARCH_SIZE,
|
||||
defaultSearchQuery,
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
} from './analytics';
|
||||
|
||||
export type { EsId, EsDoc, EsDocSource, EsFieldName } from './fields';
|
||||
export { getDefaultFieldsFromJobCaps, sortExplorationResultsFields, MAX_COLUMNS } from './fields';
|
||||
|
||||
export { getIndexData } from './get_index_data';
|
||||
export { getIndexFields } from './get_index_fields';
|
||||
export { getDestinationIndex } from './get_destination_index';
|
||||
export { getScatterplotMatrixLegendType } from './get_scatterplot_matrix_legend_type';
|
||||
|
||||
export { useResultsViewConfig } from './use_results_view_config';
|
||||
export type { DataFrameAnalyticsConfig } from '../../../../common/types/data_frame_analytics';
|
||||
export type { DataFrameAnalyticsId } from '../../../../common/types/data_frame_analytics';
|
||||
export type { IndexName } from '../../../../common/types/data_frame_analytics';
|
||||
|
|
|
@ -11,23 +11,22 @@ import { i18n } from '@kbn/i18n';
|
|||
|
||||
import type { DataView } from '@kbn/data-views-plugin/public';
|
||||
import { extractErrorMessage } from '@kbn/ml-error-utils';
|
||||
import {
|
||||
isClassificationAnalysis,
|
||||
isRegressionAnalysis,
|
||||
type DataFrameAnalyticsConfig,
|
||||
type DataFrameTaskStateType,
|
||||
type TotalFeatureImportance,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { getDataViewIdFromName } from '../../util/index_utils';
|
||||
import { ml } from '../../services/ml_api_service';
|
||||
import { newJobCapsServiceAnalytics } from '../../services/new_job_capabilities/new_job_capabilities_service_analytics';
|
||||
import { useMlContext } from '../../contexts/ml';
|
||||
|
||||
import { DataFrameAnalyticsConfig } from '.';
|
||||
|
||||
import { isGetDataFrameAnalyticsStatsResponseOk } from '../pages/analytics_management/services/analytics_service/get_analytics';
|
||||
import { DataFrameTaskStateType } from '../pages/analytics_management/components/analytics_list/common';
|
||||
import { useTrainedModelsApiService } from '../../services/ml_api_service/trained_models';
|
||||
import { TotalFeatureImportance } from '../../../../common/types/feature_importance';
|
||||
import { getToastNotificationService } from '../../services/toast_notification_service';
|
||||
import {
|
||||
isClassificationAnalysis,
|
||||
isRegressionAnalysis,
|
||||
} from '../../../../common/util/analytics_utils';
|
||||
import { getDestinationIndex } from './get_destination_index';
|
||||
|
||||
export const useResultsViewConfig = (jobId: string) => {
|
||||
|
|
|
@ -15,11 +15,11 @@ import {
|
|||
EuiSpacer,
|
||||
EuiTitle,
|
||||
} from '@elastic/eui';
|
||||
import { ANALYSIS_CONFIG_TYPE } from '@kbn/ml-data-frame-analytics-utils';
|
||||
import {
|
||||
UNSET_CONFIG_ITEM,
|
||||
State,
|
||||
} from '../../../analytics_management/hooks/use_create_analytics_form/state';
|
||||
import { ANALYSIS_CONFIG_TYPE } from '../../../../common/analytics';
|
||||
import { ANALYTICS_STEPS } from '../../page';
|
||||
|
||||
function getStringValue(value: number | undefined) {
|
||||
|
|
|
@ -23,14 +23,14 @@ import {
|
|||
EuiTitle,
|
||||
} from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { HyperParameters } from './hyper_parameters';
|
||||
import { CreateAnalyticsStepProps } from '../../../analytics_management/hooks/use_create_analytics_form';
|
||||
import { getModelMemoryLimitErrors } from '../../../analytics_management/hooks/use_create_analytics_form/reducer';
|
||||
import {
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
NUM_TOP_FEATURE_IMPORTANCE_VALUES_MIN,
|
||||
ANALYSIS_ADVANCED_FIELDS,
|
||||
} from '../../../../common/analytics';
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { HyperParameters } from './hyper_parameters';
|
||||
import { CreateAnalyticsStepProps } from '../../../analytics_management/hooks/use_create_analytics_form';
|
||||
import { getModelMemoryLimitErrors } from '../../../analytics_management/hooks/use_create_analytics_form/reducer';
|
||||
import { useMlKibana } from '../../../../../contexts/kibana';
|
||||
import { DEFAULT_MODEL_MEMORY_LIMIT } from '../../../analytics_management/hooks/use_create_analytics_form/state';
|
||||
import { ANALYTICS_STEPS } from '../../page';
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
import React, { FC, Fragment } from 'react';
|
||||
import { EuiFieldNumber, EuiFlexItem, EuiFormRow } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { ANALYSIS_ADVANCED_FIELDS } from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { CreateAnalyticsFormProps } from '../../../analytics_management/hooks/use_create_analytics_form';
|
||||
import { AdvancedParamErrors, getNumberValue } from './advanced_step_form';
|
||||
import { ANALYSIS_ADVANCED_FIELDS } from '../../../../common/analytics';
|
||||
|
||||
const MAX_TREES_LIMIT = 2000;
|
||||
|
||||
|
|
|
@ -8,7 +8,10 @@
|
|||
import React, { FC, Fragment } from 'react';
|
||||
import { EuiFieldNumber, EuiFlexItem, EuiFormRow, EuiSelect } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { OUTLIER_ANALYSIS_METHOD, ANALYSIS_ADVANCED_FIELDS } from '../../../../common/analytics';
|
||||
import {
|
||||
OUTLIER_ANALYSIS_METHOD,
|
||||
ANALYSIS_ADVANCED_FIELDS,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { CreateAnalyticsFormProps } from '../../../analytics_management/hooks/use_create_analytics_form';
|
||||
import { AdvancedParamErrors, getNumberValue } from './advanced_step_form';
|
||||
|
||||
|
|
|
@ -13,12 +13,12 @@ import { LEFT_ALIGNMENT, SortableProperties } from '@elastic/eui/lib/services';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { ES_FIELD_TYPES } from '@kbn/field-types';
|
||||
import { FieldSelectionItem } from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { useFieldStatsTrigger } from '../../../../../components/field_stats_flyout/use_field_stats_trigger';
|
||||
import {
|
||||
FieldForStats,
|
||||
FieldStatsInfoButton,
|
||||
} from '../../../../../components/field_stats_flyout/field_stats_info_button';
|
||||
import { FieldSelectionItem } from '../../../../../../../common/types/data_frame_analytics';
|
||||
// @ts-ignore could not find declaration file
|
||||
import { CustomSelectionTable } from '../../../../../components/custom_selection_table';
|
||||
|
||||
|
|
|
@ -14,11 +14,11 @@ import {
|
|||
EuiFlexItem,
|
||||
EuiSpacer,
|
||||
} from '@elastic/eui';
|
||||
import { ANALYSIS_CONFIG_TYPE } from '@kbn/ml-data-frame-analytics-utils';
|
||||
import {
|
||||
State,
|
||||
UNSET_CONFIG_ITEM,
|
||||
} from '../../../analytics_management/hooks/use_create_analytics_form/state';
|
||||
import { ANALYSIS_CONFIG_TYPE } from '../../../../common/analytics';
|
||||
import { useMlContext } from '../../../../../contexts/ml';
|
||||
import { ANALYTICS_STEPS } from '../../page';
|
||||
|
||||
|
|
|
@ -21,6 +21,13 @@ import { debounce, cloneDeep } from 'lodash';
|
|||
import { Query } from '@kbn/data-plugin/common/query';
|
||||
import { ES_FIELD_TYPES } from '@kbn/field-types';
|
||||
import { FieldStatsServices } from '@kbn/unified-field-list-plugin/public';
|
||||
import {
|
||||
type FieldSelectionItem,
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
TRAINING_PERCENT_MIN,
|
||||
TRAINING_PERCENT_MAX,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { useMlKibana } from '../../../../../contexts/kibana';
|
||||
import {
|
||||
EuiComboBoxWithFieldStats,
|
||||
|
@ -31,14 +38,8 @@ import { newJobCapsServiceAnalytics } from '../../../../../services/new_job_capa
|
|||
import { useMlContext } from '../../../../../contexts/ml';
|
||||
import { getCombinedRuntimeMappings } from '../../../../../components/data_grid/common';
|
||||
|
||||
import {
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
TRAINING_PERCENT_MIN,
|
||||
TRAINING_PERCENT_MAX,
|
||||
} from '../../../../common/analytics';
|
||||
import { getScatterplotMatrixLegendType } from '../../../../common/get_scatterplot_matrix_legend_type';
|
||||
import { RuntimeMappings as RuntimeMappingsType } from '../../../../../../../common/types/fields';
|
||||
import { FieldSelectionItem } from '../../../../../../../common/types/data_frame_analytics';
|
||||
import {
|
||||
isRuntimeMappings,
|
||||
isRuntimeField,
|
||||
|
|
|
@ -8,10 +8,13 @@
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { ES_FIELD_TYPES } from '@kbn/field-types';
|
||||
import {
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
BASIC_NUMERICAL_TYPES,
|
||||
EXTENDED_NUMERICAL_TYPES,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { EVENT_RATE_FIELD_ID } from '../../../../../../../common/types/fields';
|
||||
import { ANALYSIS_CONFIG_TYPE } from '../../../../common/analytics';
|
||||
import { AnalyticsJobType } from '../../../analytics_management/hooks/use_create_analytics_form/state';
|
||||
import { BASIC_NUMERICAL_TYPES, EXTENDED_NUMERICAL_TYPES } from '../../../../common/fields';
|
||||
|
||||
export const CATEGORICAL_TYPES = new Set(['ip', 'keyword']);
|
||||
|
||||
|
|
|
@ -9,8 +9,10 @@ import React, { FC, useState } from 'react';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { EuiCard, EuiIcon, EuiFlexItem, EuiFlexGroup, EuiSpacer } from '@elastic/eui';
|
||||
import { ANALYSIS_CONFIG_TYPE } from '../../../../../../../common/constants/data_frame_analytics';
|
||||
import { DataFrameAnalysisConfigType } from '../../../../../../../common/types/data_frame_analytics';
|
||||
import {
|
||||
type DataFrameAnalysisConfigType,
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { AnalyticsJobType } from '../../../analytics_management/hooks/use_create_analytics_form/state';
|
||||
|
||||
|
|
|
@ -8,16 +8,18 @@
|
|||
import React, { FC, Fragment, useState, useEffect } from 'react';
|
||||
import { EuiSpacer, EuiText } from '@elastic/eui';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
|
||||
import { ES_FIELD_TYPES } from '@kbn/field-types';
|
||||
import { AnalyticsJobType } from '../../../analytics_management/hooks/use_create_analytics_form/state';
|
||||
import { ANALYSIS_CONFIG_TYPE } from '../../../../common/analytics';
|
||||
import {
|
||||
type DataFrameAnalysisConfigType,
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
BASIC_NUMERICAL_TYPES,
|
||||
EXTENDED_NUMERICAL_TYPES,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { Field, EVENT_RATE_FIELD_ID } from '../../../../../../../common/types/fields';
|
||||
import { OMIT_FIELDS } from '../../../../../../../common/constants/field_types';
|
||||
import { BASIC_NUMERICAL_TYPES, EXTENDED_NUMERICAL_TYPES } from '../../../../common/fields';
|
||||
import { AnalyticsJobType } from '../../../analytics_management/hooks/use_create_analytics_form/state';
|
||||
import { CATEGORICAL_TYPES } from './form_options_validation';
|
||||
import { newJobCapsServiceAnalytics } from '../../../../../services/new_job_capabilities/new_job_capabilities_service_analytics';
|
||||
import { DataFrameAnalysisConfigType } from '../../../../../../../common/types/data_frame_analytics';
|
||||
|
||||
const containsClassificationFieldsCb = ({ name, type }: Field) =>
|
||||
!OMIT_FIELDS.includes(name) &&
|
||||
|
|
|
@ -10,16 +10,16 @@ import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule } from '@elastic/eui';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import {
|
||||
getDataFrameAnalyticsProgressPhase,
|
||||
type DataFrameAnalysisConfigType,
|
||||
DATA_FRAME_TASK_STATE,
|
||||
} from '../../../analytics_management/components/analytics_list/common';
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { getDataFrameAnalyticsProgressPhase } from '../../../analytics_management/components/analytics_list/common';
|
||||
import { isGetDataFrameAnalyticsStatsResponseOk } from '../../../analytics_management/services/analytics_service/get_analytics';
|
||||
import { useMlKibana } from '../../../../../contexts/kibana';
|
||||
import { ml } from '../../../../../services/ml_api_service';
|
||||
import { BackToListPanel } from '../back_to_list_panel';
|
||||
import { ViewResultsPanel } from '../view_results_panel';
|
||||
import { ProgressStats } from './progress_stats';
|
||||
import { DataFrameAnalysisConfigType } from '../../../../../../../common/types/data_frame_analytics';
|
||||
import { NewJobAwaitingNodeWarning } from '../../../../../components/jobs_awaiting_node_warning';
|
||||
|
||||
export const PROGRESS_REFRESH_INTERVAL_MS = 1000;
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
|
||||
import { extractErrorProperties } from '@kbn/ml-error-utils';
|
||||
|
||||
import { ml } from '../../../../../services/ml_api_service';
|
||||
import {
|
||||
import type {
|
||||
DfAnalyticsExplainResponse,
|
||||
FieldSelectionItem,
|
||||
} from '../../../../../../../common/types/data_frame_analytics';
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { ml } from '../../../../../services/ml_api_service';
|
||||
import {
|
||||
getJobConfigFromFormState,
|
||||
State,
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
import React, { FC, Fragment } from 'react';
|
||||
import { EuiCard, EuiIcon } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import type { DataFrameAnalysisConfigType } from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { useMlLink } from '../../../../../contexts/kibana';
|
||||
import { ML_PAGES } from '../../../../../../../common/constants/locator';
|
||||
import { DataFrameAnalysisConfigType } from '../../../../../../../common/types/data_frame_analytics';
|
||||
interface Props {
|
||||
jobId: string;
|
||||
analysisType: DataFrameAnalysisConfigType;
|
||||
|
|
|
@ -15,13 +15,12 @@ import type { DataView } from '@kbn/data-views-plugin/public';
|
|||
import { isPopulatedObject } from '@kbn/ml-is-populated-object';
|
||||
import type { TimeRange as TimeRangeMs } from '@kbn/ml-date-picker';
|
||||
import { extractErrorMessage } from '@kbn/ml-error-utils';
|
||||
import { INDEX_STATUS } from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { isRuntimeMappings } from '../../../../../../common/util/runtime_field_utils';
|
||||
import { RuntimeMappings } from '../../../../../../common/types/fields';
|
||||
import { DEFAULT_SAMPLER_SHARD_SIZE } from '../../../../../../common/constants/field_histograms';
|
||||
|
||||
import { DataLoader } from '../../../../datavisualizer/index_based/data_loader';
|
||||
|
||||
import {
|
||||
getFieldType,
|
||||
getDataGridSchemaFromKibanaFieldType,
|
||||
|
@ -35,8 +34,7 @@ import {
|
|||
getProcessedFields,
|
||||
getCombinedRuntimeMappings,
|
||||
} from '../../../../components/data_grid';
|
||||
|
||||
import { INDEX_STATUS } from '../../../common/analytics';
|
||||
import { DataLoader } from '../../../../datavisualizer/index_based/data_loader';
|
||||
import { ml } from '../../../../services/ml_api_service';
|
||||
|
||||
type IndexSearchResponse = estypes.SearchResponse;
|
||||
|
|
|
@ -18,6 +18,7 @@ import {
|
|||
} from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import type { DataFrameAnalyticsId } from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { useMlContext } from '../../../contexts/ml';
|
||||
import { ml } from '../../../services/ml_api_service';
|
||||
import { useCreateAnalyticsForm } from '../analytics_management/hooks/use_create_analytics_form';
|
||||
|
@ -29,7 +30,6 @@ import {
|
|||
DetailsStep,
|
||||
ValidationStepWrapper,
|
||||
} from './components';
|
||||
import { DataFrameAnalyticsId } from '../../../../../common/types/data_frame_analytics';
|
||||
import { MlPageHeader } from '../../../components/page_header';
|
||||
|
||||
export enum ANALYTICS_STEPS {
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
EuiPopover,
|
||||
EuiText,
|
||||
} from '@elastic/eui';
|
||||
import { ConfusionMatrix } from '../../../../../../../common/types/data_frame_analytics';
|
||||
import type { ConfusionMatrix } from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
const COL_INITIAL_WIDTH = 165; // in pixels
|
||||
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
import './_classification_exploration.scss';
|
||||
|
||||
import React, { FC, useEffect, useState } from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
|
||||
import {
|
||||
EuiButtonEmpty,
|
||||
EuiDataGrid,
|
||||
|
@ -20,6 +19,15 @@ import {
|
|||
EuiText,
|
||||
EuiTitle,
|
||||
} from '@elastic/eui';
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import {
|
||||
getDependentVar,
|
||||
type DataFrameAnalyticsConfig,
|
||||
type DataFrameTaskStateType,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { useCurrentThemeVars, useMlKibana } from '../../../../../contexts/kibana';
|
||||
|
||||
// Separate imports for lazy loadable VegaChart and related code
|
||||
|
@ -27,8 +35,6 @@ import { VegaChart } from '../../../../../components/vega_chart';
|
|||
import { VegaChartLoading } from '../../../../../components/vega_chart/vega_chart_loading';
|
||||
|
||||
import { ErrorCallout } from '../error_callout';
|
||||
import { DataFrameAnalyticsConfig, getDependentVar } from '../../../../common';
|
||||
import { DataFrameTaskStateType } from '../../../analytics_management/components/analytics_list/common';
|
||||
import { ResultsSearchQuery } from '../../../../common/analytics';
|
||||
|
||||
import { ExpandableSection, HEADER_ITEMS_LOADING } from '../expandable_section';
|
||||
|
|
|
@ -10,14 +10,13 @@
|
|||
import type { TopLevelSpec } from 'vega-lite/build/vega-lite';
|
||||
|
||||
import { euiPaletteColorBlind, euiPaletteGray } from '@elastic/eui';
|
||||
import { euiLightVars as euiThemeLight } from '@kbn/ui-theme';
|
||||
|
||||
import { euiLightVars as euiThemeLight } from '@kbn/ui-theme';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import type { RocCurveItem } from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { LEGEND_TYPES } from '../../../../../components/vega_chart/common';
|
||||
|
||||
import { RocCurveItem } from '../../../../../../../common/types/data_frame_analytics';
|
||||
|
||||
const GRAY = euiPaletteGray(1)[0];
|
||||
const BASELINE = 'baseline';
|
||||
const SIZE = 300;
|
||||
|
|
|
@ -7,25 +7,24 @@
|
|||
|
||||
import { useState, useEffect } from 'react';
|
||||
|
||||
import {
|
||||
isClassificationEvaluateResponse,
|
||||
ResultsSearchQuery,
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
ClassificationMetricItem,
|
||||
} from '../../../../common/analytics';
|
||||
import { isKeywordAndTextType } from '../../../../common/fields';
|
||||
import {
|
||||
ClassificationEvaluateResponse,
|
||||
ConfusionMatrix,
|
||||
} from '../../../../../../../common/types/data_frame_analytics';
|
||||
|
||||
import {
|
||||
getDependentVar,
|
||||
getPredictionFieldName,
|
||||
loadEvalData,
|
||||
loadDocsCount,
|
||||
DataFrameAnalyticsConfig,
|
||||
} from '../../../../common';
|
||||
type ClassificationEvaluateResponse,
|
||||
type ConfusionMatrix,
|
||||
type DataFrameAnalyticsConfig,
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { newJobCapsServiceAnalytics } from '../../../../../services/new_job_capabilities/new_job_capabilities_service_analytics';
|
||||
|
||||
import {
|
||||
isClassificationEvaluateResponse,
|
||||
ResultsSearchQuery,
|
||||
ClassificationMetricItem,
|
||||
} from '../../../../common/analytics';
|
||||
|
||||
import { loadEvalData, loadDocsCount } from '../../../../common';
|
||||
|
||||
import { isTrainingFilter } from './is_training_filter';
|
||||
|
||||
|
@ -84,7 +83,7 @@ export const useConfusionMatrix = (
|
|||
const isTraining = isTrainingFilter(searchQuery, resultsField);
|
||||
|
||||
try {
|
||||
requiresKeyword = isKeywordAndTextType(dependentVariable);
|
||||
requiresKeyword = newJobCapsServiceAnalytics.isKeywordAndTextType(dependentVariable);
|
||||
} catch (e) {
|
||||
// Additional error handling due to missing field type is handled by loadEvalData
|
||||
console.error('Unable to load new field types', e); // eslint-disable-line no-console
|
||||
|
|
|
@ -7,20 +7,19 @@
|
|||
|
||||
import { useState, useEffect } from 'react';
|
||||
|
||||
import {
|
||||
isClassificationEvaluateResponse,
|
||||
ResultsSearchQuery,
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
} from '../../../../common/analytics';
|
||||
import { isKeywordAndTextType } from '../../../../common/fields';
|
||||
import { RocCurveItem } from '../../../../../../../common/types/data_frame_analytics';
|
||||
|
||||
import {
|
||||
getDependentVar,
|
||||
getPredictionFieldName,
|
||||
loadEvalData,
|
||||
DataFrameAnalyticsConfig,
|
||||
} from '../../../../common';
|
||||
type DataFrameAnalyticsConfig,
|
||||
type RocCurveItem,
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { newJobCapsServiceAnalytics } from '../../../../../services/new_job_capabilities/new_job_capabilities_service_analytics';
|
||||
|
||||
import { isClassificationEvaluateResponse, ResultsSearchQuery } from '../../../../common/analytics';
|
||||
|
||||
import { loadEvalData } from '../../../../common';
|
||||
|
||||
import { ACTUAL_CLASS_ID, OTHER_CLASS_ID } from './column_data';
|
||||
|
||||
|
@ -66,7 +65,7 @@ export const useRocCurve = (
|
|||
const errors: string[] = [];
|
||||
|
||||
try {
|
||||
requiresKeyword = isKeywordAndTextType(dependentVariable);
|
||||
requiresKeyword = newJobCapsServiceAnalytics.isKeywordAndTextType(dependentVariable);
|
||||
} catch (e) {
|
||||
// Additional error handling due to missing field type is handled by loadEvalData
|
||||
console.error('Unable to load new field types', e); // eslint-disable-line no-console
|
||||
|
|
|
@ -11,12 +11,13 @@ import { FormattedMessage } from '@kbn/i18n-react';
|
|||
|
||||
import { EuiLoadingSpinner, EuiSpacer, EuiText } from '@elastic/eui';
|
||||
|
||||
import type { DataFrameAnalysisConfigType } from '../../../../../../../common/types/data_frame_analytics';
|
||||
import {
|
||||
getAnalysisType,
|
||||
type DataFrameAnalysisConfigType,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { ml } from '../../../../../services/ml_api_service';
|
||||
|
||||
import { getAnalysisType } from '../../../../common';
|
||||
|
||||
import { isGetDataFrameAnalyticsStatsResponseOk } from '../../../analytics_management/services/analytics_service/get_analytics';
|
||||
import {
|
||||
DataFrameAnalyticsListRow,
|
||||
|
|
|
@ -25,12 +25,15 @@ import {
|
|||
|
||||
import type { DataView } from '@kbn/data-views-plugin/public';
|
||||
import type { MlKibanaUrlConfig } from '@kbn/ml-anomaly-utils';
|
||||
|
||||
import type { DataGridItem } from '../../../../../components/data_grid';
|
||||
import {
|
||||
getAnalysisType,
|
||||
isClassificationAnalysis,
|
||||
isRegressionAnalysis,
|
||||
} from '../../../../../../../common/util/analytics_utils';
|
||||
type DataFrameAnalyticsConfig,
|
||||
INDEX_STATUS,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import type { DataGridItem } from '../../../../../components/data_grid';
|
||||
import { ES_CLIENT_TOTAL_HITS_RELATION } from '../../../../../../../common/types/es_client';
|
||||
import { SEARCH_QUERY_LANGUAGE } from '../../../../../../../common/constants/search';
|
||||
|
||||
|
@ -44,13 +47,7 @@ import {
|
|||
import { SavedSearchQuery } from '../../../../../contexts/ml';
|
||||
import { useMlKibana } from '../../../../../contexts/kibana';
|
||||
|
||||
import {
|
||||
defaultSearchQuery,
|
||||
DataFrameAnalyticsConfig,
|
||||
INDEX_STATUS,
|
||||
SEARCH_SIZE,
|
||||
getAnalysisType,
|
||||
} from '../../../../common';
|
||||
import { defaultSearchQuery, SEARCH_SIZE } from '../../../../common';
|
||||
|
||||
import {
|
||||
replaceTokensInDFAUrlValue,
|
||||
|
|
|
@ -9,8 +9,13 @@ import React, { FC, useCallback, useState } from 'react';
|
|||
|
||||
import { EuiCallOut, EuiFlexGroup, EuiFlexItem, EuiPanel, EuiSpacer, EuiText } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { getAnalysisType, getDependentVar } from '../../../../../../../common/util/analytics_utils';
|
||||
import {
|
||||
getAnalysisType,
|
||||
getDependentVar,
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
type DataFrameAnalyticsConfig,
|
||||
type DataFrameTaskStateType,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { useScatterplotFieldOptions } from '../../../../../components/scatterplot_matrix';
|
||||
|
||||
|
@ -18,12 +23,9 @@ import {
|
|||
defaultSearchQuery,
|
||||
getScatterplotMatrixLegendType,
|
||||
useResultsViewConfig,
|
||||
DataFrameAnalyticsConfig,
|
||||
getDestinationIndex,
|
||||
} from '../../../../common';
|
||||
import { ResultsSearchQuery, ANALYSIS_CONFIG_TYPE } from '../../../../common/analytics';
|
||||
|
||||
import { DataFrameTaskStateType } from '../../../analytics_management/components/analytics_list/common';
|
||||
import { ResultsSearchQuery } from '../../../../common/analytics';
|
||||
|
||||
import { ExpandableSectionAnalytics, ExpandableSectionSplom } from '../expandable_section';
|
||||
import { ExplorationResultsTable } from '../exploration_results_table';
|
||||
|
|
|
@ -8,15 +8,16 @@
|
|||
import React, { FC } from 'react';
|
||||
|
||||
import type { DataView } from '@kbn/data-views-plugin/public';
|
||||
import type {
|
||||
DataFrameAnalyticsConfig,
|
||||
DataFrameTaskStateType,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { getToastNotifications } from '../../../../../util/dependency_cache';
|
||||
import { useMlKibana } from '../../../../../contexts/kibana';
|
||||
|
||||
import { DataFrameAnalyticsConfig } from '../../../../common';
|
||||
import { ResultsSearchQuery } from '../../../../common/analytics';
|
||||
|
||||
import { DataFrameTaskStateType } from '../../../analytics_management/components/analytics_list/common';
|
||||
|
||||
import { ExpandableSectionResults } from '../expandable_section';
|
||||
|
||||
import { useExplorationResults } from './use_exploration_results';
|
||||
|
|
|
@ -13,11 +13,22 @@ import { CoreSetup } from '@kbn/core/public';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import type { DataView } from '@kbn/data-views-plugin/public';
|
||||
import { extractErrorMessage } from '@kbn/ml-error-utils';
|
||||
import {
|
||||
getPredictionFieldName,
|
||||
getDefaultPredictionFieldName,
|
||||
isClassificationAnalysis,
|
||||
isRegressionAnalysis,
|
||||
sortExplorationResultsFields,
|
||||
DEFAULT_RESULTS_FIELD,
|
||||
FEATURE_IMPORTANCE,
|
||||
ML__ID_COPY,
|
||||
TOP_CLASSES,
|
||||
type DataFrameAnalyticsConfig,
|
||||
type FeatureImportanceBaseline,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { MlApiServices } from '../../../../../services/ml_api_service';
|
||||
|
||||
import { DataLoader } from '../../../../../datavisualizer/index_based/data_loader';
|
||||
|
||||
import {
|
||||
getDataGridSchemasFromFieldTypes,
|
||||
getFieldType,
|
||||
|
@ -26,18 +37,9 @@ import {
|
|||
UseIndexDataReturnType,
|
||||
} from '../../../../../components/data_grid';
|
||||
import { SavedSearchQuery } from '../../../../../contexts/ml';
|
||||
import { getIndexData, getIndexFields, DataFrameAnalyticsConfig } from '../../../../common';
|
||||
import {
|
||||
getPredictionFieldName,
|
||||
getDefaultPredictionFieldName,
|
||||
isClassificationAnalysis,
|
||||
} from '../../../../../../../common/util/analytics_utils';
|
||||
import { FEATURE_IMPORTANCE, TOP_CLASSES } from '../../../../common/constants';
|
||||
import { DEFAULT_RESULTS_FIELD } from '../../../../../../../common/constants/data_frame_analytics';
|
||||
import { sortExplorationResultsFields, ML__ID_COPY } from '../../../../common/fields';
|
||||
import { isRegressionAnalysis } from '../../../../common/analytics';
|
||||
|
||||
import { getIndexData, getIndexFields } from '../../../../common';
|
||||
import { useTrainedModelsApiService } from '../../../../../services/ml_api_service/trained_models';
|
||||
import { FeatureImportanceBaseline } from '../../../../../../../common/types/feature_importance';
|
||||
import { useExplorationDataGrid } from './use_exploration_data_grid';
|
||||
|
||||
export const useExplorationResults = (
|
||||
|
|
|
@ -25,12 +25,12 @@ import { EuiIcon } from '@elastic/eui';
|
|||
import React, { useCallback, useMemo } from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { euiLightVars as euiVars } from '@kbn/ui-theme';
|
||||
import {
|
||||
type FeatureImportanceBaseline,
|
||||
isRegressionFeatureImportanceBaseline,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
import type { DecisionPathPlotData } from './use_classification_path_data';
|
||||
import { formatSingleValue } from '../../../../../formatters/format_value';
|
||||
import {
|
||||
FeatureImportanceBaseline,
|
||||
isRegressionFeatureImportanceBaseline,
|
||||
} from '../../../../../../../common/types/feature_importance';
|
||||
const { euiColorFullShade, euiColorMediumShade } = euiVars;
|
||||
const axisColor = euiColorMediumShade;
|
||||
|
||||
|
|
|
@ -9,19 +9,19 @@ import React, { FC, useMemo, useState } from 'react';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { EuiHealth, EuiSpacer, EuiSuperSelect, EuiTitle } from '@elastic/eui';
|
||||
import d3 from 'd3';
|
||||
import type {
|
||||
FeatureImportance,
|
||||
FeatureImportanceBaseline,
|
||||
TopClass,
|
||||
TopClasses,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
import {
|
||||
isDecisionPathData,
|
||||
useDecisionPathData,
|
||||
getStringBasedClassName,
|
||||
} from './use_classification_path_data';
|
||||
import type {
|
||||
FeatureImportance,
|
||||
FeatureImportanceBaseline,
|
||||
TopClasses,
|
||||
} from '../../../../../../../common/types/feature_importance';
|
||||
import { DecisionPathChart } from './decision_path_chart';
|
||||
import { MissingDecisionPathCallout } from './missing_decision_path_callout';
|
||||
import { TopClass } from '../../../../../../../common/types/feature_importance';
|
||||
|
||||
interface ClassificationDecisionPathProps {
|
||||
predictedValue: string | boolean;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import React, { FC } from 'react';
|
||||
import { EuiCodeBlock } from '@elastic/eui';
|
||||
import type { FeatureImportance } from '../../../../../../../common/types/feature_importance';
|
||||
import type { FeatureImportance } from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
interface DecisionPathJSONViewerProps {
|
||||
featureImportance: FeatureImportance[];
|
||||
|
|
|
@ -8,19 +8,19 @@
|
|||
import React, { FC, useState } from 'react';
|
||||
import { EuiLink, EuiTab, EuiTabs, EuiText } from '@elastic/eui';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { RegressionDecisionPath } from './decision_path_regression';
|
||||
import { DecisionPathJSONViewer } from './decision_path_json_viewer';
|
||||
import {
|
||||
FeatureImportance,
|
||||
FeatureImportanceBaseline,
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
type DataFrameAnalysisConfigType,
|
||||
type FeatureImportance,
|
||||
type FeatureImportanceBaseline,
|
||||
type TopClasses,
|
||||
isClassificationFeatureImportanceBaseline,
|
||||
isRegressionFeatureImportanceBaseline,
|
||||
TopClasses,
|
||||
} from '../../../../../../../common/types/feature_importance';
|
||||
import { ANALYSIS_CONFIG_TYPE } from '../../../../common';
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { RegressionDecisionPath } from './decision_path_regression';
|
||||
import { DecisionPathJSONViewer } from './decision_path_json_viewer';
|
||||
import { ClassificationDecisionPath } from './decision_path_classification';
|
||||
import { useMlKibana } from '../../../../../contexts/kibana';
|
||||
import type { DataFrameAnalysisConfigType } from '../../../../../../../common/types/data_frame_analytics';
|
||||
import { getStringBasedClassName } from './use_classification_path_data';
|
||||
|
||||
interface DecisionPathPopoverProps {
|
||||
|
|
|
@ -13,7 +13,7 @@ import type {
|
|||
FeatureImportance,
|
||||
FeatureImportanceBaseline,
|
||||
TopClasses,
|
||||
} from '../../../../../../../common/types/feature_importance';
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { useDecisionPathData, isDecisionPathData } from './use_classification_path_data';
|
||||
import { DecisionPathChart } from './decision_path_chart';
|
||||
import { MissingDecisionPathCallout } from './missing_decision_path_callout';
|
||||
|
|
|
@ -9,7 +9,7 @@ import {
|
|||
buildClassificationDecisionPathData,
|
||||
buildRegressionDecisionPathData,
|
||||
} from './use_classification_path_data';
|
||||
import type { FeatureImportance } from '../../../../../../../common/types/feature_importance';
|
||||
import type { FeatureImportance } from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { roundToDecimalPlace } from '@kbn/ml-number-utils';
|
||||
|
||||
describe('buildClassificationDecisionPathData()', () => {
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
import { useMemo } from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import {
|
||||
ClassificationFeatureImportanceBaseline,
|
||||
FeatureImportance,
|
||||
FeatureImportanceBaseline,
|
||||
type ClassificationFeatureImportanceBaseline,
|
||||
type FeatureImportance,
|
||||
type FeatureImportanceBaseline,
|
||||
type TopClasses,
|
||||
isClassificationFeatureImportanceBaseline,
|
||||
isRegressionFeatureImportanceBaseline,
|
||||
TopClasses,
|
||||
} from '../../../../../../../common/types/feature_importance';
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
import type { ExtendedFeatureImportance } from './decision_path_popover';
|
||||
|
||||
export type DecisionPathPlotData = Array<[string, number, number]>;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { DataFrameAnalyticsConfig } from '../../../../common';
|
||||
import type { DataFrameAnalyticsConfig } from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { getFeatureCount, getOutlierScoreFieldName } from './common';
|
||||
|
||||
|
|
|
@ -5,10 +5,13 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { DataGridItem } from '../../../../../components/data_grid';
|
||||
import {
|
||||
type DataFrameAnalyticsConfig,
|
||||
FEATURE_INFLUENCE,
|
||||
OUTLIER_SCORE,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { DataFrameAnalyticsConfig } from '../../../../common';
|
||||
import { FEATURE_INFLUENCE, OUTLIER_SCORE } from '../../../../common/constants';
|
||||
import { DataGridItem } from '../../../../../components/data_grid';
|
||||
|
||||
export const getOutlierScoreFieldName = (jobConfig: DataFrameAnalyticsConfig) =>
|
||||
`${jobConfig.dest.results_field}.${OUTLIER_SCORE}`;
|
||||
|
|
|
@ -10,6 +10,7 @@ import React, { useCallback, useState, FC } from 'react';
|
|||
import { EuiCallOut, EuiPanel, EuiSpacer, EuiText } from '@elastic/eui';
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { isOutlierAnalysis, FEATURE_INFLUENCE } from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import {
|
||||
useColorRange,
|
||||
|
@ -19,13 +20,7 @@ import {
|
|||
import { useScatterplotFieldOptions } from '../../../../../components/scatterplot_matrix';
|
||||
import { SavedSearchQuery } from '../../../../../contexts/ml';
|
||||
|
||||
import {
|
||||
defaultSearchQuery,
|
||||
isOutlierAnalysis,
|
||||
useResultsViewConfig,
|
||||
getDestinationIndex,
|
||||
} from '../../../../common';
|
||||
import { FEATURE_INFLUENCE } from '../../../../common/constants';
|
||||
import { defaultSearchQuery, useResultsViewConfig, getDestinationIndex } from '../../../../common';
|
||||
|
||||
import {
|
||||
ExpandableSectionSplom,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { DataFrameAnalyticsConfig } from '../../../../common';
|
||||
import type { DataFrameAnalyticsConfig } from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { getOutlierScoreFieldName } from './common';
|
||||
|
||||
|
|
|
@ -10,9 +10,16 @@ import { useEffect, useMemo } from 'react';
|
|||
import { EuiDataGridColumn } from '@elastic/eui';
|
||||
|
||||
import type { DataView } from '@kbn/data-views-plugin/public';
|
||||
import {
|
||||
sortExplorationResultsFields,
|
||||
ML__ID_COPY,
|
||||
ML__INCREMENTAL_ID,
|
||||
DEFAULT_RESULTS_FIELD,
|
||||
FEATURE_INFLUENCE,
|
||||
type DataFrameAnalyticsConfig,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { DataLoader } from '../../../../../datavisualizer/index_based/data_loader';
|
||||
|
||||
import {
|
||||
useColorRange,
|
||||
COLOR_RANGE,
|
||||
|
@ -28,14 +35,7 @@ import {
|
|||
import { SavedSearchQuery } from '../../../../../contexts/ml';
|
||||
import { getToastNotifications } from '../../../../../util/dependency_cache';
|
||||
|
||||
import { getIndexData, getIndexFields, DataFrameAnalyticsConfig } from '../../../../common';
|
||||
import { FEATURE_INFLUENCE } from '../../../../common/constants';
|
||||
import { DEFAULT_RESULTS_FIELD } from '../../../../../../../common/constants/data_frame_analytics';
|
||||
import {
|
||||
sortExplorationResultsFields,
|
||||
ML__ID_COPY,
|
||||
ML__INCREMENTAL_ID,
|
||||
} from '../../../../common/fields';
|
||||
import { getIndexData, getIndexFields } from '../../../../common';
|
||||
|
||||
import { getFeatureCount, getOutlierScoreFieldName } from './common';
|
||||
import { useExplorationDataGrid } from '../exploration_results_table/use_exploration_data_grid';
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
*/
|
||||
|
||||
import React, { FC, useEffect, useState } from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
|
||||
import {
|
||||
EuiButtonEmpty,
|
||||
EuiFlexGroup,
|
||||
|
@ -16,22 +15,24 @@ import {
|
|||
EuiText,
|
||||
EuiTitle,
|
||||
} from '@elastic/eui';
|
||||
import { useMlKibana } from '../../../../../contexts/kibana';
|
||||
import { SavedSearchQuery } from '../../../../../contexts/ml';
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import {
|
||||
getValuesFromResponse,
|
||||
getDependentVar,
|
||||
getPredictionFieldName,
|
||||
loadEvalData,
|
||||
loadDocsCount,
|
||||
Eval,
|
||||
DataFrameAnalyticsConfig,
|
||||
} from '../../../../common';
|
||||
import { DataFrameTaskStateType } from '../../../analytics_management/components/analytics_list/common';
|
||||
type DataFrameAnalyticsConfig,
|
||||
type DataFrameTaskStateType,
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { useMlKibana } from '../../../../../contexts/kibana';
|
||||
import { SavedSearchQuery } from '../../../../../contexts/ml';
|
||||
|
||||
import { getValuesFromResponse, loadEvalData, loadDocsCount, Eval } from '../../../../common';
|
||||
import {
|
||||
isResultsSearchBoolQuery,
|
||||
isRegressionEvaluateResponse,
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
REGRESSION_STATS,
|
||||
EMPTY_STAT,
|
||||
} from '../../../../common/analytics';
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
|
||||
import React, { FC, useCallback, useMemo } from 'react';
|
||||
|
||||
import { EuiButtonEmpty, EuiSpacer, EuiText, EuiCallOut } from '@elastic/eui';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import {
|
||||
Chart,
|
||||
Settings,
|
||||
|
@ -20,23 +20,26 @@ import {
|
|||
PartialTheme,
|
||||
BarSeriesProps,
|
||||
} from '@elastic/charts';
|
||||
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { euiLightVars as euiVars } from '@kbn/ui-theme';
|
||||
import {
|
||||
TotalFeatureImportance,
|
||||
getAnalysisType,
|
||||
isClassificationAnalysis,
|
||||
isClassificationTotalFeatureImportance,
|
||||
isRegressionAnalysis,
|
||||
isRegressionTotalFeatureImportance,
|
||||
RegressionTotalFeatureImportance,
|
||||
ClassificationTotalFeatureImportance,
|
||||
FeatureImportanceClassName,
|
||||
} from '../../../../../../../common/types/feature_importance';
|
||||
type DataFrameAnalyticsConfig,
|
||||
type TotalFeatureImportance,
|
||||
type RegressionTotalFeatureImportance,
|
||||
type ClassificationTotalFeatureImportance,
|
||||
type FeatureImportanceClassName,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { useMlKibana } from '../../../../../contexts/kibana';
|
||||
|
||||
import { ExpandableSection } from '../expandable_section';
|
||||
import { DataFrameAnalyticsConfig } from '../../../../../../../common/types/data_frame_analytics';
|
||||
import { getAnalysisType } from '../../../../common';
|
||||
import { isClassificationAnalysis, isRegressionAnalysis } from '../../../../common/analytics';
|
||||
|
||||
const { euiColorMediumShade } = euiVars;
|
||||
const axisColor = euiColorMediumShade;
|
||||
|
|
|
@ -10,12 +10,14 @@ import { EuiEmptyPrompt } from '@elastic/eui';
|
|||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
|
||||
import { useUrlState } from '@kbn/ml-url-state';
|
||||
import {
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
type DataFrameAnalysisConfigType,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { OutlierExploration } from './components/outlier_exploration';
|
||||
import { RegressionExploration } from './components/regression_exploration';
|
||||
import { ClassificationExploration } from './components/classification_exploration';
|
||||
|
||||
import { ANALYSIS_CONFIG_TYPE } from '../../../../../common/constants/data_frame_analytics';
|
||||
import { DataFrameAnalysisConfigType } from '../../../../../common/types/data_frame_analytics';
|
||||
import { HelpMenu } from '../../../components/help_menu';
|
||||
import { useMlKibana, useMlApiContext } from '../../../contexts/kibana';
|
||||
import { MlPageHeader } from '../../../components/page_header';
|
||||
|
|
|
@ -12,10 +12,14 @@ import { i18n } from '@kbn/i18n';
|
|||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { toMountPoint, wrapWithTheme } from '@kbn/kibana-react-plugin/public';
|
||||
import { extractErrorMessage } from '@kbn/ml-error-utils';
|
||||
import {
|
||||
isClassificationAnalysis,
|
||||
isOutlierAnalysis,
|
||||
isRegressionAnalysis,
|
||||
DEFAULT_RESULTS_FIELD,
|
||||
type DataFrameAnalyticsConfig,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { DeepReadonly } from '../../../../../../../common/types/common';
|
||||
import { DataFrameAnalyticsConfig, isOutlierAnalysis } from '../../../../common';
|
||||
import { isClassificationAnalysis, isRegressionAnalysis } from '../../../../common/analytics';
|
||||
import { DEFAULT_RESULTS_FIELD } from '../../../../../../../common/constants/data_frame_analytics';
|
||||
import { useMlKibana, useNavigateToPath } from '../../../../../contexts/kibana';
|
||||
import { DEFAULT_NUM_TOP_FEATURE_IMPORTANCE_VALUES } from '../../hooks/use_create_analytics_form';
|
||||
import { State } from '../../hooks/use_create_analytics_form/state';
|
||||
|
|
|
@ -29,6 +29,11 @@ import {
|
|||
} from '@elastic/eui';
|
||||
|
||||
import type { MlUrlConfig } from '@kbn/ml-anomaly-utils';
|
||||
import {
|
||||
DATA_FRAME_TASK_STATE,
|
||||
type DataFrameAnalyticsConfig,
|
||||
type UpdateDataFrameAnalyticsConfig,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { useMlKibana, useMlApiContext } from '../../../../../contexts/kibana';
|
||||
import { ml } from '../../../../../services/ml_api_service';
|
||||
|
@ -37,12 +42,7 @@ import {
|
|||
memoryInputValidator,
|
||||
MemoryInputValidatorResult,
|
||||
} from '../../../../../../../common/util/validators';
|
||||
import { DATA_FRAME_TASK_STATE } from '../analytics_list/common';
|
||||
import { useRefreshAnalyticsList } from '../../../../common/analytics';
|
||||
import {
|
||||
UpdateDataFrameAnalyticsConfig,
|
||||
type DataFrameAnalyticsConfig,
|
||||
} from '../../../../../../../common/types/data_frame_analytics';
|
||||
|
||||
import { EditAction } from './use_edit_action';
|
||||
import { CustomUrlsWrapper, isValidCustomUrls } from '../../../../../components/custom_urls';
|
||||
|
|
|
@ -13,7 +13,7 @@ import {
|
|||
isRegressionAnalysis,
|
||||
isOutlierAnalysis,
|
||||
isClassificationAnalysis,
|
||||
} from '../../../../common/analytics';
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { DataFrameAnalyticsListRow } from '../analytics_list/common';
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
isRegressionAnalysis,
|
||||
isOutlierAnalysis,
|
||||
isClassificationAnalysis,
|
||||
} from '../../../../common/analytics';
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
import {
|
||||
DataFrameAnalyticsListRow,
|
||||
isDataFrameAnalyticsStopped,
|
||||
|
|
|
@ -7,14 +7,17 @@
|
|||
|
||||
import React, { useCallback, useMemo } from 'react';
|
||||
|
||||
import { getAnalysisType } from '../../../../common/analytics';
|
||||
import {
|
||||
getAnalysisType,
|
||||
type DataFrameAnalysisConfigType,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { useMlLocator, useNavigateToPath } from '../../../../../contexts/kibana';
|
||||
|
||||
import { DataFrameAnalyticsListAction, DataFrameAnalyticsListRow } from '../analytics_list/common';
|
||||
|
||||
import { getViewLinkStatus } from './get_view_link_status';
|
||||
import { viewActionButtonText, ViewButton } from './view_button';
|
||||
import { DataFrameAnalysisConfigType } from '../../../../../../../common/types/data_frame_analytics';
|
||||
import { ML_PAGES } from '../../../../../../../common/constants/locator';
|
||||
|
||||
export type ViewAction = ReturnType<typeof useViewAction>;
|
||||
|
|
|
@ -16,8 +16,12 @@ import {
|
|||
EuiSearchBarProps,
|
||||
EuiSpacer,
|
||||
} from '@elastic/eui';
|
||||
import { ANALYSIS_CONFIG_TYPE } from '../../../../../../../common/constants/data_frame_analytics';
|
||||
import { DataFrameAnalyticsId, useRefreshAnalyticsList } from '../../../../common';
|
||||
import {
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
DATA_FRAME_TASK_STATE,
|
||||
type DataFrameAnalyticsId,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { useRefreshAnalyticsList } from '../../../../common';
|
||||
import { checkPermission } from '../../../../../capabilities/check_capabilities';
|
||||
import { useNavigateToPath } from '../../../../../contexts/kibana';
|
||||
import { ML_PAGES } from '../../../../../../../common/constants/locator';
|
||||
|
@ -26,7 +30,6 @@ import {
|
|||
DataFrameAnalyticsListColumn,
|
||||
DataFrameAnalyticsListRow,
|
||||
ItemIdToExpandedRowMap,
|
||||
DATA_FRAME_TASK_STATE,
|
||||
} from './common';
|
||||
import { getAnalyticsFactory } from '../../services/analytics_service';
|
||||
import { getTaskStateBadge, getJobTypeBadge, useColumns } from './use_columns';
|
||||
|
|
|
@ -7,14 +7,17 @@
|
|||
|
||||
import StatsMock from './__mocks__/analytics_stats.json';
|
||||
|
||||
import {
|
||||
type DataFrameAnalyticsStats,
|
||||
DATA_FRAME_TASK_STATE,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import {
|
||||
getDataFrameAnalyticsProgress,
|
||||
getDataFrameAnalyticsProgressPhase,
|
||||
isCompletedAnalyticsJob,
|
||||
isDataFrameAnalyticsRunning,
|
||||
isDataFrameAnalyticsStats,
|
||||
DataFrameAnalyticsStats,
|
||||
DATA_FRAME_TASK_STATE,
|
||||
} from './common';
|
||||
|
||||
const completedJob = StatsMock.data_frame_analytics[0] as DataFrameAnalyticsStats;
|
||||
|
|
|
@ -7,18 +7,14 @@
|
|||
|
||||
import { EuiTableActionsColumnType, Query, Ast } from '@elastic/eui';
|
||||
|
||||
import { DATA_FRAME_TASK_STATE } from '../../../../../../../common/constants/data_frame_analytics';
|
||||
import { DataFrameTaskStateType } from '../../../../../../../common/types/data_frame_analytics';
|
||||
export { DATA_FRAME_TASK_STATE };
|
||||
export type { DataFrameTaskStateType };
|
||||
|
||||
import { DataFrameAnalyticsId, DataFrameAnalyticsConfig } from '../../../../common';
|
||||
import {
|
||||
DataFrameAnalysisConfigType,
|
||||
DataFrameAnalyticsStats,
|
||||
} from '../../../../../../../common/types/data_frame_analytics';
|
||||
|
||||
export type { DataFrameAnalyticsStats } from '../../../../../../../common/types/data_frame_analytics';
|
||||
DATA_FRAME_TASK_STATE,
|
||||
type DataFrameAnalyticsId,
|
||||
type DataFrameAnalyticsConfig,
|
||||
type DataFrameAnalysisConfigType,
|
||||
type DataFrameAnalyticsStats,
|
||||
type DataFrameTaskStateType,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
export enum DATA_FRAME_MODE {
|
||||
BATCH = 'batch',
|
||||
|
|
|
@ -11,6 +11,7 @@ import moment from 'moment-timezone';
|
|||
import { EuiProgress, EuiTabbedContent } from '@elastic/eui';
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { getAnalysisType } from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { formatHumanReadableDateTimeSeconds } from '../../../../../../../common/util/date_utils';
|
||||
|
||||
|
@ -19,7 +20,6 @@ import { ExpandedRowDetailsPane, SectionConfig } from './expanded_row_details_pa
|
|||
import { ExpandedRowJsonPane } from './expanded_row_json_pane';
|
||||
|
||||
import { getDataFrameAnalyticsProgressPhase } from './common';
|
||||
import { getAnalysisType } from '../../../../common/analytics';
|
||||
import { ExpandedRowMessagesPane } from './expanded_row_messages_pane';
|
||||
|
||||
function getItemDescription(value: any) {
|
||||
|
|
|
@ -20,7 +20,11 @@ import {
|
|||
EuiLink,
|
||||
RIGHT_ALIGNMENT,
|
||||
} from '@elastic/eui';
|
||||
import { getAnalysisType, DataFrameAnalyticsId } from '../../../../common';
|
||||
import {
|
||||
getAnalysisType,
|
||||
type DataFrameAnalyticsId,
|
||||
type DataFrameAnalyticsStats,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
import {
|
||||
getDataFrameAnalyticsProgressPhase,
|
||||
isDataFrameAnalyticsFailed,
|
||||
|
@ -28,7 +32,6 @@ import {
|
|||
isDataFrameAnalyticsStopped,
|
||||
DataFrameAnalyticsListColumn,
|
||||
DataFrameAnalyticsListRow,
|
||||
DataFrameAnalyticsStats,
|
||||
} from './common';
|
||||
import { useActions } from './use_actions';
|
||||
import { useMlLink } from '../../../../../contexts/kibana';
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { DataFrameAnalyticsConfig } from '@kbn/ml-data-frame-analytics-utils';
|
||||
import { DeepReadonly } from '../../../../../../../common/types/common';
|
||||
import { DataFrameAnalyticsConfig } from '../../../../common';
|
||||
import { FormMessage, State, SourceIndexMap } from './state';
|
||||
|
||||
export enum ACTION {
|
||||
|
|
|
@ -7,7 +7,10 @@
|
|||
|
||||
import { merge } from 'lodash';
|
||||
|
||||
import { ANALYSIS_CONFIG_TYPE, DataFrameAnalyticsConfig } from '../../../../common';
|
||||
import {
|
||||
ANALYSIS_CONFIG_TYPE,
|
||||
type DataFrameAnalyticsConfig,
|
||||
} from '@kbn/ml-data-frame-analytics-utils';
|
||||
|
||||
import { ACTION } from './actions';
|
||||
import {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue