Skip to content

Commit fe224da

Browse files
pquentinlcawlszabosteve
authored
Merge doc-examples branch (#2759)
* Add machine learning API examples (#2452) * Add examples for transform APIs (#2505) * [DOCS] Adds ML API examples (DELETE ops) (#2518) * [DOCS] Adds anomaly detection API examples. * [DOCS] Adds more ML examples. * [DOCS] Further edits. * [DOCS] Fixes style. * [DOCS] Adds example requests and responses to ML APIs (C-E) (#2521) Co-authored-by: Quentin Pradet <[email protected]> --------- Co-authored-by: Lisa Cawley <[email protected]> Co-authored-by: István Zoltán Szabó <[email protected]>
1 parent f9cb81c commit fe224da

File tree

46 files changed

+1091
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1091
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"summary": "A successful response when clearing the inference cache.",
3+
"value": {
4+
"cleared": true
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"summary": "A successful response when closing anomaly detection jobs.",
3+
"value": {
4+
"closed": true
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"summary": "A successful response when deleting a calendar.",
3+
"value": {
4+
"acknowledged": true
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"summary": "A successful response when deleting a calendar event.",
3+
"value": {
4+
"acknowledged": true
5+
}
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"summary": "A successful response when deleting an anomaly detection job from a calendar.",
3+
"value": {
4+
"calendar_id": "planned-outages",
5+
"job_ids": []
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"summary": "A successful response when deleting a data frame analytics job.",
3+
"value": {
4+
"acknowledged": true
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"summary": "A successful response when deleting a datafeed.",
3+
"value": {
4+
"acknowledged": true
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"summary": "A successful response when deleting expired and unused anomaly detection data.",
3+
"value": {
4+
"deleted": true
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"summary": "A successful response when deleting a filter.",
3+
"value": {
4+
"acknowledged": true
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"summary": "A successful response when deleting a forecast from an anomaly detection job.",
3+
"value": {
4+
"acknowledged": true
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"summary": "A successful response when deleting an anomaly detection job.",
3+
"value": {
4+
"acknowledged": true
5+
}
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"summary": "A successful response when deleting an anomaly detection job asynchronously.",
3+
"description": "When the `wait_for_completion` query parameter is set to `false`, the response contains an identifier for the job deletion task.",
4+
"value": {
5+
"task": "oTUltX4IQMOUUVeiohTt8A:39"
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"summary": "A successful response when deleting an existing model snapshot.",
3+
"value": {
4+
"acknowledged": true
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"summary": "A successful response when deleting an existing trained inference model.",
3+
"value": {
4+
"acknowledged": true
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"summary": "A successful response when deleting a trained model alias.",
3+
"value": {
4+
"acknowledged": true
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"summary": "A successful response when estimating sufficent memory for a model.",
3+
"value": {
4+
"model_memory_estimate": "21mb"
5+
}
6+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"summary": "A request of estimating model memory limit based on the analysis configuration details provided in the body.",
3+
"value": {
4+
"analysis_config": {
5+
"bucket_span": "5m",
6+
"detectors": [
7+
{
8+
"function": "sum",
9+
"field_name": "bytes",
10+
"by_field_name": "status",
11+
"partition_field_name": "app"
12+
}
13+
],
14+
"influencers": ["source_ip", "dest_ip"]
15+
},
16+
"overall_cardinality": {
17+
"status": 10,
18+
"app": 50
19+
},
20+
"max_bucket_cardinality": {
21+
"source_ip": 300,
22+
"dest_ip": 30
23+
}
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"summary": "A succesful response for evaluating a classification analysis job for an annotated index.",
3+
"description": "The `actual_class` contains the name of the class the analysis tried to predict. The `actual_class_doc_count` is the number of documents in the index belonging to the `actual_class`. The `predicted_classes` object contains the list of the predicted classes and the number of predictions associated with the class.",
4+
"value": {
5+
"classification": {
6+
"multiclass_confusion_matrix": {
7+
"confusion_matrix": [
8+
{
9+
"actual_class": "cat",
10+
"actual_class_doc_count": 12,
11+
"predicted_classes": [
12+
{
13+
"predicted_class": "cat",
14+
"count": 12
15+
},
16+
{
17+
"predicted_class": "dog",
18+
"count": 0
19+
}
20+
],
21+
"other_predicted_class_doc_count": 0
22+
},
23+
{
24+
"actual_class": "dog",
25+
"actual_class_doc_count": 11,
26+
"predicted_classes": [
27+
{
28+
"predicted_class": "dog",
29+
"count": 7
30+
},
31+
{
32+
"predicted_class": "cat",
33+
"count": 4
34+
}
35+
],
36+
"other_predicted_class_doc_count": 0
37+
}
38+
],
39+
"other_actual_class_count": 0
40+
}
41+
}
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"summary": "A succesful response for evaluating a classification analysis job with the AUC ROC metrics for an annotated index.",
3+
"value": {
4+
"classification": {
5+
"auc_roc": {
6+
"value": 0.8941788639536681
7+
}
8+
}
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"summary": "A successful response when evaluating an outlier detection job.",
3+
"value": {
4+
"outlier_detection": {
5+
"auc_roc": {
6+
"value": 0.92584757746414444
7+
},
8+
"confusion_matrix": {
9+
"0.25": {
10+
"tp": 5,
11+
"fp": 9,
12+
"tn": 204,
13+
"fn": 5
14+
},
15+
"0.5": {
16+
"tp": 1,
17+
"fp": 5,
18+
"tn": 208,
19+
"fn": 9
20+
},
21+
"0.75": {
22+
"tp": 0,
23+
"fp": 4,
24+
"tn": 209,
25+
"fn": 10
26+
}
27+
},
28+
"precision": {
29+
"0.25": 0.35714285714285715,
30+
"0.5": 0.16666666666666666,
31+
"0.75": 0
32+
},
33+
"recall": {
34+
"0.25": 0.5,
35+
"0.5": 0.1,
36+
"0.75": 0
37+
}
38+
}
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"summary": "A request for evaluating a classification job for an annotated index.",
3+
"description": "The `actual_field` contains the ground truth for classification. The `predicted_field` contains the predicted value calculated by the classification analysis.",
4+
"value": {
5+
"index": "animal_classification",
6+
"evaluation": {
7+
"classification": {
8+
"actual_field": "animal_class",
9+
"predicted_field": "ml.animal_class_prediction",
10+
"metrics": {
11+
"multiclass_confusion_matrix": {}
12+
}
13+
}
14+
}
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"summary": "A request for evaluating a classification job with AUC ROC metrics for an annotated index.",
3+
"description": "The `class_name` specifies the class name that is treated as positive during the evaluation, all the other classes are treated as negative.",
4+
"value": {
5+
"index": "animal_classification",
6+
"evaluation": {
7+
"classification": {
8+
"actual_field": "animal_class",
9+
"metrics": {
10+
"auc_roc": {
11+
"class_name": "dog"
12+
}
13+
}
14+
}
15+
}
16+
}
17+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"summary": "A request for evaluating an outlier detection job for an annotated index.",
3+
"value": {
4+
"index": "my_analytics_dest_index",
5+
"evaluation": {
6+
"outlier_detection": {
7+
"actual_field": "is_outlier",
8+
"predicted_probability_field": "ml.outlier_score"
9+
}
10+
}
11+
}
12+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"summary": "A request for evaluating the testing error of a regression job for an annotated index.",
3+
"description": "The term query in the body limits evaluation to be performed on the test split only. The `actual_field` contains the ground truth for house prices. The `predicted_field` contains the house price calculated by the regression analysis.",
4+
"value": {
5+
"index": "house_price_predictions",
6+
"query": {
7+
"bool": {
8+
"filter": [
9+
{
10+
"term": {
11+
"ml.is_training": false
12+
}
13+
}
14+
]
15+
}
16+
},
17+
"evaluation": {
18+
"regression": {
19+
"actual_field": "price",
20+
"predicted_field": "ml.price_prediction",
21+
"metrics": {
22+
"r_squared": {},
23+
"mse": {},
24+
"msle": {
25+
"offset": 10
26+
},
27+
"huber": {
28+
"delta": 1.5
29+
}
30+
}
31+
}
32+
}
33+
}
34+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"summary": "A request for evaluating the training error of a regression job for an annotated index.",
3+
"description": "The term query in the body limits evaluation to be performed on the training split only. The `actual_field` contains the ground truth for house prices. The `predicted_field` contains the house price calculated by the regression analysis.",
4+
"value": {
5+
"index": "house_price_predictions",
6+
"query": {
7+
"term": {
8+
"ml.is_training": {
9+
"value": true
10+
}
11+
}
12+
},
13+
"evaluation": {
14+
"regression": {
15+
"actual_field": "price",
16+
"predicted_field": "ml.price_prediction",
17+
"metrics": {
18+
"r_squared": {},
19+
"mse": {},
20+
"msle": {},
21+
"huber": {}
22+
}
23+
}
24+
}
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"summary": "A succesful response for explaining a data frame analytics job configuration.",
3+
"value": {
4+
"field_selection": [
5+
{
6+
"field": "number_of_bedrooms",
7+
"mappings_types": ["integer"],
8+
"is_included": true,
9+
"is_required": false,
10+
"feature_type": "numerical"
11+
},
12+
{
13+
"field": "postcode",
14+
"mappings_types": ["text"],
15+
"is_included": false,
16+
"is_required": false,
17+
"reason": "[postcode.keyword] is preferred because it is aggregatable"
18+
},
19+
{
20+
"field": "postcode.keyword",
21+
"mappings_types": ["keyword"],
22+
"is_included": true,
23+
"is_required": false,
24+
"feature_type": "categorical"
25+
},
26+
{
27+
"field": "price",
28+
"mappings_types": ["float"],
29+
"is_included": true,
30+
"is_required": true,
31+
"feature_type": "numerical"
32+
}
33+
],
34+
"memory_estimation": {
35+
"expected_memory_without_disk": "128MB",
36+
"expected_memory_with_disk": "32MB"
37+
}
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"summary": "A request for explaining a data frame analytics job configuration.",
3+
"value": {
4+
"source": {
5+
"index": "houses_sold_last_10_yrs"
6+
},
7+
"analysis": {
8+
"regression": {
9+
"dependent_variable": "price"
10+
}
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)