Skip to main content
Version: 6.1

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-service service — used when the sme.ml.enabled system 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

info

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.

ParameterSyntaxDescription
< algorithm><algorithm_name>The name of the algorithm used to train the model.

Optional arguments

ParameterSyntaxDefaultDescription
model_idmodel_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.
overwriteoverwrite=trueSpecifies whether the command should overwrite an existing model with the specified identifier.
fieldsfields="<field>[,<field>]"all fieldsList 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:

  1. 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
  2. The model_id value 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 the predict command
  3. 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.

SettingDescriptionDefault value
sme.ml.enabledEnables command execution through sm-ml-service. When disabled, the command uses the built-in storage mechanisms.false
sme.ml.service_urlBase URL of sm-ml-service.
sme.ml.service_portPort used by sm-ml-service.
sme.ml.userUsername used to authenticate requests to the service.
sme.ml.timeoutService 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"