All Products
Search
Document Center

Platform For AI:Model prediction

Last Updated:Jan 05, 2023

This topic describes how to deploy a model in a production environment after you use Machine Learning Designer to train the model.

Background information

After you deploy a model, you can use the model to perform predictions based on new data. Prediction services can be classified into offline prediction services and online prediction services based on the timeliness requirements of the new data that is used to perform predictions. Machine Learning Designer supports both types of prediction services.

  • Offline prediction

    In Machine Learning Designer, you can use prediction components to perform batch predictions. You can also submit workflows to DataWorks to periodically schedule the workflows.

  • Online prediction

    You can deploy Predictive Model Markup Language (PMML), AlinkModel, or XGBoost models as online services after you use Machine Learning Designer to train these models. For specific parameter server (PS) models, you need to manually deploy them as online services.

    The output port of model training components in Machine Learning Designer can be connected to the Update EAS Service component to update online services. You can also submit workflows to DataWorks to periodically run the workflows.

Offline prediction

Perform batch predictions in the development environment

Machine Learning Designer provides a variety of prediction components to support different algorithms and scenarios. You can directly drag and drop these components in the canvas.

  • You can directly use the model training and prediction components displayed in the left-side component pane to train a model and then use the model to perform batch predictions.

    image
  • If no prediction component is available for the algorithm that you want to use, you can use the general-purpose prediction component to perform batch predictions after you train the model. image

    Important

    The general-purpose prediction component supports only OfflineModel models. It does not support PMML models.

  • If you already have a trained model, you can use the Read MaxCompute Offline Model or Import MaxCompute Offline Model component together with the Read File Data component to import the model. Then, connect to the prediction component to deploy the model and perform predictions.

Periodically schedule an offline prediction workflow

After you verify an offline prediction workflow, you can submit the workflow to DataWorks to periodically schedule the workflow. For more information, see Use DataWorks to periodically schedule an offline Designer workflow.

If your workspace is in DataWorks standard mode, the development environment and production environment maintain MaxCompute data separately. Therefore, before you periodically schedule an offline prediction workflow, you need to synchronize the model that is trained offline to the production environment. You can use one of the following methods to synchronize the model:

  • Use the Copy MaxCompute Offline Model and Read MaxCompute Offline Model components

    Use the Copy MaxCompute Offline Model component to replicate the trained OfflineModel model to the production environment, and then use the Read MaxCompute Offline Model component in the periodically scheduled workflow to read the model in the production environment.

    The system needs to write MaxCompute data in the production environment when replicating the model. Therefore, you need to use the workspace administrator account or production account to perform the replicate operation. For more information, see Permissions.

  • (Recommended) Use the Model Export and Import MaxCompute Offline Model components

    Use the Model Export component to export the trained OfflineModel model to Object Storage Service (OSS), and then use the Export MaxCompute Offline Model component in the periodically scheduled workflow to import the model from OSS.

Online prediction

One-click deployment

After you train a model and verify the model offline, you can choose Model Deployment > Deploy in EAS above the canvas of Machine Learning Designer. Then, the system automatically detects the trained model and matches the model with a processor. You can then follow the instructions to deploy the model in Elastic Algorithm Service (EAS). For more information, see Deploy models with one click by using Machine Learning Designer.

Algorithms that support one-click deployment

Component

Generated model format

Matching EAS processor

Description

Logistic Regression for Binary Classification

PMML

PMML

Before you train a model, you need to select Whether to Generate PMML on the Fields Setting tab of the component.

GBDT Binary Classification

PMML

PMML

Before you train a model, you need to select Whether to Generate PMML on the Fields Setting tab of the component.

Linear SVM

PMML

PMML

Before you train a model, you need to select Whether to Generate PMML on the Fields Setting tab of the component.

Logistic Regression for Multiclass Classification

PMML

PMML

Before you train a model, you need to select Whether to Generate PMML on the Fields Setting tab of the component.

Random Forest

PMML

PMML

Before you train a model, you need to select Whether to Generate PMML on the Fields Setting tab of the component.

Naive Bayes

PMML

PMML

Before you train a model, you need to select Whether to Generate PMML on the Fields Setting tab of the component.

K-means Clustering

PMML

PMML

Before you train a model, you need to select Whether to Generate PMML on the Fields Setting tab of the component.

GBDT Regression

PMML

PMML

Before you train a model, you need to select Whether to Generate PMML on the Fields Setting tab of the component.

Linear Regression

PMML

PMML

Before you train a model, you need to select Whether to Generate PMML on the Fields Setting tab of the component.

Scorecard training

PMML

PMML

Before you train a model, you need to select Whether to Generate PMML on the Fields Setting tab of the component.

PyAlink Script

AlinkModel

Alink

For more information, see PyAlink Script.

XGboost Train

XGBoost

XGBoost

For more information, see XGboost Train.

For algorithm components that need to generate PMML models, select Whether to Generate PMML on the Fields Setting tab of the components. After you select the option, you need to rerun the node (component). image

Algorithms that require you to manually deploy the model

Some algorithm components do not support one-click deployment. After you use these algorithm components to train models, you need to use the Model Export component to assemble the model and export the model to OSS. Then, you need to manually deploy the model. The following table describes the components that do not support one-click deployment.

Component

Generated model format

Matching EAS processor

Manual deployment procedure

PS-SMART Binary Classification Training, PS-SMART Multiclass Classification, and PS-SMART Regression

PS

PS algorithm

Connect the output port of the component to the Model Export component.

For more information about how to manually deploy the model after you export the model to an OSS bucket, see Upload and deploy the model.

FAQ

What do I do if some nodes are dimmed after you perform a one-click deployment?

Select Whether to Generate PMML on the Fields Setting tab of the algorithm component and rerun the corresponding node.

image

Periodically update online model services

Machine Learning Designer provides the Update EAS Service component to allow you to periodically update your model services.

The input port of the Update EAS Service component can be connected to the path of a model that is stored in an OSS bucket. For example, you can use PMML models generated by machine learning algorithms or models generated by vision, text processing, and XGBoost training algorithms. You need to only connect the output port of the preceding components to the input port of the Update EAS Service component. Set EAS Service Name on the Parameters Settings tab of the Update EAS Service component to the name of an EAS service that runs as expected. If you want to configure other parameters, refer to EAS deployment requirements and specify the parameters in the EAS service description json editor. In most cases, you do not need to specify other parameters.

image

If you want to periodically schedule the model training and service update tasks, refer to Use DataWorks to periodically schedule an offline Designer workflow, submit the preceding workflow to DataWorks, and periodically schedule the workflow.