Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Clone analytics job #59791

Merged
merged 30 commits into from
Mar 15, 2020
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ef9170c
[ML] clone analytics job
darnautov Mar 10, 2020
86be82e
[ML] flyout clone header
darnautov Mar 10, 2020
4923423
[ML] improve clone action context menu item
darnautov Mar 10, 2020
307b32b
[ML] support advanced job cloning
darnautov Mar 11, 2020
d1356bc
[ML] extractCloningConfig
darnautov Mar 11, 2020
ba2cabd
[ML] fix isAdvancedSetting condition, add test
darnautov Mar 11, 2020
9fc4fdb
[ML] clone job header
darnautov Mar 12, 2020
a667557
Merge remote-tracking branch 'upstream/master' into ML-clone-analytic…
darnautov Mar 12, 2020
84deee6
[ML] job description placeholder
darnautov Mar 12, 2020
6722186
[ML] setEstimatedModelMemoryLimit on source index change
darnautov Mar 12, 2020
e476f28
[ML] Fix types.
walterra Mar 12, 2020
ff14676
[ML] useUpdateEffect in create_analytics_form.tsx
darnautov Mar 12, 2020
254daf4
[ML] setJobClone action
darnautov Mar 12, 2020
09425ab
Merge pull request #1 from walterra/ML-clone-analytics-jobs
darnautov Mar 12, 2020
2c180c1
[ML] remove CreateAnalyticsFlyoutWrapper instance from the create_ana…
darnautov Mar 12, 2020
29ca176
Merge remote-tracking branch 'origin/ML-clone-analytics-jobs' into ML…
darnautov Mar 12, 2020
9f05bb8
[ML] fix types
darnautov Mar 12, 2020
458ec21
[ML] hack to align Clone button with the other actions
darnautov Mar 12, 2020
d3992a0
[ML] unknown props lead to advanced editor
darnautov Mar 12, 2020
44cc41b
[ML] rename maximum_number_trees ot max_trees
darnautov Mar 13, 2020
6b7d0bf
[ML] fix forceInput
darnautov Mar 13, 2020
5939ddc
[ML] populate excludesOptions on the first update, skip setting mml o…
darnautov Mar 13, 2020
cac0b36
[ML] init functional test for cloning analytics jobs
darnautov Mar 13, 2020
fde5626
Merge remote-tracking branch 'upstream/master' into ML-clone-analytic…
darnautov Mar 14, 2020
a9b742a
[ML] functional tests
darnautov Mar 14, 2020
fee64e2
[ML] fix functional tests imports
darnautov Mar 15, 2020
8c2968e
[ML] fix indices names for functional tests
darnautov Mar 15, 2020
bfd985b
[ML] functional tests for outlier detection and regression jobs cloning
darnautov Mar 15, 2020
24d4b57
[ML] delete james tag
darnautov Mar 15, 2020
526f88c
[ML] fix tests arrangement
darnautov Mar 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,37 @@ export type IndexName = string;
export type IndexPattern = string;
export type DataFrameAnalyticsId = string;

export enum ANALYSIS_CONFIG_TYPE {
OUTLIER_DETECTION = 'outlier_detection',
REGRESSION = 'regression',
CLASSIFICATION = 'classification',
UNKNOWN = 'unknown',
}

interface OutlierAnalysis {
[key: string]: {};
outlier_detection: {};
}

interface Regression {
dependent_variable: string;
training_percent?: number;
prediction_field_name?: string;
}
interface RegressionAnalysis {
regression: {
dependent_variable: string;
training_percent?: number;
prediction_field_name?: string;
};
[key: string]: Regression;
regression: Regression;
}

interface Classification {
dependent_variable: string;
training_percent?: number;
num_top_classes?: string;
prediction_field_name?: string;
}
interface ClassificationAnalysis {
classification: {
dependent_variable: string;
training_percent?: number;
num_top_classes?: string;
prediction_field_name?: string;
};
[key: string]: Classification;
classification: Classification;
}

