[DOCS] Makes PUT inference API docs collapsible (#54653)

Co-authored-by: lcawl <lcawley@elastic.co>
This commit is contained in:
István Zoltán Szabó 2020-04-03 09:45:42 +02:00
parent 11afead21e
commit d025b90cd1
3 changed files with 272 additions and 222 deletions

View File

@ -42,7 +42,7 @@ Regression configuration for inference.
`results_field`:: `results_field`::
(Optional, string) (Optional, string)
include::{docdir}/ml/ml-shared.asciidoc[tag=inference-config-regression-results-field] include::{docdir}/ml/ml-shared.asciidoc[tag=inference-config-results-field]
`num_top_feature_importance_values`:: `num_top_feature_importance_values`::
(Optional, integer) (Optional, integer)
@ -65,7 +65,7 @@ include::{docdir}/ml/ml-shared.asciidoc[tag=inference-config-classification-num-
`results_field`:: `results_field`::
(Optional, string) (Optional, string)
include::{docdir}/ml/ml-shared.asciidoc[tag=inference-config-classification-results-field] include::{docdir}/ml/ml-shared.asciidoc[tag=inference-config-results-field]
`top_classes_results_field`:: `top_classes_results_field`::
(Optional, string) (Optional, string)

View File

@ -61,15 +61,272 @@ The {infer} definition for the model. If `definition` is specified, then
.Properties of `definition` .Properties of `definition`
[%collapsible%open] [%collapsible%open]
==== ====
`preprocessors`::: //Begin preprocessors
`preprocessors`::
(Optional, object) (Optional, object)
Collection of preprocessors. See <<ml-put-inference-preprocessors>> for the full Collection of preprocessors. See <<ml-put-inference-preprocessor-example>>.
list of available preprocessors. +
.Properties of `preprocessors`
`trained_model`::: [%collapsible%open]
=====
//Begin frequency encoding
`frequency_encoding`::
(Required, object) (Required, object)
The definition of the trained model. See <<ml-put-inference-trained-model>> for Defines a frequency encoding for a field.
details. +
.Properties of `frequency_encoding`
[%collapsible%open]
======
`feature_name`::
(Required, string)
The name of the resulting feature.
`field`::
(Required, string)
The field name to encode.
`frequency_map`::
(Required, object map of string:double)
Object that maps the field value to the frequency encoded value.
======
//End frequency encoding
//Begin one hot encoding
`one_hot_encoding`::
(Required, object)
Defines a one hot encoding map for a field.
+
.Properties of `one_hot_encoding`
[%collapsible%open]
======
`field`::
(Required, string)
The field name to encode.
`hot_map`::
(Required, object map of strings)
String map of "field_value: one_hot_column_name".
======
//End one hot encoding
//Begin target mean encoding
`target_mean_encoding`::
(Required, object)
Defines a target mean encoding for a field.
+
.Properties of `target_mean_encoding`
[%collapsible%open]
======
`default_value`:::
(Required, double)
The feature value if the field value is not in the `target_map`.
`feature_name`:::
(Required, string)
The name of the resulting feature.
`field`:::
(Required, string)
The field name to encode.
`target_map`:::
(Required, object map of string:double)
Object that maps the field value to the target mean value.
======
//End target mean encoding
=====
//End preprocessors
//Begin trained model
`trained_model`::
(Required, object)
The definition of the trained model.
+
.Properties of `trained_model`
[%collapsible%open]
=====
//Begin tree
`tree`::
(Required, object)
The definition for a binary decision tree.
+
.Properties of `tree`
[%collapsible%open]
======
`classification_labels`:::
(Optional, string) An array of classification labels (used for
`classification`).
`feature_names`:::
(Required, string)
Features expected by the tree, in their expected order.
`target_type`:::
(Required, string)
String indicating the model target type; `regression` or `classification`.
`tree_structure`:::
(Required, object)
An array of `tree_node` objects. The nodes must be in ordinal order by their
`tree_node.node_index` value.
======
//End tree
//Begin tree node
`tree_node`::
(Required, object)
The definition of a node in a tree.
+
--
There are two major types of nodes: leaf nodes and not-leaf nodes.
* Leaf nodes only need `node_index` and `leaf_value` defined.
* All other nodes need `split_feature`, `left_child`, `right_child`,
`threshold`, `decision_type`, and `default_left` defined.
--
+
.Properties of `tree_node`
[%collapsible%open]
======
`decision_type`::
(Optional, string)
Indicates the positive value (in other words, when to choose the left node)
decision type. Supported `lt`, `lte`, `gt`, `gte`. Defaults to `lte`.
`default_left`::
(Optional, boolean)
Indicates whether to default to the left when the feature is missing. Defaults
to `true`.
`leaf_value`::
(Optional, double)
The leaf value of the of the node, if the value is a leaf (in other words, no
children).
`left_child`::
(Optional, integer)
The index of the left child.
`node_index`::
(Integer)
The index of the current node.
`right_child`::
(Optional, integer)
The index of the right child.
`split_feature`::
(Optional, integer)
The index of the feature value in the feature array.
`split_gain`::
(Optional, double) The information gain from the split.
`threshold`::
(Optional, double)
The decision threshold with which to compare the feature value.
======
//End tree node
//Begin ensemble
`ensemble`::
(Optional, object)
The definition for an ensemble model. See <<ml-put-inference-model-example>>.
+
.Properties of `ensemble`
[%collapsible%open]
======
//Begin aggregate output
`aggregate_output`::
(Required, object)
An aggregated output object that defines how to aggregate the outputs of the
`trained_models`. Supported objects are `weighted_mode`, `weighted_sum`, and
`logistic_regression`. See <<ml-put-inference-aggregated-output-example>>.
+
.Properties of `aggregate_output`
[%collapsible%open]
=======
//Begin logistic regression
`logistic_regression`::
(Optional, object)
This `aggregated_output` type works with binary classification (classification
for values [0, 1]). It multiplies the outputs (in the case of the `ensemble`
model, the inference model values) by the supplied `weights`. The resulting
vector is summed and passed to a
https://en.wikipedia.org/wiki/Sigmoid_function[`sigmoid` function]. The result
of the `sigmoid` function is considered the probability of class 1 (`P_1`),
consequently, the probability of class 0 is `1 - P_1`. The class with the
highest probability (either 0 or 1) is then returned. For more information about
logistic regression, see
https://en.wikipedia.org/wiki/Logistic_regression[this wiki article].
+
.Properties of `logistic_regression`
[%collapsible%open]
========
`weights`:::
(Required, double)
The weights to multiply by the input values (the inference values of the trained
models).
========
//End logistic regression
//Begin weighted sum
`weighted_sum`::
(Optional, object)
This `aggregated_output` type works with regression. The weighted sum of the
input values.
+
.Properties of `weighted_sum`
[%collapsible%open]
========
`weights`:::
(Required, double)
The weights to multiply by the input values (the inference values of the trained
models).
========
//End weighted sum
//Begin weighted mode
`weighted_mode`::
(Optional, object)
This `aggregated_output` type works with regression or classification. It takes
a weighted vote of the input values. The most common input value (taking the
weights into account) is returned.
+
.Properties of `weighted_mode`
[%collapsible%open]
========
`weights`:::
(Required, double)
The weights to multiply by the input values (the inference values of the trained
models).
========
//End weighted mode
=======
//End aggregate output
`classification_labels`::
(Optional, string)
An array of classification labels.
`feature_names`::
(Optional, string)
Features expected by the ensemble, in their expected order.
`target_type`::
(Required, string)
String indicating the model target type; `regression` or `classification.`
`trained_models`::
(Required, object)
An array of `trained_model` objects. Supported trained models are `tree` and
`ensemble`.
======
//End ensemble
=====
//End trained model
==== ====
//End definition //End definition
@ -100,7 +357,7 @@ include::{docdir}/ml/ml-shared.asciidoc[tag=inference-config-regression-num-top-
`results_field`:::: `results_field`::::
(Optional, string) (Optional, string)
include::{docdir}/ml/ml-shared.asciidoc[tag=inference-config-regression-results-field] include::{docdir}/ml/ml-shared.asciidoc[tag=inference-config-results-field]
===== =====
`classification`::: `classification`:::
@ -120,7 +377,7 @@ include::{docdir}/ml/ml-shared.asciidoc[tag=inference-config-classification-num-
`results_field`:::: `results_field`::::
(Optional, string) (Optional, string)
include::{docdir}/ml/ml-shared.asciidoc[tag=inference-config-classification-results-field] include::{docdir}/ml/ml-shared.asciidoc[tag=inference-config-results-field]
`top_classes_results_field`:::: `top_classes_results_field`::::
(Optional, string) (Optional, string)
@ -151,208 +408,6 @@ An object map that contains metadata about the model.
(Optional, string) (Optional, string)
An array of tags to organize the model. An array of tags to organize the model.
[[ml-put-inference-preprocessors]]
===== {infer-cap} preprocessor definitions
`frequency_encoding`::
(Required, object)
Defines a frequency encoding for a field.
`frequency_encoding`.`field`:::
(Required, string)
The field name to encode.
`frequency_encoding`.`feature_name`:::
(Required, string)
The name of the resulting feature.
`frequency_encoding`.`frequency_map`:::
(Required, object map of string:double)
Object that maps the field value to the frequency encoded value.
`one_hot_encoding`::
(Required, object)
Defines a one hot encoding map for a field.
`one_hot_encoding`.`field`:::
(Required, string)
The field name to encode.
`one_hot_encoding`.`hot_map`:::
(Required, object map of strings)
String map of "field_value: one_hot_column_name".
`target_mean_encoding`::
(Required, object)
Defines a target mean encoding for a field.
`target_mean_encoding`.`field`:::
(Required, string)
The field name to encode.
`target_mean_encoding`.`feature_name`:::
(Required, string)
The name of the resulting feature.
`target_mean_encoding`.`target_map`:::
(Required, object map of string:double)
Object that maps the field value to the target mean value.
`target_mean_encoding`.`default_value`:::
(Required, double)
The feature value if the field value is not in the `target_map`.
See <<ml-put-inference-preprocessor-example>> for more details.
[[ml-put-inference-trained-model]]
===== {infer-cap} trained model definitions
`tree`::
(Required, object)
The definition for a binary decision tree.
`tree`.`feature_names`:::
(Required, string)
Features expected by the tree, in their expected order.
`tree`.`tree_structure`:::
(Required, object)
An array of `tree_node` objects. The nodes must be in ordinal order by their
`tree_node.node_index` value.
`tree`.`classification_labels`:::
(Optional, string) An array of classification labels (used for
`classification`).
`tree`.`target_type`:::
(Required, string)
String indicating the model target type; `regression` or `classification`.
There are two major types of nodes: leaf nodes and not-leaf nodes.
* Leaf nodes only need `node_index` and `leaf_value` defined.
* All other nodes need `split_feature`, `left_child`, `right_child`,
`threshold`, `decision_type`, and `default_left` defined.
`tree_node`::
(Required, object)
The definition of a node in a tree.
`tree_node`.`decision_type`:::
(Optional, string)
Indicates the positive value (in other words, when to choose the left node)
decision type. Supported `lt`, `lte`, `gt`, `gte`. Defaults to `lte`.
`tree_node`.`threshold`:::
(Optional, double)
The decision threshold with which to compare the feature value.
`tree_node`.`left_child`:::
(Optional, integer)
The index of the left child.
`tree_node`.`right_child`:::
(Optional, integer)
The index of the right child.
`tree_node`.`default_left`:::
(Optional, boolean)
Indicates whether to default to the left when the feature is missing. Defaults
to `true`.
`tree_node`.`split_feature`:::
(Optional, integer)
The index of the feature value in the feature array.
`tree_node`.`node_index`:::
(Integer)
The index of the current node.
`tree_node`.`split_gain`:::
(Optional, double) The information gain from the split.
`tree_node`.`leaf_value`:::
(Optional, double)
The leaf value of the of the node, if the value is a leaf (in other words, no
children).
`ensemble`::
(Optional, object)
The definition for an ensemble model.
`ensemble`.`feature_names`:::
(Optional, string)
Features expected by the ensemble, in their expected order.
`ensemble`.`trained_models`:::
(Required, object)
An array of `trained_model` objects. Supported trained models are `tree` and
`ensemble`.
`ensemble`.`classification_labels`:::
(Optional, string)
An array of classification labels.
`ensemble`.`target_type`:::
(Required, string)
String indicating the model target type; `regression` or `classification.`
`ensemble`.`aggregate_output`:::
(Required, object)
An aggregated output object that defines how to aggregate the outputs of the
`trained_models`. Supported objects are `weighted_mode`, `weighted_sum`, and
`logistic_regression`.
See <<ml-put-inference-model-example>> for more details.
[[ml-put-inference-aggregated-output]]
===== Aggregated output types
`logistic_regression`::
(Optional, object)
This `aggregated_output` type works with binary classification (classification
for values [0, 1]). It multiplies the outputs (in the case of the `ensemble`
model, the inference model values) by the supplied `weights`. The resulting
vector is summed and passed to a
https://en.wikipedia.org/wiki/Sigmoid_function[`sigmoid` function]. The result
of the `sigmoid` function is considered the probability of class 1 (`P_1`),
consequently, the probability of class 0 is `1 - P_1`. The class with the
highest probability (either 0 or 1) is then returned. For more information about
logistic regression, see
https://en.wikipedia.org/wiki/Logistic_regression[this wiki article].
`logistic_regression`.`weights`:::
(Required, double)
The weights to multiply by the input values (the inference values of the trained
models).
`weighted_sum`::
(Optional, object)
This `aggregated_output` type works with regression. The weighted sum of the
input values.
`weighted_sum`.`weights`:::
(Required, double)
The weights to multiply by the input values (the inference values of the trained
models).
`weighted_mode`::
(Optional, object)
This `aggregated_output` type works with regression or classification. It takes
a weighted vote of the input values. The most common input value (taking the
weights into account) is returned.
`weighted_mode`.`weights`:::
(Required, double)
The weights to multiply by the input values (the inference values of the trained
models).
See <<ml-put-inference-aggregated-output-example>> for more details.
[[ml-put-inference-example]] [[ml-put-inference-example]]
==== {api-examples-title} ==== {api-examples-title}

View File

@ -1224,11 +1224,6 @@ importance] values per document. By default, it is zero and no feature
importance calculation occurs. importance calculation occurs.
end::inference-config-classification-num-top-feature-importance-values[] end::inference-config-classification-num-top-feature-importance-values[]
tag::inference-config-classification-results-field[]
The field that is added to incoming documents to contain the inference
prediction. Defaults to `predicted_value`.
end::inference-config-classification-results-field[]
tag::inference-config-classification-top-classes-results-field[] tag::inference-config-classification-top-classes-results-field[]
Specifies the field to which the top classes are written. Defaults to Specifies the field to which the top classes are written. Defaults to
`top_classes`. `top_classes`.
@ -1241,10 +1236,10 @@ importance] values per document. By default, it is zero and no feature importanc
calculation occurs. calculation occurs.
end::inference-config-regression-num-top-feature-importance-values[] end::inference-config-regression-num-top-feature-importance-values[]
tag::inference-config-regression-results-field[] tag::inference-config-results-field[]
Specifies the field to which the inference prediction is written. Defaults to The field that is added to incoming documents to contain the inference
`predicted_value`. prediction. Defaults to `predicted_value`.
end::inference-config-regression-results-field[] end::inference-config-results-field[]
tag::influencers[] tag::influencers[]
A comma separated list of influencer field names. Typically these can be the by, A comma separated list of influencer field names. Typically these can be the by,