get-trained-models.asciidoc 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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. [[ml-get-trained-models-request]]
  11. == {api-request-title}
  12. `GET _ml/trained_models/` +
  13. `GET _ml/trained_models/<model_id>` +
  14. `GET _ml/trained_models/_all` +
  15. `GET _ml/trained_models/<model_id1>,<model_id2>` +
  16. `GET _ml/trained_models/<model_id_pattern*>`
  17. [[ml-get-trained-models-prereq]]
  18. == {api-prereq-title}
  19. If the {es} {security-features} are enabled, you must have the following
  20. privileges:
  21. * cluster: `monitor_ml`
  22. For more information, see <<security-privileges>> and
  23. {ml-docs-setup-privileges}.
  24. [[ml-get-trained-models-desc]]
  25. == {api-description-title}
  26. You can get information for multiple trained models in a single API request by
  27. using a comma-separated list of model IDs or a wildcard expression.
  28. [[ml-get-trained-models-path-params]]
  29. == {api-path-parms-title}
  30. `<model_id>`::
  31. (Optional, string)
  32. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-id-or-alias]
  33. [[ml-get-trained-models-query-params]]
  34. == {api-query-parms-title}
  35. `allow_no_match`::
  36. (Optional, Boolean)
  37. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=allow-no-match-models]
  38. `decompress_definition`::
  39. (Optional, Boolean)
  40. Specifies whether the included model definition should be returned as a JSON map
  41. (`true`) or in a custom compressed format (`false`). Defaults to `true`.
  42. `exclude_generated`::
  43. (Optional, Boolean)
  44. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=exclude-generated]
  45. `from`::
  46. (Optional, integer)
  47. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=from-models]
  48. `include`::
  49. (Optional, string)
  50. A comma delimited string of optional fields to include in the response body. The
  51. default value is empty, indicating no optional fields are included. Valid
  52. options are:
  53. - `definition`: Includes the model definition.
  54. - `feature_importance_baseline`: Includes the baseline for {feat-imp} values.
  55. - `hyperparameters`: Includes the information about hyperparameters used to
  56. train the model. This information consists of the value, the absolute and
  57. relative importance of the hyperparameter as well as an indicator of whether
  58. it was specified by the user or tuned during hyperparameter optimization.
  59. - `total_feature_importance`: Includes the total {feat-imp} for the training
  60. data set.
  61. The baseline and total {feat-imp} values are returned in the `metadata` field
  62. in the response body.
  63. `size`::
  64. (Optional, integer)
  65. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=size-models]
  66. `tags`::
  67. (Optional, string)
  68. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=tags]
  69. [role="child_attributes"]
  70. [[ml-get-trained-models-results]]
  71. == {api-response-body-title}
  72. `trained_model_configs`::
  73. (array)
  74. An array of trained model resources, which are sorted by the `model_id` value in
  75. ascending order.
  76. +
  77. .Properties of trained model resources
  78. [%collapsible%open]
  79. ====
  80. `created_by`:::
  81. (string)
  82. Information on the creator of the trained model.
  83. `create_time`:::
  84. (<<time-units,time units>>)
  85. The time when the trained model was created.
  86. `default_field_map` :::
  87. (object)
  88. A string to string object that contains the default field map to use
  89. when inferring against the model. For example, data frame analytics
  90. may train the model on a specific multi-field `foo.keyword`.
  91. The analytics job would then supply a default field map entry for
  92. `"foo" : "foo.keyword"`.
  93. +
  94. Any field map described in the inference configuration takes precedence.
  95. `description`:::
  96. (string)
  97. The free-text description of the trained model.
  98. `estimated_heap_memory_usage_bytes`:::
  99. (integer)
  100. The estimated heap usage in bytes to keep the trained model in memory.
  101. `estimated_operations`:::
  102. (integer)
  103. The estimated number of operations to use the trained model.
  104. `inference_config`:::
  105. (object)
  106. The default configuration for inference. This can be either a `regression`
  107. or `classification` configuration. It must match the underlying
  108. `definition.trained_model`'s `target_type`.
  109. +
  110. .Properties of `inference_config`
  111. [%collapsible%open]
  112. =====
  113. `classification`::::
  114. (object)
  115. Classification configuration for inference.
  116. +
  117. .Properties of classification inference
  118. [%collapsible%open]
  119. ======
  120. `num_top_classes`:::
  121. (integer)
  122. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-classification-num-top-classes]
  123. `num_top_feature_importance_values`:::
  124. (integer)
  125. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-classification-num-top-feature-importance-values]
  126. `prediction_field_type`:::
  127. (string)
  128. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-classification-prediction-field-type]
  129. `results_field`:::
  130. (string)
  131. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-results-field]
  132. `top_classes_results_field`:::
  133. (string)
  134. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-classification-top-classes-results-field]
  135. ======
  136. `regression`::::
  137. (object)
  138. Regression configuration for inference.
  139. +
  140. .Properties of regression inference
  141. [%collapsible%open]
  142. ======
  143. `num_top_feature_importance_values`:::
  144. (integer)
  145. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-regression-num-top-feature-importance-values]
  146. `results_field`:::
  147. (string)
  148. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-results-field]
  149. ======
  150. =====
  151. `input`:::
  152. (object)
  153. The input field names for the model definition.+
  154. +
  155. .Properties of `input`
  156. [%collapsible%open]
  157. =====
  158. `field_names`::::
  159. (string)
  160. An array of input field names for the model.
  161. =====
  162. `license_level`:::
  163. (string)
  164. The license level of the trained model.
  165. `metadata`:::
  166. (object)
  167. An object containing metadata about the trained model. For example, models
  168. created by {dfanalytics} contain `analysis_config` and `input` objects.
  169. +
  170. .Properties of metadata
  171. [%collapsible%open]
  172. =====
  173. `feature_importance_baseline`:::
  174. (object)
  175. An object that contains the baseline for {feat-imp} values. For {reganalysis},
  176. it is a single value. For {classanalysis}, there is a value for each class.
  177. `hyperparameters`:::
  178. (array)
  179. List of the available hyperparameters optimized during the
  180. `fine_parameter_tuning` phase as well as specified by the user.
  181. +
  182. .Properties of hyperparameters
  183. [%collapsible%open]
  184. ======
  185. `absolute_importance`::::
  186. (Optional, double)
  187. A positive number showing how much the parameter influences the variation of the
  188. {ml-docs}/dfa-regression.html#dfa-regression-lossfunction[loss function]. For
  189. hyperparameters with values that are not specified by the user but tuned during
  190. hyperparameter optimization.
  191. `name`::::
  192. (string)
  193. Name of the hyperparameter.
  194. `relative_importance`::::
  195. (Optional, double)
  196. A number between 0 and 1 showing the proportion of influence on the variation of
  197. the loss function among all tuned hyperparameters. For hyperparameters with
  198. values that are not specified by the user but tuned during hyperparameter
  199. optimization.
  200. `supplied`::::
  201. (Boolean)
  202. Indicates if the hyperparameter is specified by the user (`true`) or optimized
  203. (`false`).
  204. `value`::::
  205. (double)
  206. The value of the hyperparameter, either optimized or specified by the user.
  207. ======
  208. `total_feature_importance`:::
  209. (array)
  210. An array of the total {feat-imp} for each feature used from
  211. the training data set. This array of objects is returned if {dfanalytics} trained
  212. the model and the request includes `total_feature_importance` in the `include`
  213. request parameter.
  214. +
  215. .Properties of total {feat-imp}
  216. [%collapsible%open]
  217. ======
  218. `feature_name`:::
  219. (string)
  220. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-feature-name]
  221. `importance`:::
  222. (object)
  223. A collection of {feat-imp} statistics related to the training data set for this particular feature.
  224. +
  225. .Properties of {feat-imp}
  226. [%collapsible%open]
  227. =======
  228. `mean_magnitude`:::
  229. (double)
  230. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-magnitude]
  231. `max`:::
  232. (int)
  233. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-max]
  234. `min`:::
  235. (int)
  236. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-min]
  237. =======
  238. `classes`:::
  239. (array)
  240. If the trained model is a classification model, {feat-imp} statistics are gathered
  241. per target class value.
  242. +
  243. .Properties of class {feat-imp}
  244. [%collapsible%open]
  245. =======
  246. `class_name`:::
  247. (string)
  248. The target class value. Could be a string, boolean, or number.
  249. `importance`:::
  250. (object)
  251. A collection of {feat-imp} statistics related to the training data set for this particular feature.
  252. +
  253. .Properties of {feat-imp}
  254. [%collapsible%open]
  255. ========
  256. `mean_magnitude`:::
  257. (double)
  258. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-magnitude]
  259. `max`:::
  260. (int)
  261. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-max]
  262. `min`:::
  263. (int)
  264. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-metadata-feature-importance-min]
  265. ========
  266. =======
  267. ======
  268. =====
  269. `model_id`:::
  270. (string)
  271. Identifier for the trained model.
  272. `tags`:::
  273. (string)
  274. A comma delimited string of tags. A trained model can have many tags, or none.
  275. `version`:::
  276. (string)
  277. The {es} version number in which the trained model was created.
  278. ====
  279. [[ml-get-trained-models-response-codes]]
  280. == {api-response-codes-title}
  281. `400`::
  282. If `include_model_definition` is `true`, this code indicates that more than
  283. one models match the ID pattern.
  284. `404` (Missing resources)::
  285. If `allow_no_match` is `false`, this code indicates that there are no
  286. resources that match the request or only partial matches for the request.
  287. [[ml-get-trained-models-example]]
  288. == {api-examples-title}
  289. The following example gets configuration information for all the trained models:
  290. [source,console]
  291. --------------------------------------------------
  292. GET _ml/trained_models/
  293. --------------------------------------------------
  294. // TEST[skip:TBD]