-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Creating category validation package (#161261)
Moves the server and client side code which performs analysis on data to see whether it is suitable for categorization. This is currently only used by the categorization job wizard to display this callout:  However this analysis will be useful for the Log Pattern Analysis feature and so moving the code to a package allows easier sharing between ML and AIOPs plugins. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
85c85e9
commit 219426d
Showing
36 changed files
with
354 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# @kbn/ml-category-validator | ||
|
||
Provides functions for validating data to see whether it is suitable for categorization |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
x-pack/packages/ml/category_validator/common/types/categories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* 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 * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; | ||
|
||
import { | ||
CATEGORY_EXAMPLES_VALIDATION_STATUS, | ||
VALIDATION_RESULT, | ||
} from '../constants/categorization'; | ||
|
||
/** | ||
* Token | ||
*/ | ||
export interface Token { | ||
/** | ||
* The token string. | ||
*/ | ||
token: string; | ||
/** | ||
* The starting offset of the token. | ||
*/ | ||
start_offset: number; | ||
/** | ||
* The ending offset of the token. | ||
*/ | ||
end_offset: number; | ||
/** | ||
* The type of the token. | ||
*/ | ||
type: string; | ||
/** | ||
* The position of the token. | ||
*/ | ||
position: number; | ||
} | ||
|
||
/** | ||
* Categorization analyzer with additional properties. | ||
*/ | ||
export type CategorizationAnalyzer = estypes.MlCategorizationAnalyzerDefinition & { | ||
/** | ||
* The analyzer used for categorization. | ||
*/ | ||
analyzer?: string; | ||
}; | ||
|
||
/** | ||
* Field example for a category. | ||
*/ | ||
export interface CategoryFieldExample { | ||
/** | ||
* The text of the field example. | ||
*/ | ||
text: string; | ||
/** | ||
* The tokens extracted from the field example. | ||
*/ | ||
tokens: Token[]; | ||
} | ||
|
||
/** | ||
* Result of a field example check. | ||
*/ | ||
export interface FieldExampleCheck { | ||
/** | ||
* The ID of the validation result. | ||
*/ | ||
id: VALIDATION_RESULT; | ||
/** | ||
* The validation status of the field example. | ||
*/ | ||
valid: CATEGORY_EXAMPLES_VALIDATION_STATUS; | ||
/** | ||
* The message associated with the validation result. | ||
*/ | ||
message: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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. | ||
*/ | ||
|
||
export { categorizationExamplesProvider } from './src/examples'; | ||
export type { | ||
CategorizationAnalyzer, | ||
CategoryFieldExample, | ||
FieldExampleCheck, | ||
Token, | ||
} from './common/types/categories'; | ||
export { | ||
CATEGORY_EXAMPLES_ERROR_LIMIT, | ||
CATEGORY_EXAMPLES_SAMPLE_SIZE, | ||
CATEGORY_EXAMPLES_VALIDATION_STATUS, | ||
CATEGORY_EXAMPLES_WARNING_LIMIT, | ||
MEDIAN_LINE_LENGTH_LIMIT, | ||
NULL_COUNT_PERCENT_LIMIT, | ||
VALID_TOKEN_COUNT, | ||
VALIDATION_CHECK_DESCRIPTION, | ||
VALIDATION_RESULT, | ||
} from './common/constants/categorization'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
module.exports = { | ||
preset: '@kbn/test/jest_node', | ||
rootDir: '../../../..', | ||
roots: ['<rootDir>/x-pack/packages/ml/category_validator'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"type": "shared-common", | ||
"id": "@kbn/ml-category-validator", | ||
"owner": "@elastic/ml-ui" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "@kbn/ml-category-validator", | ||
"private": true, | ||
"version": "1.0.0", | ||
"license": "Elastic License 2.0" | ||
} |
Oops, something went wrong.