All Products
Search
Document Center

Platform For AI:A CTR prediction solution with offline-online consistency

Last Updated:Aug 21, 2026

This tutorial demonstrates how to train a model using the classic Avazu click-through rate (CTR) prediction dataset. You will then deploy the entire offline-validated pipeline, which runs the Normalization Prediction->One-Hot Encoding Prediction->Vector Assembler->FM Prediction process, to EAS. Reusing the same data preprocessing and feature engineering logic for both offline training and online inference ensures consistency between offline and online environments.

Prerequisites

Dataset

Avazu is a classic dataset for CTR prediction. PAI uses a subset of the Avazu dataset, which includes 200,000 samples (160,000 for training and 40,000 for prediction), to build a CTR prediction pipeline. For more information about the dataset, see Avazu. The following table describes the fields.

Name

Type

Description

id

STRING

The ad ID.

click

DOUBLE

Indicates whether the ad was clicked.

dt_year

INT

The year of the click.

dt_month

INT

The month of the click.

dt_day

INT

The day of the click.

dt_hour

INT

The hour of the click.

c1

STRING

An anonymized discrete variable.

banner_pos

INT

The position of the banner.

site_id

STRING

The site ID.

site_domain

STRING

The site domain.

site_category

STRING

The site category.

app_id

STRING

The app ID.

app_domain

STRING

The app domain.

app_category

STRING

The app category.

device_id

STRING

The device ID.

device_ip

STRING

The device IP address.

device_model

STRING

The device model.

device_type

STRING

The device type.

device_conn_type

STRING

The device connection type.

c14 - c21

DOUBLE

Eight anonymized discrete variables.

Procedure

  1. Go to the Machine Learning Designer page.

    1. Log on to the PAI console.

    2. In the left-side navigation pane, click Workspaces. On the Workspaces page, click the name of the workspace that you want to manage.

    3. In the left-side navigation pane, choose Model Training > Visualized Modeling (Designer).

  2. Build the pipeline.

    1. On the Designer page, click the Preset Templates tab.

    2. In the A CTR prediction solution with offline-online consistency section, click Create.

    3. In the Create Pipeline dialog box, configure the following parameter. You can use the default values for other parameters.

      Data Storage: Specify an OSS bucket path to store temporary data and models generated during the pipeline run.

    4. Click Confirm.

      It takes about 10 seconds to create the pipeline.

    5. In the pipeline list, double-click the A CTR prediction solution with offline-online consistency pipeline to open it on the canvas.

  3. The pipeline created from the template is shown in the following figure. image

    In this pipeline, PAI categorizes features into two types:

    • Numeric features: PAI uses a normalization algorithm to process these features.

    • Discrete features: PAI uses one-hot encoding to process these features. Finally, the pipeline assembles both feature types into a vector and uses the FM algorithm to train the model and perform inference.

  4. Run the pipeline and view the results.

    1. Click the Run icon image at the top of the canvas.

    2. After the pipeline finishes running, right-click the Binary Classification Evaluation-1 component on the canvas and select Visual Analysis from the shortcut menu. Alternatively, you can click the image.png Visual Analysis icon at the top of the canvas.

    3. In the Binary Classification Evaluation-1 dialog box, click the Indicator Data tab to view the prediction accuracy. image

  5. If the metrics meet your requirements, you can package the entire data preprocessing, feature engineering, and model prediction workflow into a pipeline model and deploy it to EAS.

    1. At the top of the canvas, click Create Pipeline Model.

    2. Select the Min Max Scaler Batch Predict-2 node. All downstream components are automatically selected. Click Next to package these components and their models into a single pipeline model.image.png

    3. In the Create Pipeline Model dialog box, confirm the model packaging information and click Next to package the model.image.png The packaging task takes about 3 to 5 minutes to complete.

    4. Deploy the model service.

      • Method 1: In the Create Pipeline Model dialog box, when the Status changes to Success, click Deploy to EAS. You are redirected to the EAS console. Configure the Service name and Resource Deployment Information, and then click Deploy. For more information, see Deploy a pipeline as an online service.

      • Method 2: If the Create Pipeline Model dialog box is closed, click View All Tasks in the upper-right corner of the canvas. In the Previous Tasks dialog box, check the task status. When the Status changes to Succeeded, perform one of the following operations:

        • In the Actions column, choose Model > Deploy and follow the on-screen instructions to deploy the model service.

        • Click Model List at the top of the canvas. In the model list, select the packaged model, click Deploy to EAS, and follow the on-screen instructions to deploy the model service.

  6. In the EAS console, find the deployed service and click Debug in the Actions column. For more information, see Online debugging of services.

    In the Body section, enter test data that has the same structure as the dataset. Example:

    [{"id":"10000169349117863715","click":0.0,"dt_year":14,"dt_month":10,"dt_day":21,"dt_hour":0,"C1":"1005","banner_pos":0,"site_id":"1fbe01fe","site_domain":"f3845767","site_category":"28905ebd","app_id":"ecad2386","app_domain":"7801e8d9","app_category":"07d7df22","device_id":"a99f214a","device_ip":"96809ac8","device_model":"711ee120","device_type":"1","device_conn_type":"0","c14":15704.0,"c15":320.0,"c16":50.0,"c17":1722.0,"c18":0,"c19":35.0,"c20":100084.0,"c21":79.0}]

    The service processes the data through the Normalization Prediction->One-Hot Encoding Prediction->Vector Assembler->FM Prediction sequence and returns the prediction result.image.png