Skip to main content
Version: 8.0

Customize machine learning service

Level: advanced

The machine learning service predicts lookup values using statistical analysis methods based on historical data. For example, a history of customer communications with customer support is historical data in Creatio. Learn more: Predictive data analysis, Machine learning service (user documentation).

Stages of prediction model processing

Prediction model is the algorithm that builds predictions and enables the system to automatically make decisions based on historical data.

Processing of prediction model in Creatio includes the following stages:

  • training
  • prediction

Training

The training stage is designed for training the prediction model. Main steps of training model are as follows:

  1. Establish a session for data transfer and training.
  2. Select a portion of data for the model sequentially and upload it to the service.
  3. Send query to include a model training queue.
  4. Training engine processes the queue for model training, trains the model and saves its parameters to the local database.
  5. Creatio queries the service to get the model status occasionally. Once the model status is set to "Done," the model is ready for prediction.

Classes that implement machine learning service call and create instances of each other through the Terrasoft.Core.Factories.ClassFactory container. To implement custom business logic for training model, implement the appropriate interface listed in the table below and bind the interface in your own implementation.

Interface

Description

IMLModelTrainerJob

Change the set of models for training.

IMLModelTrainer

Load data for training and update the status of models.

IMLServiceProxy

Execute queries to arbitrary predictive services.

Prediction

The prediction task is performed through a call to the cloud service, indicating the ID of the model instance and data for the prediction. The result of the service operation is a set of values with prediction probabilities that the MLPrediction database table stores. If the MLPrediction database table includes a prediction for a dedicated record, Creatio displays the predicted values for the field on the record page.

Creatio provides the following settings to work with the prediction service listed in the table below.

Setting

Description

"Creatio cloud services API key" (CloudServicesAPIKey code) system setting

Authenticate the Creatio instance in cloud services.

ML problem types (MLProblemType code) lookup

Address of the implemented prediction service, i. e., the lookup record that has the Service endpoint Url field populated.

ML model (MLModel code) lookup

Information about selected data for the model, the training period, the current training status, etc. For each model, the ML problem type field in the ML model (MLModel code) lookup includes a reference to the corresponding record in the ML problem types (MLProblemType code) lookup.

"Periodicity of machine learning model training job" (MLModelTrainingPeriodMinutes code) system setting

Determine the frequency of model synchronization launch.

Forecasting

Use the classes for forecasting in the following cases:

  • Predict time of creating or updating an object record on the server.
  • Predict when the record on the record page is changed.

Implement prediction on the Creatio server-side using business process. Detailed example: Implement custom prediction model.

Create data queries for the machine learning model

Use the Terrasoft.Core.DB.Select class instance to query training data or data for predicting machine learning service. The Terrasoft.Configuration.ML.QueryInterpreter interpreter imports the Terrasoft.Core.DB.Select class instance dynamically.

Important

The QueryInterpreter interpreter does not allow the use of lambda expressions.

Use the provided userConnection variable as a parameter of the Terrasoft.Core.UserConnection type in the Select constructor when building query expression. The column that has the "Id" alias, i. e., the unique ID of the target object instance, is required in the query expression. The Select expression can be complex. Use the following practices to simplify the expression:

  • Add types for the interpreter dynamically by using the RegisterConfigurationType() and RegisterType() methods provided by Terrasoft.Configuration.QueryExtensions utility class directly in the expression. For example, use the name of a constant from dynamically registered enumeration instead of using the type id directly.

    RegisterConfigurationType("ActivityConsts");
    new Select(userConnection)
    .Column("Id")
    .Column("Body")
    .From("Activity")
    .Where("TypeId")
    .IsEqual(Column.Parameter(ActivityConsts.EmailTypeUId));

    Use the Terrasoft.Configuration.QueryExtensions utility class. Learn more: QueryExtensions class.

  • Use local variables to avoid code duplication and convenient structuring. For example, the query that uses delegates repetitively.

    var monthAgo = Func.DateAddMonth(-1, Func.CurrentDateTime());

    new Select(userConnection)
    .Column("Id")
    .Column("Body")
    .From("Activity")
    .Where("StartDate")
    .IsGreater(monthAgo)
    .And("ModifiedOn")
    .IsGreater(monthAgo);

    Using local variables has the following constraints:

    • Calculate the variable statically.
    • Define the variable type via var.

See also

Predictive data analysis (user documentation)

Machine learning service (user documentation)

QueryExtensions class