put-trained-models.asciidoc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[put-trained-models]]
  4. = Create trained models API
  5. [subs="attributes"]
  6. ++++
  7. <titleabbrev>Create trained models</titleabbrev>
  8. ++++
  9. Creates a trained model.
  10. WARNING: Models created in version 7.8.0 are not backwards compatible
  11. with older node versions. If in a mixed cluster environment,
  12. all nodes must be at least 7.8.0 to use a model stored by
  13. a 7.8.0 node.
  14. [[ml-put-trained-models-request]]
  15. == {api-request-title}
  16. `PUT _ml/trained_models/<model_id>`
  17. [[ml-put-trained-models-prereq]]
  18. == {api-prereq-title}
  19. Requires the `manage_ml` cluster privilege. This privilege is included in the
  20. `machine_learning_admin` built-in role.
  21. [[ml-put-trained-models-desc]]
  22. == {api-description-title}
  23. The create trained model API enables you to supply a trained model that is not
  24. created by {dfanalytics}.
  25. [[ml-put-trained-models-path-params]]
  26. == {api-path-parms-title}
  27. `<model_id>`::
  28. (Required, string)
  29. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-id]
  30. [[ml-put-trained-models-query-params]]
  31. == {api-query-parms-title}
  32. `defer_definition_decompression`::
  33. (Optional, boolean)
  34. If set to `true` and a `compressed_definition` is provided, the request defers
  35. definition decompression and skips relevant validations.
  36. This deferral is useful for systems or users that know a good JVM heap size estimate for their
  37. model and know that their model is valid and likely won't fail during inference.
  38. [role="child_attributes"]
  39. [[ml-put-trained-models-request-body]]
  40. == {api-request-body-title}
  41. `compressed_definition`::
  42. (Required, string)
  43. The compressed (GZipped and Base64 encoded) {infer} definition of the model.
  44. If `compressed_definition` is specified, then `definition` cannot be specified.
  45. //Begin definition
  46. `definition`::
  47. (Required, object)
  48. The {infer} definition for the model. If `definition` is specified, then
  49. `compressed_definition` cannot be specified.
  50. +
  51. .Properties of `definition`
  52. [%collapsible%open]
  53. ====
  54. //Begin preprocessors
  55. `preprocessors`::
  56. (Optional, object)
  57. Collection of preprocessors. See <<ml-put-trained-models-preprocessor-example>>.
  58. +
  59. .Properties of `preprocessors`
  60. [%collapsible%open]
  61. =====
  62. //Begin frequency encoding
  63. `frequency_encoding`::
  64. (Required, object)
  65. Defines a frequency encoding for a field.
  66. +
  67. .Properties of `frequency_encoding`
  68. [%collapsible%open]
  69. ======
  70. `feature_name`::
  71. (Required, string)
  72. The name of the resulting feature.
  73. `field`::
  74. (Required, string)
  75. The field name to encode.
  76. `frequency_map`::
  77. (Required, object map of string:double)
  78. Object that maps the field value to the frequency encoded value.
  79. `custom`::
  80. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=custom-preprocessor]
  81. ======
  82. //End frequency encoding
  83. //Begin one hot encoding
  84. `one_hot_encoding`::
  85. (Required, object)
  86. Defines a one hot encoding map for a field.
  87. +
  88. .Properties of `one_hot_encoding`
  89. [%collapsible%open]
  90. ======
  91. `field`::
  92. (Required, string)
  93. The field name to encode.
  94. `hot_map`::
  95. (Required, object map of strings)
  96. String map of "field_value: one_hot_column_name".
  97. `custom`::
  98. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=custom-preprocessor]
  99. ======
  100. //End one hot encoding
  101. //Begin target mean encoding
  102. `target_mean_encoding`::
  103. (Required, object)
  104. Defines a target mean encoding for a field.
  105. +
  106. .Properties of `target_mean_encoding`
  107. [%collapsible%open]
  108. ======
  109. `default_value`:::
  110. (Required, double)
  111. The feature value if the field value is not in the `target_map`.
  112. `feature_name`:::
  113. (Required, string)
  114. The name of the resulting feature.
  115. `field`:::
  116. (Required, string)
  117. The field name to encode.
  118. `target_map`:::
  119. (Required, object map of string:double)
  120. Object that maps the field value to the target mean value.
  121. `custom`::
  122. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=custom-preprocessor]
  123. ======
  124. //End target mean encoding
  125. =====
  126. //End preprocessors
  127. //Begin trained model
  128. `trained_model`::
  129. (Required, object)
  130. The definition of the trained model.
  131. +
  132. .Properties of `trained_model`
  133. [%collapsible%open]
  134. =====
  135. //Begin tree
  136. `tree`::
  137. (Required, object)
  138. The definition for a binary decision tree.
  139. +
  140. .Properties of `tree`
  141. [%collapsible%open]
  142. ======
  143. `classification_labels`:::
  144. (Optional, string) An array of classification labels (used for
  145. `classification`).
  146. `feature_names`:::
  147. (Required, string)
  148. Features expected by the tree, in their expected order.
  149. `target_type`:::
  150. (Required, string)
  151. String indicating the model target type; `regression` or `classification`.
  152. `tree_structure`:::
  153. (Required, object)
  154. An array of `tree_node` objects. The nodes must be in ordinal order by their
  155. `tree_node.node_index` value.
  156. ======
  157. //End tree
  158. //Begin tree node
  159. `tree_node`::
  160. (Required, object)
  161. The definition of a node in a tree.
  162. +
  163. --
  164. There are two major types of nodes: leaf nodes and not-leaf nodes.
  165. * Leaf nodes only need `node_index` and `leaf_value` defined.
  166. * All other nodes need `split_feature`, `left_child`, `right_child`,
  167. `threshold`, `decision_type`, and `default_left` defined.
  168. --
  169. +
  170. .Properties of `tree_node`
  171. [%collapsible%open]
  172. ======
  173. `decision_type`::
  174. (Optional, string)
  175. Indicates the positive value (in other words, when to choose the left node)
  176. decision type. Supported `lt`, `lte`, `gt`, `gte`. Defaults to `lte`.
  177. `default_left`::
  178. (Optional, Boolean)
  179. Indicates whether to default to the left when the feature is missing. Defaults
  180. to `true`.
  181. `leaf_value`::
  182. (Optional, double)
  183. The leaf value of the of the node, if the value is a leaf (in other words, no
  184. children).
  185. `left_child`::
  186. (Optional, integer)
  187. The index of the left child.
  188. `node_index`::
  189. (Integer)
  190. The index of the current node.
  191. `right_child`::
  192. (Optional, integer)
  193. The index of the right child.
  194. `split_feature`::
  195. (Optional, integer)
  196. The index of the feature value in the feature array.
  197. `split_gain`::
  198. (Optional, double) The information gain from the split.
  199. `threshold`::
  200. (Optional, double)
  201. The decision threshold with which to compare the feature value.
  202. ======
  203. //End tree node
  204. //Begin ensemble
  205. `ensemble`::
  206. (Optional, object)
  207. The definition for an ensemble model. See <<ml-put-trained-models-model-example>>.
  208. +
  209. .Properties of `ensemble`
  210. [%collapsible%open]
  211. ======
  212. //Begin aggregate output
  213. `aggregate_output`::
  214. (Required, object)
  215. An aggregated output object that defines how to aggregate the outputs of the
  216. `trained_models`. Supported objects are `weighted_mode`, `weighted_sum`, and
  217. `logistic_regression`. See <<ml-put-trained-models-aggregated-output-example>>.
  218. +
  219. .Properties of `aggregate_output`
  220. [%collapsible%open]
  221. =======
  222. //Begin logistic regression
  223. `logistic_regression`::
  224. (Optional, object)
  225. This `aggregated_output` type works with binary classification (classification
  226. for values [0, 1]). It multiplies the outputs (in the case of the `ensemble`
  227. model, the inference model values) by the supplied `weights`. The resulting
  228. vector is summed and passed to a
  229. {wikipedia}/Sigmoid_function[`sigmoid` function]. The result
  230. of the `sigmoid` function is considered the probability of class 1 (`P_1`),
  231. consequently, the probability of class 0 is `1 - P_1`. The class with the
  232. highest probability (either 0 or 1) is then returned. For more information about
  233. logistic regression, see
  234. {wikipedia}/Logistic_regression[this wiki article].
  235. +
  236. .Properties of `logistic_regression`
  237. [%collapsible%open]
  238. ========
  239. `weights`:::
  240. (Required, double)
  241. The weights to multiply by the input values (the inference values of the trained
  242. models).
  243. ========
  244. //End logistic regression
  245. //Begin weighted sum
  246. `weighted_sum`::
  247. (Optional, object)
  248. This `aggregated_output` type works with regression. The weighted sum of the
  249. input values.
  250. +
  251. .Properties of `weighted_sum`
  252. [%collapsible%open]
  253. ========
  254. `weights`:::
  255. (Required, double)
  256. The weights to multiply by the input values (the inference values of the trained
  257. models).
  258. ========
  259. //End weighted sum
  260. //Begin weighted mode
  261. `weighted_mode`::
  262. (Optional, object)
  263. This `aggregated_output` type works with regression or classification. It takes
  264. a weighted vote of the input values. The most common input value (taking the
  265. weights into account) is returned.
  266. +
  267. .Properties of `weighted_mode`
  268. [%collapsible%open]
  269. ========
  270. `weights`:::
  271. (Required, double)
  272. The weights to multiply by the input values (the inference values of the trained
  273. models).
  274. ========
  275. //End weighted mode
  276. //Begin exponent
  277. `exponent`::
  278. (Optional, object)
  279. This `aggregated_output` type works with regression. It takes a weighted sum of
  280. the input values and passes the result to an exponent function
  281. (`e^x` where `x` is the sum of the weighted values).
  282. +
  283. .Properties of `exponent`
  284. [%collapsible%open]
  285. ========
  286. `weights`:::
  287. (Required, double)
  288. The weights to multiply by the input values (the inference values of the trained
  289. models).
  290. ========
  291. //End exponent
  292. =======
  293. //End aggregate output
  294. `classification_labels`::
  295. (Optional, string)
  296. An array of classification labels.
  297. `feature_names`::
  298. (Optional, string)
  299. Features expected by the ensemble, in their expected order.
  300. `target_type`::
  301. (Required, string)
  302. String indicating the model target type; `regression` or `classification.`
  303. `trained_models`::
  304. (Required, object)
  305. An array of `trained_model` objects. Supported trained models are `tree` and
  306. `ensemble`.
  307. ======
  308. //End ensemble
  309. =====
  310. //End trained model
  311. ====
  312. //End definition
  313. `description`::
  314. (Optional, string)
  315. A human-readable description of the {infer} trained model.
  316. //Begin inference_config
  317. `inference_config`::
  318. (Required, object)
  319. The default configuration for inference. This can be: `regression`,
  320. `classification`, `fill_mask`, `ner`, `text_classification`, or `text_embedding`.
  321. If `regression` or `classification`, it must match the `target_type` of the
  322. underlying `definition.trained_model`. If `fill_mask`, `ner`,
  323. `text_classification`, or `text_embedding`; the `model_type` must be `pytorch`.
  324. +
  325. .Properties of `inference_config`
  326. [%collapsible%open]
  327. ====
  328. `classification`:::
  329. (Optional, object)
  330. Classification configuration for inference.
  331. +
  332. .Properties of classification inference
  333. [%collapsible%open]
  334. =====
  335. `num_top_classes`::::
  336. (Optional, integer)
  337. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-classification-num-top-classes]
  338. `num_top_feature_importance_values`::::
  339. (Optional, integer)
  340. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-classification-num-top-feature-importance-values]
  341. `prediction_field_type`::::
  342. (Optional, string)
  343. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-classification-prediction-field-type]
  344. `results_field`::::
  345. (Optional, string)
  346. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-results-field]
  347. `top_classes_results_field`::::
  348. (Optional, string)
  349. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-classification-top-classes-results-field]
  350. =====
  351. `fill_mask`:::
  352. (Optional, object)
  353. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-fill-mask]
  354. +
  355. .Properties of fill_mask inference
  356. [%collapsible%open]
  357. =====
  358. `tokenization`::::
  359. (Optional, object)
  360. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization]
  361. +
  362. .Properties of tokenization
  363. [%collapsible%open]
  364. ======
  365. `bert`::::
  366. (Optional, object)
  367. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization-bert]
  368. +
  369. .Properties of bert
  370. [%collapsible%open]
  371. =======
  372. `do_lower_case`::::
  373. (Optional, boolean)
  374. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization-bert-do-lower-case]
  375. `max_sequence_length`::::
  376. (Optional, integer)
  377. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization-bert-max-sequence-length]
  378. `with_special_tokens`::::
  379. (Optional, boolean)
  380. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization-bert-with-special-tokens]
  381. =======
  382. ======
  383. =====
  384. `ner`:::
  385. (Optional, object)
  386. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-ner]
  387. +
  388. .Properties of ner inference
  389. [%collapsible%open]
  390. =====
  391. `classification_labels`::::
  392. (Optional, string)
  393. An array of classification labels. NER only supports Inside-Outside-Beginning labels (IOB)
  394. and only persons, organizations, locations, and miscellaneous.
  395. Example: ["O", "B-PER", "I-PER", "B-ORG", "I-ORG", "B-LOC", "I-LOC", "B-MISC", "I-MISC"]
  396. `tokenization`::::
  397. (Optional, object)
  398. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization]
  399. +
  400. .Properties of tokenization
  401. [%collapsible%open]
  402. ======
  403. `bert`::::
  404. (Optional, object)
  405. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization-bert]
  406. +
  407. .Properties of bert
  408. [%collapsible%open]
  409. =======
  410. `do_lower_case`::::
  411. (Optional, boolean)
  412. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization-bert-do-lower-case]
  413. `max_sequence_length`::::
  414. (Optional, integer)
  415. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization-bert-max-sequence-length]
  416. `with_special_tokens`::::
  417. (Optional, boolean)
  418. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization-bert-with-special-tokens]
  419. =======
  420. ======
  421. =====
  422. `pass_through`:::
  423. (Optional, object)
  424. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-pass-through]
  425. +
  426. .Properties of pass_through inference
  427. [%collapsible%open]
  428. =====
  429. `tokenization`::::
  430. (Optional, object)
  431. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization]
  432. +
  433. .Properties of tokenization
  434. [%collapsible%open]
  435. ======
  436. `bert`::::
  437. (Optional, object)
  438. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization-bert]
  439. +
  440. .Properties of bert
  441. [%collapsible%open]
  442. =======
  443. `do_lower_case`::::
  444. (Optional, boolean)
  445. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization-bert-do-lower-case]
  446. `max_sequence_length`::::
  447. (Optional, integer)
  448. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization-bert-max-sequence-length]
  449. `with_special_tokens`::::
  450. (Optional, boolean)
  451. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization-bert-with-special-tokens]
  452. =======
  453. ======
  454. =====
  455. `regression`:::
  456. (Optional, object)
  457. Regression configuration for inference.
  458. +
  459. .Properties of regression inference
  460. [%collapsible%open]
  461. =====
  462. `num_top_feature_importance_values`::::
  463. (Optional, integer)
  464. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-regression-num-top-feature-importance-values]
  465. `results_field`::::
  466. (Optional, string)
  467. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-results-field]
  468. =====
  469. `text_classification`:::
  470. (Optional, object)
  471. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-text-classification]
  472. +
  473. .Properties of text_classification inference
  474. [%collapsible%open]
  475. =====
  476. `classification_labels`::::
  477. (Optional, string) An array of classification labels.
  478. `num_top_classes`::::
  479. (Optional, integer)
  480. Specifies the number of top class predictions to return. Defaults to all classes (-1).
  481. `tokenization`::::
  482. (Optional, object)
  483. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization]
  484. +
  485. .Properties of tokenization
  486. [%collapsible%open]
  487. ======
  488. `bert`::::
  489. (Optional, object)
  490. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization-bert]
  491. +
  492. .Properties of bert
  493. [%collapsible%open]
  494. =======
  495. `do_lower_case`::::
  496. (Optional, boolean)
  497. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization-bert-do-lower-case]
  498. `max_sequence_length`::::
  499. (Optional, integer)
  500. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization-bert-max-sequence-length]
  501. `with_special_tokens`::::
  502. (Optional, boolean)
  503. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization-bert-with-special-tokens]
  504. =======
  505. ======
  506. =====
  507. `text_embedding`:::
  508. (Object, optional)
  509. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-text-embedding]
  510. +
  511. .Properties of text_embedding inference
  512. [%collapsible%open]
  513. =====
  514. `tokenization`::::
  515. (Optional, object)
  516. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization]
  517. +
  518. .Properties of tokenization
  519. [%collapsible%open]
  520. ======
  521. `bert`::::
  522. (Optional, object)
  523. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization-bert]
  524. +
  525. .Properties of bert
  526. [%collapsible%open]
  527. =======
  528. `do_lower_case`::::
  529. (Optional, boolean)
  530. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization-bert-do-lower-case]
  531. `max_sequence_length`::::
  532. (Optional, integer)
  533. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization-bert-max-sequence-length]
  534. `with_special_tokens`::::
  535. (Optional, boolean)
  536. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-nlp-tokenization-bert-with-special-tokens]
  537. =======
  538. ======
  539. =====
  540. ====
  541. //End of inference_config
  542. //Begin input
  543. `input`::
  544. (Required, object)
  545. The input field names for the model definition.
  546. +
  547. .Properties of `input`
  548. [%collapsible%open]
  549. ====
  550. `field_names`:::
  551. (Required, string)
  552. An array of input field names for the model.
  553. ====
  554. //End input
  555. // Begin location
  556. `location`::
  557. (Optional, object)
  558. The model definition location. If the `definition` or `compressed_definition`
  559. are not specified, the `location` is required.
  560. +
  561. .Properties of `location`
  562. [%collapsible%open]
  563. ====
  564. `index`:::
  565. (Required, object)
  566. Indicates that the model definition is stored in an index. This object must be
  567. empty as the index for storing model definitions is configured automatically.
  568. ====
  569. // End location
  570. `metadata`::
  571. (Optional, object)
  572. An object map that contains metadata about the model.
  573. `model_type`::
  574. (Optional, string)
  575. The created model type. By default the model type is `tree_ensemble`.
  576. Appropriate types are:
  577. +
  578. --
  579. * `tree_ensemble`: The model definition is an ensemble model of decision trees.
  580. * `lang_ident`: A special type reserved for language identification models.
  581. * `pytorch`: The stored definition is a PyTorch (specifically a TorchScript) model. Currently only
  582. NLP models are supported.
  583. --
  584. `tags`::
  585. (Optional, string)
  586. An array of tags to organize the model.
  587. [[ml-put-trained-models-example]]
  588. == {api-examples-title}
  589. [[ml-put-trained-models-preprocessor-example]]
  590. === Preprocessor examples
  591. The example below shows a `frequency_encoding` preprocessor object:
  592. [source,js]
  593. ----------------------------------
  594. {
  595. "frequency_encoding":{
  596. "field":"FlightDelayType",
  597. "feature_name":"FlightDelayType_frequency",
  598. "frequency_map":{
  599. "Carrier Delay":0.6007414737092798,
  600. "NAS Delay":0.6007414737092798,
  601. "Weather Delay":0.024573576178086153,
  602. "Security Delay":0.02476631010889467,
  603. "No Delay":0.6007414737092798,
  604. "Late Aircraft Delay":0.6007414737092798
  605. }
  606. }
  607. }
  608. ----------------------------------
  609. //NOTCONSOLE
  610. The next example shows a `one_hot_encoding` preprocessor object:
  611. [source,js]
  612. ----------------------------------
  613. {
  614. "one_hot_encoding":{
  615. "field":"FlightDelayType",
  616. "hot_map":{
  617. "Carrier Delay":"FlightDelayType_Carrier Delay",
  618. "NAS Delay":"FlightDelayType_NAS Delay",
  619. "No Delay":"FlightDelayType_No Delay",
  620. "Late Aircraft Delay":"FlightDelayType_Late Aircraft Delay"
  621. }
  622. }
  623. }
  624. ----------------------------------
  625. //NOTCONSOLE
  626. This example shows a `target_mean_encoding` preprocessor object:
  627. [source,js]
  628. ----------------------------------
  629. {
  630. "target_mean_encoding":{
  631. "field":"FlightDelayType",
  632. "feature_name":"FlightDelayType_targetmean",
  633. "target_map":{
  634. "Carrier Delay":39.97465788139886,
  635. "NAS Delay":39.97465788139886,
  636. "Security Delay":203.171206225681,
  637. "Weather Delay":187.64705882352948,
  638. "No Delay":39.97465788139886,
  639. "Late Aircraft Delay":39.97465788139886
  640. },
  641. "default_value":158.17995752420433
  642. }
  643. }
  644. ----------------------------------
  645. //NOTCONSOLE
  646. [[ml-put-trained-models-model-example]]
  647. === Model examples
  648. The first example shows a `trained_model` object:
  649. [source,js]
  650. ----------------------------------
  651. {
  652. "tree":{
  653. "feature_names":[
  654. "DistanceKilometers",
  655. "FlightTimeMin",
  656. "FlightDelayType_NAS Delay",
  657. "Origin_targetmean",
  658. "DestRegion_targetmean",
  659. "DestCityName_targetmean",
  660. "OriginAirportID_targetmean",
  661. "OriginCityName_frequency",
  662. "DistanceMiles",
  663. "FlightDelayType_Late Aircraft Delay"
  664. ],
  665. "tree_structure":[
  666. {
  667. "decision_type":"lt",
  668. "threshold":9069.33437193022,
  669. "split_feature":0,
  670. "split_gain":4112.094574306927,
  671. "node_index":0,
  672. "default_left":true,
  673. "left_child":1,
  674. "right_child":2
  675. },
  676. ...
  677. {
  678. "node_index":9,
  679. "leaf_value":-27.68987349695448
  680. },
  681. ...
  682. ],
  683. "target_type":"regression"
  684. }
  685. }
  686. ----------------------------------
  687. //NOTCONSOLE
  688. The following example shows an `ensemble` model object:
  689. [source,js]
  690. ----------------------------------
  691. "ensemble":{
  692. "feature_names":[
  693. ...
  694. ],
  695. "trained_models":[
  696. {
  697. "tree":{
  698. "feature_names":[],
  699. "tree_structure":[
  700. {
  701. "decision_type":"lte",
  702. "node_index":0,
  703. "leaf_value":47.64069875778043,
  704. "default_left":false
  705. }
  706. ],
  707. "target_type":"regression"
  708. }
  709. },
  710. ...
  711. ],
  712. "aggregate_output":{
  713. "weighted_sum":{
  714. "weights":[
  715. ...
  716. ]
  717. }
  718. },
  719. "target_type":"regression"
  720. }
  721. ----------------------------------
  722. //NOTCONSOLE
  723. [[ml-put-trained-models-aggregated-output-example]]
  724. === Aggregated output example
  725. Example of a `logistic_regression` object:
  726. [source,js]
  727. ----------------------------------
  728. "aggregate_output" : {
  729. "logistic_regression" : {
  730. "weights" : [2.0, 1.0, .5, -1.0, 5.0, 1.0, 1.0]
  731. }
  732. }
  733. ----------------------------------
  734. //NOTCONSOLE
  735. Example of a `weighted_sum` object:
  736. [source,js]
  737. ----------------------------------
  738. "aggregate_output" : {
  739. "weighted_sum" : {
  740. "weights" : [1.0, -1.0, .5, 1.0, 5.0]
  741. }
  742. }
  743. ----------------------------------
  744. //NOTCONSOLE
  745. Example of a `weighted_mode` object:
  746. [source,js]
  747. ----------------------------------
  748. "aggregate_output" : {
  749. "weighted_mode" : {
  750. "weights" : [1.0, 1.0, 1.0, 1.0, 1.0]
  751. }
  752. }
  753. ----------------------------------
  754. //NOTCONSOLE
  755. Example of an `exponent` object:
  756. [source,js]
  757. ----------------------------------
  758. "aggregate_output" : {
  759. "exponent" : {
  760. "weights" : [1.0, 1.0, 1.0, 1.0, 1.0]
  761. }
  762. }
  763. ----------------------------------
  764. //NOTCONSOLE
  765. [[ml-put-trained-models-json-schema]]
  766. === Trained models JSON schema
  767. For the full JSON schema of trained models,
  768. https://github.com/elastic/ml-json-schemas[click here].