get-inference-trained-model.asciidoc 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[get-inference]]
  4. = Get trained model API
  5. [subs="attributes"]
  6. ++++
  7. <titleabbrev>Get trained model</titleabbrev>
  8. ++++
  9. Retrieves configuration information for a trained model.
  10. experimental[]
  11. [[ml-get-inference-request]]
  12. == {api-request-title}
  13. `GET _ml/inference/` +
  14. `GET _ml/inference/<model_id>` +
  15. `GET _ml/inference/_all` +
  16. `GET _ml/inference/<model_id1>,<model_id2>` +
  17. `GET _ml/inference/<model_id_pattern*>`
  18. [[ml-get-inference-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-inference-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-inference-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-inference-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. Indicates if certain fields should be removed from the model configuration on
  46. retrieval. This allows the model to be in an acceptable format to be retrieved
  47. and then added to another cluster. Default is false.
  48. `from`::
  49. (Optional, integer)
  50. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=from-models]
  51. `include`::
  52. (Optional, string)
  53. A comma delimited string of optional fields to include in the response body.
  54. Valid options are:
  55. - `definition`: Includes the model definition
  56. - `total_feature_importance`: Includes the total feature importance for the
  57. training data set. This field is available in the `metadata` field in the
  58. response body.
  59. Default is empty, indicating including no optional fields.
  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-inference-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. .Properties of metadata
  106. [%collapsible%open]
  107. =====
  108. `total_feature_importance`:::
  109. (array)
  110. An array of the total feature importance for each feature used from
  111. the training data set. This array of objects is returned if {dfanalytics} trained
  112. the model and the request includes `total_feature_importance` in the `include`
  113. request parameter.
  114. +
  115. .Properties of total feature importance
  116. [%collapsible%open]
  117. ======
  118. `feature_name`:::
  119. (string)
  120. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-feature-name]
  121. `importance`:::
  122. (object)
  123. A collection of feature importance statistics related to the training data set for this particular feature.
  124. +
  125. .Properties of feature importance
  126. [%collapsible%open]
  127. =======
  128. `mean_magnitude`:::
  129. (double)
  130. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-magnitude]
  131. `max`:::
  132. (int)
  133. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-max]
  134. `min`:::
  135. (int)
  136. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-min]
  137. =======
  138. `classes`:::
  139. (array)
  140. If the trained model is a classification model, feature importance statistics are gathered
  141. per target class value.
  142. +
  143. .Properties of class feature importance
  144. [%collapsible%open]
  145. =======
  146. `class_name`:::
  147. (string)
  148. The target class value. Could be a string, boolean, or number.
  149. `importance`:::
  150. (object)
  151. A collection of feature importance statistics related to the training data set for this particular feature.
  152. +
  153. .Properties of feature importance
  154. [%collapsible%open]
  155. ========
  156. `mean_magnitude`:::
  157. (double)
  158. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-magnitude]
  159. `max`:::
  160. (int)
  161. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-max]
  162. `min`:::
  163. (int)
  164. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-min]
  165. ========
  166. =======
  167. ======
  168. =====
  169. `model_id`:::
  170. (string)
  171. Identifier for the trained model.
  172. `tags`:::
  173. (string)
  174. A comma delimited string of tags. A trained model can have many tags, or none.
  175. `version`:::
  176. (string)
  177. The {es} version number in which the trained model was created.
  178. ====
  179. [[ml-get-inference-response-codes]]
  180. == {api-response-codes-title}
  181. `400`::
  182. If `include_model_definition` is `true`, this code indicates that more than
  183. one models match the ID pattern.
  184. `404` (Missing resources)::
  185. If `allow_no_match` is `false`, this code indicates that there are no
  186. resources that match the request or only partial matches for the request.
  187. [[ml-get-inference-example]]
  188. == {api-examples-title}
  189. The following example gets configuration information for all the trained models:
  190. [source,console]
  191. --------------------------------------------------
  192. GET _ml/inference/
  193. --------------------------------------------------
  194. // TEST[skip:TBD]