2019-07-05 07:34:05 -04:00
|
|
|
[role="xpack"]
|
|
|
|
[testenv="platinum"]
|
|
|
|
[[evaluate-dfanalytics]]
|
|
|
|
=== Evaluate {dfanalytics} API
|
|
|
|
|
|
|
|
[subs="attributes"]
|
|
|
|
++++
|
|
|
|
<titleabbrev>Evaluate {dfanalytics}</titleabbrev>
|
|
|
|
++++
|
|
|
|
|
2019-07-11 12:05:05 -04:00
|
|
|
Evaluates the {dfanalytics} for an annotated index.
|
2019-07-05 07:34:05 -04:00
|
|
|
|
2019-07-11 12:05:05 -04:00
|
|
|
experimental[]
|
2019-07-05 07:34:05 -04:00
|
|
|
|
|
|
|
[[ml-evaluate-dfanalytics-request]]
|
|
|
|
==== {api-request-title}
|
|
|
|
|
|
|
|
`POST _ml/data_frame/_evaluate`
|
|
|
|
|
|
|
|
[[ml-evaluate-dfanalytics-prereq]]
|
|
|
|
==== {api-prereq-title}
|
|
|
|
|
|
|
|
* You must have `monitor_ml` privilege to use this API. For more
|
|
|
|
information, see {stack-ov}/security-privileges.html[Security privileges] and
|
|
|
|
{stack-ov}/built-in-roles.html[Built-in roles].
|
|
|
|
|
2019-07-11 12:05:05 -04:00
|
|
|
[[ml-evaluate-dfanalytics-desc]]
|
|
|
|
==== {api-description-title}
|
|
|
|
|
2019-09-19 03:10:11 -04:00
|
|
|
The API packages together commonly used evaluation metrics for various types of
|
|
|
|
machine learning features. This has been designed for use on indexes created by
|
|
|
|
{dfanalytics}. Evaluation requires both a ground truth field and an analytics
|
|
|
|
result field to be present.
|
2019-07-11 12:05:05 -04:00
|
|
|
|
|
|
|
|
2019-07-05 07:34:05 -04:00
|
|
|
[[ml-evaluate-dfanalytics-request-body]]
|
|
|
|
==== {api-request-body-title}
|
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`index`::
|
|
|
|
(Required, object) Defines the `index` in which the evaluation will be
|
|
|
|
performed.
|
2019-08-22 05:14:26 -04:00
|
|
|
|
|
|
|
`query`::
|
2019-09-19 03:10:11 -04:00
|
|
|
(Optional, object) A query clause that retrieves a subset of data from the
|
|
|
|
source index. See <<query-dsl>>.
|
2019-08-22 05:14:26 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`evaluation`::
|
2019-09-19 03:10:11 -04:00
|
|
|
(Required, object) Defines the type of evaluation you want to perform. See
|
|
|
|
<<ml-evaluate-dfanalytics-resources>>.
|
|
|
|
+
|
|
|
|
--
|
|
|
|
Available evaluation types:
|
|
|
|
* `binary_soft_classification`
|
|
|
|
* `regression`
|
|
|
|
--
|
|
|
|
|
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
////
|
2019-07-11 12:05:05 -04:00
|
|
|
[[ml-evaluate-dfanalytics-results]]
|
|
|
|
==== {api-response-body-title}
|
|
|
|
|
|
|
|
`binary_soft_classification`::
|
|
|
|
(object) If you chose to do binary soft classification, the API returns the
|
|
|
|
following evaluation metrics:
|
|
|
|
|
|
|
|
`auc_roc`::: TBD
|
|
|
|
|
|
|
|
`confusion_matrix`::: TBD
|
|
|
|
|
|
|
|
`precision`::: TBD
|
|
|
|
|
|
|
|
`recall`::: TBD
|
2019-07-12 11:26:31 -04:00
|
|
|
////
|
2019-07-05 07:34:05 -04:00
|
|
|
|
|
|
|
[[ml-evaluate-dfanalytics-example]]
|
|
|
|
==== {api-examples-title}
|
|
|
|
|
2019-09-19 03:10:11 -04:00
|
|
|
===== Binary soft classification
|
|
|
|
|
2019-09-09 12:35:50 -04:00
|
|
|
[source,console]
|
2019-07-05 07:34:05 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
POST _ml/data_frame/_evaluate
|
|
|
|
{
|
|
|
|
"index": "my_analytics_dest_index",
|
|
|
|
"evaluation": {
|
|
|
|
"binary_soft_classification": {
|
|
|
|
"actual_field": "is_outlier",
|
|
|
|
"predicted_probability_field": "ml.outlier_score"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// TEST[skip:TBD]
|
|
|
|
|
|
|
|
The API returns the following results:
|
|
|
|
|
2019-09-06 09:22:08 -04:00
|
|
|
[source,console-result]
|
2019-07-05 07:34:05 -04:00
|
|
|
----
|
|
|
|
{
|
|
|
|
"binary_soft_classification": {
|
|
|
|
"auc_roc": {
|
|
|
|
"score": 0.92584757746414444
|
|
|
|
},
|
|
|
|
"confusion_matrix": {
|
|
|
|
"0.25": {
|
|
|
|
"tp": 5,
|
|
|
|
"fp": 9,
|
|
|
|
"tn": 204,
|
|
|
|
"fn": 5
|
|
|
|
},
|
|
|
|
"0.5": {
|
|
|
|
"tp": 1,
|
|
|
|
"fp": 5,
|
|
|
|
"tn": 208,
|
|
|
|
"fn": 9
|
|
|
|
},
|
|
|
|
"0.75": {
|
|
|
|
"tp": 0,
|
|
|
|
"fp": 4,
|
|
|
|
"tn": 209,
|
|
|
|
"fn": 10
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"precision": {
|
|
|
|
"0.25": 0.35714285714285715,
|
|
|
|
"0.5": 0.16666666666666666,
|
|
|
|
"0.75": 0
|
|
|
|
},
|
|
|
|
"recall": {
|
|
|
|
"0.25": 0.5,
|
|
|
|
"0.5": 0.1,
|
|
|
|
"0.75": 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
2019-09-19 03:10:11 -04:00
|
|
|
|
|
|
|
|
|
|
|
===== {regression-cap}
|
|
|
|
|
|
|
|
[source,console]
|
|
|
|
--------------------------------------------------
|
|
|
|
POST _ml/data_frame/_evaluate
|
|
|
|
{
|
|
|
|
"index": "house_price_predictions", <1>
|
|
|
|
"query": {
|
|
|
|
"bool": {
|
|
|
|
"filter": [
|
|
|
|
{ "term": { "ml.is_training": false } } <2>
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"evaluation": {
|
|
|
|
"regression": {
|
|
|
|
"actual_field": "price", <3>
|
|
|
|
"predicted_field": "ml.price_prediction", <4>
|
|
|
|
"metrics": {
|
|
|
|
"r_squared": {},
|
|
|
|
"mean_squared_error": {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// TEST[skip:TBD]
|
|
|
|
|
|
|
|
<1> The output destination index from a {dfanalytics} {reganalysis}.
|
|
|
|
<2> In this example, a test/train split (`training_percent`) was defined for the
|
|
|
|
{reganalysis}. This query limits evaluation to be performed on the test split
|
|
|
|
only.
|
|
|
|
<3> The ground truth value for the actual house price. This is required in order
|
|
|
|
to evaluate results.
|
|
|
|
<4> The predicted value for house price calculated by the {reganalysis}.
|