put-trained-models-aliases.asciidoc 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[put-trained-models-aliases]]
  4. = Create or update trained model aliases API
  5. [subs="attributes"]
  6. ++++
  7. <titleabbrev>Create or update trained model aliases</titleabbrev>
  8. ++++
  9. beta::[]
  10. Creates or updates a trained model alias.
  11. A trained model alias is a logical name used to reference a single trained model.
  12. [[ml-put-trained-models-aliases-request]]
  13. == {api-request-title}
  14. `PUT _ml/trained_models/<model_id>/model_aliases/<model_alias>`
  15. [[ml-put-trained-models-aliases-prereq]]
  16. == {api-prereq-title}
  17. If the {es} {security-features} are enabled, you must have the following
  18. built-in role:
  19. * `machine_learning_admin`
  20. For more information, see <<built-in-roles>>, <<security-privileges>>, and
  21. {ml-docs-setup-privileges}.
  22. [[ml-put-trained-models-aliases-desc]]
  23. == {api-description-title}
  24. You can use aliases instead of trained model identifiers to make it easier to
  25. reference your models. For example, you can use aliases in {infer} aggregations
  26. and processors.
  27. An alias must be unique and refer to only a single trained model. However,
  28. you can have multiple aliases for each trained model.
  29. If you use this API to update an alias such that it references a different
  30. trained model ID and the model uses a different type of {dfanalytics}, an error
  31. occurs. For example, this situation occurs if you have a trained model for
  32. {reganalysis} and a trained model for {classanalysis}; you cannot reassign an
  33. alias from one type of trained model to another.
  34. If you use this API to update an alias and there are very few input fields in
  35. common between the old and new trained models for the model alias, the API
  36. returns a warning.
  37. [[ml-put-trained-models-aliases-path-params]]
  38. == {api-path-parms-title}
  39. `model_alias`::
  40. (Required, string)
  41. The alias to create or update. This value cannot end in numbers.
  42. `model_id`::
  43. (Required, string)
  44. The identifier for the trained model that the alias refers to.
  45. [[ml-put-trained-models-aliases-query-params]]
  46. == {api-query-parms-title}
  47. `reassign`::
  48. (Optional, boolean)
  49. Specifies whether the alias gets reassigned to the specified trained model if it
  50. is already assigned to a different model. If the alias is already assigned and
  51. this parameter is `false`, the API returns an error. Defaults to `false`.
  52. [[ml-put-trained-models-aliases-example]]
  53. == {api-examples-title}
  54. [[ml-put-trained-models-aliases-example-new-alias]]
  55. === Create a trained model alias
  56. The following example shows how to create an alias (`flight_delay_model`) for a
  57. trained model (`flight-delay-prediction-1574775339910`):
  58. [source,console]
  59. --------------------------------------------------
  60. PUT _ml/trained_models/flight-delay-prediction-1574775339910/model_aliases/flight_delay_model
  61. --------------------------------------------------
  62. // TEST[skip:setup kibana sample data]
  63. [[ml-put-trained-models-aliases-example-put-alias]]
  64. === Update a trained model alias
  65. The following example shows how to reassign an alias (`flight_delay_model`) to a
  66. different trained model (`flight-delay-prediction-1580004349800`):
  67. [source,console]
  68. --------------------------------------------------
  69. PUT _ml/trained_models/flight-delay-prediction-1580004349800/model_aliases/flight_delay_model?reassign=true
  70. --------------------------------------------------
  71. // TEST[skip:setup kibana sample data]