train
Description
Performs model training on input data. The result of the command is the model ID, which can be used in the predict command.
The command supports two execution mechanisms:
- built-in storage mechanisms — used by default
- the
sm-ml-serviceservice — used when thesme.ml.enabledsystem setting is enabled
The command syntax is the same for both execution mechanisms.
Syntax
... | train <algorithm> [model_id="<model_id>"] [overwrite=true] [fields="<field>[,<field>]"] [<params>]
Required arguments
The supported algorithms for training and the parameters for them are available in the repository documentation. When using sm-ml-service, the supported algorithms and parameters are determined by the service.
| Parameter | Syntax | Description |
|---|---|---|
< algorithm> | <algorithm_name> | The name of the algorithm used to train the model. |
Optional arguments
| Parameter | Syntax | Default | Description |
|---|---|---|---|
model_id | model_id="<model_id>" | Identifier under which the model is stored in the system. If omitted, the identifier is generated automatically and returned in the command output. | |
overwrite | overwrite=true | Specifies whether the command should overwrite an existing model with the specified identifier. | |
fields | fields="<field>[,<field>]" | all fields | List of input fields passed to model training. If omitted, all fields in the current row set are passed. |
<params> | <param> = <value> [<param> = <value>] | Algorithm parameters. They are passed to the execution mechanism as-is. |
Using sm-ml-service
When the sme.ml.enabled setting is enabled, training is performed by sm-ml-service. The service address is configured using the sme.ml.service_url and sme.ml.service_port settings:
- The input data—the fields specified in
fields, or all fields in the current row set—is sent to the service together with the algorithm and command parameters - The
model_idvalue is used as the model name in the service. If the identifier is omitted, the service generates a name automatically. The generated name is returned in the command output and can be referenced by thepredictcommand - Service errors are returned as query execution errors
Requests to the service require authentication. The username is configured using the sme.ml.user setting. The service request timeout is configured using the sme.ml.timeout setting.
System settings
The settings are stored in _cluster/settings. The following table lists the sm-ml-service integration settings and their default values.
| Setting | Description | Default value |
|---|---|---|
sme.ml.enabled | Enables command execution through sm-ml-service. When disabled, the command uses the built-in storage mechanisms. | false |
sme.ml.service_url | Base URL of sm-ml-service. | |
sme.ml.service_port | Port used by sm-ml-service. | |
sme.ml.user | Username used to authenticate requests to the service. | |
sme.ml.timeout | Service request timeout, in milliseconds. | 300000 |
Examples
Example 1
In this example, the kmeans model is trained on pre-prepared binary features without explicitly specifying model_id.
source user_operations_train
| peval operation_type_ssh=if(operation_type.keyword == "ssh_connect", 1, 0), operation_type_1c=if(operation_type.keyword == "1c_connect", 1, 0), operation_type_view_dashboard=if(operation_type.keyword == "view_dashboard", 1, 0), operation_type_gitlab=if(operation_type.keyword == "gitlab_connect", 1, 0)
| fields operation_type_ssh, operation_type_1c, operation_type_view_dashboard, operation_type_gitlab
| train kmeans centroids=4 distance_type=L1
Example 2
In this example, the command trains the same model but additionally saves it under the explicit identifier operations_type_model and passes the field list through fields.
source user_operations_train
| peval operation_type_ssh=if(operation_type.keyword == "ssh_connect", 1, 0), operation_type_1c=if(operation_type.keyword == "1c_connect", 1, 0), operation_type_view_dashboard=if(operation_type.keyword == "view_dashboard", 1, 0), operation_type_gitlab=if(operation_type.keyword == "gitlab_connect", 1, 0)
| train kmeans centroids=4 distance_type=L1 fields="operation_type_ssh, operation_type_1c, operation_type_view_dashboard, operation_type_gitlab"