Skip to main content
Version: 6.1

predict

Description

Performs prediction using a trained model and input data. The model must first be trained using the train 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 does not depend on the execution mechanism.

Syntax

... | predict <algorithm> model_id="<model_id>" [fields="<field>[,<field>]"]

Required arguments

info

The supported algorithms are available in the repository documentation. When using sm-ml-service, the supported algorithms are determined by the service.

ParameterSyntaxDescription
<algorithm><algorithm_name>Name of the prediction algorithm. When using sm-ml-service, the algorithm is determined from the stored model.
model_idmodel_id="<model_id>"Identifier of the trained model returned by the train command.

Optional arguments

ParameterSyntaxDefaultDescription
fieldsfields="<field>[,<field>]"all fieldsList of input fields to pass to the prediction operation. If omitted, all fields in the current row set are passed.

Using sm-ml-service

When the sme.ml.enabled setting is enabled, predictions are 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. The service looks up the model by the name specified in model_id
  2. The algorithm is determined from the stored model. The <algorithm> value specified in the command is ignored
  3. If a model with the specified name is not found or is not ready yet, the command fails with a query execution error
  4. The prediction result rows are returned as the command output

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, prediction is performed by default on those fields that remain in the input stream after peval and 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)
| fields operation_type_ssh, operation_type_1c, operation_type_view_dashboard, operation_type_gitlab
| predict kmeans model_id="4wedvml"

Example 2

In this example, the fields for prediction are passed explicitly through the fields parameter.

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)
| predict kmeans model_id="4wedvml" fields="operation_type_ssh, operation_type_1c, operation_type_view_dashboard, operation_type_gitlab"