export interface LoadExploreDataArg {
Expand Down Expand Up @@ -136,13 +148,6 @@ type AnalysisConfig =
| ClassificationAnalysis
| GenericAnalysis;

export enum ANALYSIS_CONFIG_TYPE {
OUTLIER_DETECTION = 'outlier_detection',
REGRESSION = 'regression',
CLASSIFICATION = 'classification',
UNKNOWN = 'unknown',
}

export const getAnalysisType = (analysis: AnalysisConfig) => {
const keys = Object.keys(analysis);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { isAdvancedConfig } from './action_clone';

describe('Analytics job clone action', () => {
describe('isAdvancedConfig', () => {
test('should detect a classification job created with the form', () => {
const formCreatedClassificationJob = {
id: 'bank_classification_1',
description: "Classification job with 'bank-marketing' dataset",
source: {
index: ['bank-marketing'],
query: {
match_all: {},
},
},
dest: {
index: 'dest_bank_1',
results_field: 'ml',
},
analysis: {
classification: {
dependent_variable: 'y',
num_top_classes: 2,
prediction_field_name: 'y_prediction',
training_percent: 2,
randomize_seed: 6233212276062807000,
},
},
analyzed_fields: {
includes: [],
excludes: [],
},
model_memory_limit: '350mb',
create_time: 1583417086689,
version: '8.0.0',
allow_lazy_start: false,
};

expect(isAdvancedConfig(formCreatedClassificationJob)).toBe(false);
});

test('should detect a outlier_detection job created with the form', () => {
const formCreatedOutlierDetectionJob = {
id: 'glass_outlier_detection_1',
description: "Outlier detection job with 'glass' dataset",
source: {
index: ['glass_withoutdupl_norm'],
query: {
match_all: {},
},
},
dest: {
index: 'dest_glass_1',
results_field: 'ml',
},
analysis: {
outlier_detection: {
compute_feature_influence: true,
outlier_fraction: 0.05,
standardization_enabled: true,
},
},
analyzed_fields: {
includes: [],
excludes: ['id', 'outlier'],
},
model_memory_limit: '1mb',
create_time: 1583417347446,
version: '8.0.0',
allow_lazy_start: false,
};
expect(isAdvancedConfig(formCreatedOutlierDetectionJob)).toBe(false);
});

test('should detect a regression job created with the form', () => {
const formCreatedRegressionJob = {
id: 'grid_regression_1',
description: "Regression job with 'electrical-grid-stability' dataset",
source: {
index: ['electrical-grid-stability'],
query: {
match_all: {},
},
},
dest: {
index: 'dest_grid_1',
results_field: 'ml',
},
analysis: {
regression: {
dependent_variable: 'stab',
prediction_field_name: 'stab_prediction',
training_percent: 20,
randomize_seed: -2228827740028660200,
},
},
analyzed_fields: {
includes: [],
excludes: [],
},
model_memory_limit: '150mb',
create_time: 1583417178919,
version: '8.0.0',
allow_lazy_start: false,
};

expect(isAdvancedConfig(formCreatedRegressionJob)).toBe(false);
});

test('should detect advanced classification job', () => {
const advancedClassificationJob = {
id: 'bank_classification_1',
description: "Classification job with 'bank-marketing' dataset",
source: {
index: ['bank-marketing'],
query: {
match_all: {},
},
},
dest: {
index: 'dest_bank_1',
results_field: 'CUSTOM_RESULT_FIELD',
},
analysis: {
classification: {
dependent_variable: 'y',
num_top_classes: 2,
prediction_field_name: 'y_prediction',
training_percent: 2,
randomize_seed: 6233212276062807000,
},
},
analyzed_fields: {
includes: [],
excludes: [],
},
model_memory_limit: '350mb',
create_time: 1583417086689,
version: '8.0.0',
allow_lazy_start: false,
};

expect(isAdvancedConfig(advancedClassificationJob)).toBe(true);
});

test('should detect advanced outlier_detection job', () => {
const advancedOutlierDetectionJob = {
id: 'glass_outlier_detection_1',
description: "Outlier detection job with 'glass' dataset",
source: {
index: ['glass_withoutdupl_norm'],
query: {
// TODO check default for `match`
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to leave in this comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed one of the outlier detection jobs (created by env bootstrap) has query match instead of match_all. As I saw in all the other cases match_all is a default, so probably it's just a typo in a bootstrap job.

match_all: {},
},
},
dest: {
index: 'dest_glass_1',
results_field: 'ml',
},
analysis: {
outlier_detection: {
compute_feature_influence: false,
outlier_fraction: 0.05,
standardization_enabled: true,
},
},
analyzed_fields: {
includes: [],
excludes: ['id', 'outlier'],
},
model_memory_limit: '1mb',
create_time: 1583417347446,
version: '8.0.0',
allow_lazy_start: false,
};
expect(isAdvancedConfig(advancedOutlierDetectionJob)).toBe(true);
});

test('should detect a custom query', () => {
const advancedRegressionJob = {
id: 'grid_regression_1',
description: "Regression job with 'electrical-grid-stability' dataset",
source: {
index: ['electrical-grid-stability'],
query: {
match: {
custom_field: 'custom_match',
},
},
},
dest: {
index: 'dest_grid_1',
results_field: 'ml',
},
analysis: {
regression: {
dependent_variable: 'stab',
prediction_field_name: 'stab_prediction',
training_percent: 20,
randomize_seed: -2228827740028660200,
},
},
analyzed_fields: {
includes: [],
excludes: [],
},
model_memory_limit: '150mb',
create_time: 1583417178919,
version: '8.0.0',
allow_lazy_start: false,
};

expect(isAdvancedConfig(advancedRegressionJob)).toBe(true);
});

test('should detect custom analysis settings', () => {
const config = {
description: "Classification clone with 'bank-marketing' dataset",
source: {
index: 'bank-marketing',
},
dest: {
index: 'bank_classification4',
},
analyzed_fields: {
excludes: [],
},
analysis: {
classification: {
dependent_variable: 'y',
training_percent: 71,
maximum_number_trees: 1500,
darnautov marked this conversation as resolved.
Show resolved Hide resolved
},
},
model_memory_limit: '400mb',
};

expect(isAdvancedConfig(config)).toBe(true);
});
});
});
Loading