2019-12-18 03:10:12 -05:00
|
|
|
[role="xpack"]
|
|
|
|
[testenv="basic"]
|
2020-10-02 07:34:28 -04:00
|
|
|
[[get-trained-models]]
|
2020-10-02 13:15:14 -04:00
|
|
|
= Get trained models API
|
2019-12-18 03:10:12 -05:00
|
|
|
[subs="attributes"]
|
|
|
|
++++
|
2020-10-02 13:15:14 -04:00
|
|
|
<titleabbrev>Get trained models</titleabbrev>
|
2019-12-18 03:10:12 -05:00
|
|
|
++++
|
|
|
|
|
2020-09-07 06:14:13 -04:00
|
|
|
Retrieves configuration information for a trained model.
|
2019-12-18 03:10:12 -05:00
|
|
|
|
|
|
|
experimental[]
|
|
|
|
|
|
|
|
|
2020-10-02 07:34:28 -04:00
|
|
|
[[ml-get-trained-models-request]]
|
2020-07-20 16:06:29 -04:00
|
|
|
== {api-request-title}
|
2019-12-18 03:10:12 -05:00
|
|
|
|
2020-10-02 07:34:28 -04:00
|
|
|
`GET _ml/trained_models/` +
|
2019-12-18 03:10:12 -05:00
|
|
|
|
2020-10-02 07:34:28 -04:00
|
|
|
`GET _ml/trained_models/<model_id>` +
|
2019-12-18 03:10:12 -05:00
|
|
|
|
2020-10-02 07:34:28 -04:00
|
|
|
`GET _ml/trained_models/_all` +
|
2019-12-18 03:10:12 -05:00
|
|
|
|
2020-10-02 07:34:28 -04:00
|
|
|
`GET _ml/trained_models/<model_id1>,<model_id2>` +
|
2019-12-18 03:10:12 -05:00
|
|
|
|
2020-10-02 07:34:28 -04:00
|
|
|
`GET _ml/trained_models/<model_id_pattern*>`
|
2019-12-18 03:10:12 -05:00
|
|
|
|
|
|
|
|
2020-10-02 07:34:28 -04:00
|
|
|
[[ml-get-trained-models-prereq]]
|
2020-07-20 16:06:29 -04:00
|
|
|
== {api-prereq-title}
|
2019-12-18 03:10:12 -05:00
|
|
|
|
2020-09-18 10:07:35 -04:00
|
|
|
If the {es} {security-features} are enabled, you must have the following
|
|
|
|
privileges:
|
2020-01-09 04:44:07 -05:00
|
|
|
|
|
|
|
* cluster: `monitor_ml`
|
2020-09-18 10:07:35 -04:00
|
|
|
|
|
|
|
For more information, see <<security-privileges>> and
|
2020-09-07 06:14:13 -04:00
|
|
|
{ml-docs-setup-privileges}.
|
2019-12-18 03:10:12 -05:00
|
|
|
|
|
|
|
|
2020-10-02 07:34:28 -04:00
|
|
|
[[ml-get-trained-models-desc]]
|
2020-07-20 16:06:29 -04:00
|
|
|
== {api-description-title}
|
2019-12-18 03:10:12 -05:00
|
|
|
|
2020-09-18 10:07:35 -04:00
|
|
|
You can get information for multiple trained models in a single API request by
|
2019-12-18 03:10:12 -05:00
|
|
|
using a comma-separated list of model IDs or a wildcard expression.
|
|
|
|
|
|
|
|
|
2020-10-02 07:34:28 -04:00
|
|
|
[[ml-get-trained-models-path-params]]
|
2020-07-20 16:06:29 -04:00
|
|
|
== {api-path-parms-title}
|
2019-12-18 03:10:12 -05:00
|
|
|
|
|
|
|
`<model_id>`::
|
2020-09-18 10:07:35 -04:00
|
|
|
(Optional, string)
|
2020-06-01 16:46:15 -04:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-id]
|
2019-12-18 03:10:12 -05:00
|
|
|
|
|
|
|
|
2020-10-02 07:34:28 -04:00
|
|
|
[[ml-get-trained-models-query-params]]
|
2020-07-20 16:06:29 -04:00
|
|
|
== {api-query-parms-title}
|
2019-12-18 03:10:12 -05:00
|
|
|
|
|
|
|
`allow_no_match`::
|
2020-09-18 10:07:35 -04:00
|
|
|
(Optional, boolean)
|
2020-09-08 11:11:33 -04:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=allow-no-match-models]
|
2019-12-18 03:10:12 -05:00
|
|
|
|
|
|
|
`decompress_definition`::
|
|
|
|
(Optional, boolean)
|
2020-09-18 10:07:35 -04:00
|
|
|
Specifies whether the included model definition should be returned as a JSON map
|
2020-04-14 21:47:09 -04:00
|
|
|
(`true`) or in a custom compressed format (`false`). Defaults to `true`.
|
2019-12-18 03:10:12 -05:00
|
|
|
|
2020-09-08 15:54:51 -04:00
|
|
|
`for_export`::
|
|
|
|
(Optional, boolean)
|
|
|
|
Indicates if certain fields should be removed from the model configuration on
|
|
|
|
retrieval. This allows the model to be in an acceptable format to be retrieved
|
|
|
|
and then added to another cluster. Default is false.
|
|
|
|
|
2019-12-18 03:10:12 -05:00
|
|
|
`from`::
|
2020-09-18 10:07:35 -04:00
|
|
|
(Optional, integer)
|
2020-09-08 15:54:51 -04:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=from-models]
|
2019-12-18 03:10:12 -05:00
|
|
|
|
2020-09-18 10:07:35 -04:00
|
|
|
`include`::
|
|
|
|
(Optional, string)
|
2020-10-06 13:08:34 -04:00
|
|
|
A comma delimited string of optional fields to include in the response body. The
|
|
|
|
default value is empty, indicating no optional fields are included. Valid
|
|
|
|
options are:
|
2020-09-18 10:07:35 -04:00
|
|
|
- `definition`: Includes the model definition
|
2020-10-06 13:08:34 -04:00
|
|
|
- `feature_importance_baseline`: Includes the baseline for {feat-imp} values.
|
|
|
|
- `total_feature_importance`: Includes the total {feat-imp} for the training
|
|
|
|
data set.
|
|
|
|
The baseline and total {feat-imp} values are returned in the `metadata` field
|
|
|
|
in the response body.
|
2019-12-18 03:10:12 -05:00
|
|
|
|
|
|
|
`size`::
|
2020-09-18 10:07:35 -04:00
|
|
|
(Optional, integer)
|
2020-09-08 15:54:51 -04:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=size-models]
|
2019-12-18 03:10:12 -05:00
|
|
|
|
2020-01-24 08:26:58 -05:00
|
|
|
`tags`::
|
|
|
|
(Optional, string)
|
2020-06-01 16:46:15 -04:00
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=tags]
|
2019-12-18 03:10:12 -05:00
|
|
|
|
2020-03-31 15:51:04 -04:00
|
|
|
[role="child_attributes"]
|
2020-10-02 07:34:28 -04:00
|
|
|
[[ml-get-trained-models-results]]
|
2020-07-20 16:06:29 -04:00
|
|
|
== {api-response-body-title}
|
2020-03-03 10:25:24 -05:00
|
|
|
|
|
|
|
`trained_model_configs`::
|
2020-04-14 21:47:09 -04:00
|
|
|
(array)
|
2020-09-18 10:07:35 -04:00
|
|
|
An array of trained model resources, which are sorted by the `model_id` value in
|
2020-04-14 21:47:09 -04:00
|
|
|
ascending order.
|
|
|
|
+
|
|
|
|
.Properties of trained model resources
|
|
|
|
[%collapsible%open]
|
|
|
|
====
|
|
|
|
`created_by`:::
|
|
|
|
(string)
|
|
|
|
Information on the creator of the trained model.
|
|
|
|
|
|
|
|
`create_time`:::
|
|
|
|
(<<time-units,time units>>)
|
|
|
|
The time when the trained model was created.
|
|
|
|
|
|
|
|
`default_field_map` :::
|
|
|
|
(object)
|
|
|
|
A string to string object that contains the default field map to use
|
|
|
|
when inferring against the model. For example, data frame analytics
|
|
|
|
may train the model on a specific multi-field `foo.keyword`.
|
|
|
|
The analytics job would then supply a default field map entry for
|
|
|
|
`"foo" : "foo.keyword"`.
|
|
|
|
+
|
|
|
|
Any field map described in the inference configuration takes precedence.
|
|
|
|
|
|
|
|
`estimated_heap_memory_usage_bytes`:::
|
|
|
|
(integer)
|
|
|
|
The estimated heap usage in bytes to keep the trained model in memory.
|
|
|
|
|
|
|
|
`estimated_operations`:::
|
|
|
|
(integer)
|
|
|
|
The estimated number of operations to use the trained model.
|
|
|
|
|
|
|
|
`license_level`:::
|
|
|
|
(string)
|
|
|
|
The license level of the trained model.
|
|
|
|
|
|
|
|
`metadata`:::
|
|
|
|
(object)
|
2020-09-18 10:07:35 -04:00
|
|
|
An object containing metadata about the trained model. For example, models
|
2020-04-14 21:47:09 -04:00
|
|
|
created by {dfanalytics} contain `analysis_config` and `input` objects.
|
2020-09-21 11:19:37 -04:00
|
|
|
+
|
2020-09-18 10:07:35 -04:00
|
|
|
.Properties of metadata
|
|
|
|
[%collapsible%open]
|
|
|
|
=====
|
2020-10-06 13:08:34 -04:00
|
|
|
`feature_importance_baseline`:::
|
|
|
|
(object)
|
|
|
|
An object that contains the baseline for {feat-imp} values. For {reganalysis},
|
|
|
|
it is a single value. For {classanalysis}, there is a value for each class.
|
|
|
|
|
2020-09-18 10:07:35 -04:00
|
|
|
`total_feature_importance`:::
|
|
|
|
(array)
|
2020-10-06 13:08:34 -04:00
|
|
|
An array of the total {feat-imp} for each feature used from
|
2020-09-18 10:07:35 -04:00
|
|
|
the training data set. This array of objects is returned if {dfanalytics} trained
|
|
|
|
the model and the request includes `total_feature_importance` in the `include`
|
|
|
|
request parameter.
|
|
|
|
+
|
2020-10-06 13:08:34 -04:00
|
|
|
.Properties of total {feat-imp}
|
2020-09-18 10:07:35 -04:00
|
|
|
[%collapsible%open]
|
|
|
|
======
|
|
|
|
|
|
|
|
`feature_name`:::
|
|
|
|
(string)
|
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-feature-name]
|
|
|
|
|
|
|
|
`importance`:::
|
|
|
|
(object)
|
2020-10-06 13:08:34 -04:00
|
|
|
A collection of {feat-imp} statistics related to the training data set for this particular feature.
|
2020-09-18 10:07:35 -04:00
|
|
|
+
|
2020-10-06 13:08:34 -04:00
|
|
|
.Properties of {feat-imp}
|
2020-09-18 10:07:35 -04:00
|
|
|
[%collapsible%open]
|
|
|
|
=======
|
|
|
|
`mean_magnitude`:::
|
|
|
|
(double)
|
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-magnitude]
|
|
|
|
|
|
|
|
`max`:::
|
|
|
|
(int)
|
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-max]
|
|
|
|
|
|
|
|
`min`:::
|
|
|
|
(int)
|
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-min]
|
|
|
|
|
|
|
|
=======
|
|
|
|
|
|
|
|
`classes`:::
|
|
|
|
(array)
|
2020-10-06 13:08:34 -04:00
|
|
|
If the trained model is a classification model, {feat-imp} statistics are gathered
|
2020-09-18 10:07:35 -04:00
|
|
|
per target class value.
|
|
|
|
+
|
2020-10-06 13:08:34 -04:00
|
|
|
.Properties of class {feat-imp}
|
2020-09-18 10:07:35 -04:00
|
|
|
[%collapsible%open]
|
|
|
|
|
|
|
|
=======
|
|
|
|
|
|
|
|
`class_name`:::
|
|
|
|
(string)
|
|
|
|
The target class value. Could be a string, boolean, or number.
|
|
|
|
|
|
|
|
`importance`:::
|
|
|
|
(object)
|
2020-10-06 13:08:34 -04:00
|
|
|
A collection of {feat-imp} statistics related to the training data set for this particular feature.
|
2020-09-18 10:07:35 -04:00
|
|
|
+
|
2020-10-06 13:08:34 -04:00
|
|
|
.Properties of {feat-imp}
|
2020-09-18 10:07:35 -04:00
|
|
|
[%collapsible%open]
|
|
|
|
========
|
|
|
|
`mean_magnitude`:::
|
|
|
|
(double)
|
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-magnitude]
|
|
|
|
|
|
|
|
`max`:::
|
|
|
|
(int)
|
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-max]
|
|
|
|
|
|
|
|
`min`:::
|
|
|
|
(int)
|
|
|
|
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-min]
|
|
|
|
|
|
|
|
========
|
|
|
|
|
|
|
|
=======
|
|
|
|
|
|
|
|
======
|
|
|
|
=====
|
2020-04-14 21:47:09 -04:00
|
|
|
|
|
|
|
`model_id`:::
|
|
|
|
(string)
|
|
|
|
Idetifier for the trained model.
|
|
|
|
|
|
|
|
`tags`:::
|
|
|
|
(string)
|
2020-09-07 06:14:13 -04:00
|
|
|
A comma delimited string of tags. A trained model can have many tags, or none.
|
2020-04-14 21:47:09 -04:00
|
|
|
|
|
|
|
`version`:::
|
|
|
|
(string)
|
|
|
|
The {es} version number in which the trained model was created.
|
|
|
|
====
|
2020-03-03 10:25:24 -05:00
|
|
|
|
2020-10-02 07:34:28 -04:00
|
|
|
[[ml-get-trained-models-response-codes]]
|
|
|
|
|
2020-07-20 16:06:29 -04:00
|
|
|
== {api-response-codes-title}
|
2019-12-18 03:10:12 -05:00
|
|
|
|
|
|
|
`400`::
|
2020-09-18 10:07:35 -04:00
|
|
|
If `include_model_definition` is `true`, this code indicates that more than
|
2019-12-18 03:10:12 -05:00
|
|
|
one models match the ID pattern.
|
|
|
|
|
|
|
|
`404` (Missing resources)::
|
|
|
|
If `allow_no_match` is `false`, this code indicates that there are no
|
|
|
|
resources that match the request or only partial matches for the request.
|
2020-09-18 10:07:35 -04:00
|
|
|
|
2019-12-18 03:10:12 -05:00
|
|
|
|
2020-10-02 07:34:28 -04:00
|
|
|
[[ml-get-trained-models-example]]
|
2020-07-20 16:06:29 -04:00
|
|
|
== {api-examples-title}
|
2019-12-18 03:10:12 -05:00
|
|
|
|
|
|
|
The following example gets configuration information for all the trained models:
|
|
|
|
|
|
|
|
[source,console]
|
|
|
|
--------------------------------------------------
|
2020-10-02 07:34:28 -04:00
|
|
|
GET _ml/trained_models/
|
2019-12-18 03:10:12 -05:00
|
|
|
--------------------------------------------------
|
2020-01-24 08:26:58 -05:00
|
|
|
// TEST[skip:TBD]
|