get-trained-models.asciidoc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[get-trained-models]]
  4. = Get trained models API
  5. [subs="attributes"]
  6. ++++
  7. <titleabbrev>Get trained models</titleabbrev>
  8. ++++
  9. Retrieves configuration information for a trained model.
  10. experimental[]
  11. [[ml-get-trained-models-request]]
  12. == {api-request-title}
  13. `GET _ml/trained_models/` +
  14. `GET _ml/trained_models/<model_id>` +
  15. `GET _ml/trained_models/_all` +
  16. `GET _ml/trained_models/<model_id1>,<model_id2>` +
  17. `GET _ml/trained_models/<model_id_pattern*>`
  18. [[ml-get-trained-models-prereq]]
  19. == {api-prereq-title}
  20. If the {es} {security-features} are enabled, you must have the following
  21. privileges:
  22. * cluster: `monitor_ml`
  23. For more information, see <<security-privileges>> and
  24. {ml-docs-setup-privileges}.
  25. [[ml-get-trained-models-desc]]
  26. == {api-description-title}
  27. You can get information for multiple trained models in a single API request by
  28. using a comma-separated list of model IDs or a wildcard expression.
  29. [[ml-get-trained-models-path-params]]
  30. == {api-path-parms-title}
  31. `<model_id>`::
  32. (Optional, string)
  33. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-id]
  34. [[ml-get-trained-models-query-params]]
  35. == {api-query-parms-title}
  36. `allow_no_match`::
  37. (Optional, boolean)
  38. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=allow-no-match-models]
  39. `decompress_definition`::
  40. (Optional, boolean)
  41. Specifies whether the included model definition should be returned as a JSON map
  42. (`true`) or in a custom compressed format (`false`). Defaults to `true`.
  43. `for_export`::
  44. (Optional, boolean)
  45. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=for-export]
  46. `from`::
  47. (Optional, integer)
  48. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=from-models]
  49. `include`::
  50. (Optional, string)
  51. A comma delimited string of optional fields to include in the response body.
  52. Valid options are:
  53. - `definition`: Includes the model definition
  54. - `total_feature_importance`: Includes the total feature importance for the
  55. training data set. This field is available in the `metadata` field in the
  56. response body.
  57. Default is empty, indicating including no optional fields.
  58. `size`::
  59. (Optional, integer)
  60. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=size-models]
  61. `tags`::
  62. (Optional, string)
  63. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=tags]
  64. [role="child_attributes"]
  65. [[ml-get-trained-models-results]]
  66. == {api-response-body-title}
  67. `trained_model_configs`::
  68. (array)
  69. An array of trained model resources, which are sorted by the `model_id` value in
  70. ascending order.
  71. +
  72. .Properties of trained model resources
  73. [%collapsible%open]
  74. ====
  75. `created_by`:::
  76. (string)
  77. Information on the creator of the trained model.
  78. `create_time`:::
  79. (<<time-units,time units>>)
  80. The time when the trained model was created.
  81. `default_field_map` :::
  82. (object)
  83. A string to string object that contains the default field map to use
  84. when inferring against the model. For example, data frame analytics
  85. may train the model on a specific multi-field `foo.keyword`.
  86. The analytics job would then supply a default field map entry for
  87. `"foo" : "foo.keyword"`.
  88. +
  89. Any field map described in the inference configuration takes precedence.
  90. `estimated_heap_memory_usage_bytes`:::
  91. (integer)
  92. The estimated heap usage in bytes to keep the trained model in memory.
  93. `estimated_operations`:::
  94. (integer)
  95. The estimated number of operations to use the trained model.
  96. `license_level`:::
  97. (string)
  98. The license level of the trained model.
  99. `metadata`:::
  100. (object)
  101. An object containing metadata about the trained model. For example, models
  102. created by {dfanalytics} contain `analysis_config` and `input` objects.
  103. +
  104. .Properties of metadata
  105. [%collapsible%open]
  106. =====
  107. `total_feature_importance`:::
  108. (array)
  109. An array of the total feature importance for each feature used from
  110. the training data set. This array of objects is returned if {dfanalytics} trained
  111. the model and the request includes `total_feature_importance` in the `include`
  112. request parameter.
  113. +
  114. .Properties of total feature importance
  115. [%collapsible%open]
  116. ======
  117. `feature_name`:::
  118. (string)
  119. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-feature-name]
  120. `importance`:::
  121. (object)
  122. A collection of feature importance statistics related to the training data set for this particular feature.
  123. +
  124. .Properties of feature importance
  125. [%collapsible%open]
  126. =======
  127. `mean_magnitude`:::
  128. (double)
  129. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-magnitude]
  130. `max`:::
  131. (int)
  132. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-max]
  133. `min`:::
  134. (int)
  135. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-min]
  136. =======
  137. `classes`:::
  138. (array)
  139. If the trained model is a classification model, feature importance statistics are gathered
  140. per target class value.
  141. +
  142. .Properties of class feature importance
  143. [%collapsible%open]
  144. =======
  145. `class_name`:::
  146. (string)
  147. The target class value. Could be a string, boolean, or number.
  148. `importance`:::
  149. (object)
  150. A collection of feature importance statistics related to the training data set for this particular feature.
  151. +
  152. .Properties of feature importance
  153. [%collapsible%open]
  154. ========
  155. `mean_magnitude`:::
  156. (double)
  157. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-magnitude]
  158. `max`:::
  159. (int)
  160. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-max]
  161. `min`:::
  162. (int)
  163. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-min]
  164. ========
  165. =======
  166. ======
  167. =====
  168. `model_id`:::
  169. (string)
  170. Identifier for the trained model.
  171. `tags`:::
  172. (string)
  173. A comma delimited string of tags. A trained model can have many tags, or none.
  174. `version`:::
  175. (string)
  176. The {es} version number in which the trained model was created.
  177. ====
  178. [[ml-get-trained-models-response-codes]]
  179. == {api-response-codes-title}
  180. `400`::
  181. If `include_model_definition` is `true`, this code indicates that more than
  182. one models match the ID pattern.
  183. `404` (Missing resources)::
  184. If `allow_no_match` is `false`, this code indicates that there are no
  185. resources that match the request or only partial matches for the request.
  186. [[ml-get-trained-models-example]]
  187. == {api-examples-title}
  188. The following example gets configuration information for all the trained models:
  189. [source,console]
  190. --------------------------------------------------
  191. GET _ml/trained_models/
  192. --------------------------------------------------
  193. // TEST[skip:TBD]