get-trained-models.asciidoc 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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. beta::[]
  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. `exclude_generated`::
  44. (Optional, boolean)
  45. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=exclude-generated]
  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. The
  52. default value is empty, indicating no optional fields are included. Valid
  53. options are:
  54. - `definition`: Includes the model definition
  55. - `feature_importance_baseline`: Includes the baseline for {feat-imp} values.
  56. - `total_feature_importance`: Includes the total {feat-imp} for the training
  57. data set.
  58. The baseline and total {feat-imp} values are returned in the `metadata` field
  59. in the response body.
  60. `size`::
  61. (Optional, integer)
  62. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=size-models]
  63. `tags`::
  64. (Optional, string)
  65. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=tags]
  66. [role="child_attributes"]
  67. [[ml-get-trained-models-results]]
  68. == {api-response-body-title}
  69. `trained_model_configs`::
  70. (array)
  71. An array of trained model resources, which are sorted by the `model_id` value in
  72. ascending order.
  73. +
  74. .Properties of trained model resources
  75. [%collapsible%open]
  76. ====
  77. `created_by`:::
  78. (string)
  79. Information on the creator of the trained model.
  80. `create_time`:::
  81. (<<time-units,time units>>)
  82. The time when the trained model was created.
  83. `default_field_map` :::
  84. (object)
  85. A string to string object that contains the default field map to use
  86. when inferring against the model. For example, data frame analytics
  87. may train the model on a specific multi-field `foo.keyword`.
  88. The analytics job would then supply a default field map entry for
  89. `"foo" : "foo.keyword"`.
  90. +
  91. Any field map described in the inference configuration takes precedence.
  92. `estimated_heap_memory_usage_bytes`:::
  93. (integer)
  94. The estimated heap usage in bytes to keep the trained model in memory.
  95. `estimated_operations`:::
  96. (integer)
  97. The estimated number of operations to use the trained model.
  98. `license_level`:::
  99. (string)
  100. The license level of the trained model.
  101. `metadata`:::
  102. (object)
  103. An object containing metadata about the trained model. For example, models
  104. created by {dfanalytics} contain `analysis_config` and `input` objects.
  105. +
  106. .Properties of metadata
  107. [%collapsible%open]
  108. =====
  109. `feature_importance_baseline`:::
  110. (object)
  111. An object that contains the baseline for {feat-imp} values. For {reganalysis},
  112. it is a single value. For {classanalysis}, there is a value for each class.
  113. `total_feature_importance`:::
  114. (array)
  115. An array of the total {feat-imp} for each feature used from
  116. the training data set. This array of objects is returned if {dfanalytics} trained
  117. the model and the request includes `total_feature_importance` in the `include`
  118. request parameter.
  119. +
  120. .Properties of total {feat-imp}
  121. [%collapsible%open]
  122. ======
  123. `feature_name`:::
  124. (string)
  125. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-feature-name]
  126. `importance`:::
  127. (object)
  128. A collection of {feat-imp} statistics related to the training data set for this particular feature.
  129. +
  130. .Properties of {feat-imp}
  131. [%collapsible%open]
  132. =======
  133. `mean_magnitude`:::
  134. (double)
  135. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-magnitude]
  136. `max`:::
  137. (int)
  138. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-max]
  139. `min`:::
  140. (int)
  141. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-min]
  142. =======
  143. `classes`:::
  144. (array)
  145. If the trained model is a classification model, {feat-imp} statistics are gathered
  146. per target class value.
  147. +
  148. .Properties of class {feat-imp}
  149. [%collapsible%open]
  150. =======
  151. `class_name`:::
  152. (string)
  153. The target class value. Could be a string, boolean, or number.
  154. `importance`:::
  155. (object)
  156. A collection of {feat-imp} statistics related to the training data set for this particular feature.
  157. +
  158. .Properties of {feat-imp}
  159. [%collapsible%open]
  160. ========
  161. `mean_magnitude`:::
  162. (double)
  163. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-magnitude]
  164. `max`:::
  165. (int)
  166. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-max]
  167. `min`:::
  168. (int)
  169. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-min]
  170. ========
  171. =======
  172. ======
  173. =====
  174. `model_id`:::
  175. (string)
  176. Identifier for the trained model.
  177. `tags`:::
  178. (string)
  179. A comma delimited string of tags. A trained model can have many tags, or none.
  180. `version`:::
  181. (string)
  182. The {es} version number in which the trained model was created.
  183. ====
  184. [[ml-get-trained-models-response-codes]]
  185. == {api-response-codes-title}
  186. `400`::
  187. If `include_model_definition` is `true`, this code indicates that more than
  188. one models match the ID pattern.
  189. `404` (Missing resources)::
  190. If `allow_no_match` is `false`, this code indicates that there are no
  191. resources that match the request or only partial matches for the request.
  192. [[ml-get-trained-models-example]]
  193. == {api-examples-title}
  194. The following example gets configuration information for all the trained models:
  195. [source,console]
  196. --------------------------------------------------
  197. GET _ml/trained_models/
  198. --------------------------------------------------
  199. // TEST[skip:TBD]