Data registration
Para registrar los datos, active MaxCompute, vincule un proyecto y registre una tabla de MaxCompute.. This registered table serves as an intermediate table for performance statistics, called the experiment report source table. It uses a composite primary key of user_id, exp_id, and dimension fields to aggregate statistics. Each row represents metrics such as exposures and clicks for a specific user in a specific experiment. You can add dimensions such as country to build a more granular intermediate statistics table keyed on user_id, country, and exp_id. All basic and derived metrics depend on this intermediate table. The overall experiment architecture is as follows:
PAI-Rec engine is a recommendation service that integrates an SDK from the configuration center to retrieve experiment information. The response includes the experiment ID (exp_id) and a request ID (reqid).
When a user interacts with your application, front-end event tracking collects behavior logs and sends them to MaxCompute. An SQL task processes these logs to generate the experiment report source table. After you configure metrics in the configuration center, the system dynamically assembles SQL queries to compute statistics from this source table. The results are stored in Hologres, and you can view them on the experiment report page.
I. Offline experiment reports
Offline experiment report source table code
CREATE TABLE IF NOT EXISTS experiment_report (
user_id STRING COMMENT 'User ID',
exp_id STRING COMMENT 'Experiment ID',
exposure_count BIGINT COMMENT 'Exposure count',
click_count BIGINT COMMENT 'Click count',
like_comment_collect_count BIGINT COMMENT 'Like, comment, and collect count'
)
PARTITIONED by (dt STRING COMMENT 'Date')
STORED AS ALIORC;
INSERT OVERWRITE TABLE experiment_report PARTITION (dt = '${bdp.system.bizdate}')
SELECT user_id
,exp_id
,SUM(IF(event == 'expose',1,0))
,SUM(IF(event == 'click',1,0))
,SUM(IF(event IN ('like','comment','collect'),1,0))
FROM rec_sln_demo_behavior_table_v1
WHERE ds = '${bdp.system.bizdate}'
GROUP BY user_id
,exp_id
Offline experiment report source table schema
Parámetro | Descripción | Obligatorio | Notas |
| Identificador de usuario | Sí | Un identificador único de usuario, como un UID, |
| Identificador del experimento | Sí | El identificador del experimento que devuelve el servicio de pruebas A/B y que se registra mediante el seguimiento de eventos. Si utiliza su propio servicio de recomendación, establezca un identificador personalizado. Por ejemplo: |
Campo de dimensión | Campo que se usa para generar reportes estadísticos más detallados. | No | Utilice este campo para agrupar y mostrar las métricas correspondientes. Por ejemplo, agregue un campo Especifique hasta dos campos de dimensión, como Un campo de dimensión común es |
Campo de cálculo | Puede incluir varios campos de cálculo. Por ejemplo: Otro ejemplo: | Sí | Un campo numérico proporcionado por usted, como el conteo de exposiciones, el conteo de clics o la duración de visualización. |
| Partición de fecha | Sí | Formato: |
| Partición de hora | No | Formato de 24 horas: de |
| Partición de minuto | No | De |
You can generate the source table daily for offline reports or hourly for near-real-time reports, depending on your business needs. For example, use DataWorks to schedule a job that runs every hour to process logs from the previous hour. For offline generation, user_id, exp_id, and dt are required. For hourly reports, user_id, exp_id, dt, and hh are required; the mm partition is optional.
Dimension fields are optional but enable dimensional analysis of your metrics. Common dimension fields include gender and os (operating system, such as iOS or Android), which let you view report data segmented by gender or operating system.
Código de la tabla de origen del reporte de significancia sin conexión
CREATE TABLE IF NOT EXISTS experiment_report_v3 (
user_id STRING COMMENT 'User ID',
exp_id STRING COMMENT 'Experiment ID',
item_id STRING COMMENT 'Item ID',
request_id STRING COMMENT 'Request ID',
click_uv BIGINT COMMENT 'Click UV',
expr_pv BIGINT COMMENT 'Exposure PV'
)
PARTITIONED by (dt STRING COMMENT 'Date')
STORED AS ALIORC;
INSERT OVERWRITE TABLE experiment_report_v3 PARTITION (dt = '${bdp.system.bizdate}')
SELECT
user_id,
exp_id,
item_id,
request_id,
MAX(IF(event = 'click', 1, 0)) AS click_uv,
SUM(IF(event = 'expr', 1, 0)) AS expr_pv
FROM rec_sln_demo_behavior_table_v1
WHERE ds = '${bdp.system.bizdate}'
GROUP BY
user_id,
exp_id,
item_id,
request_id
Offline significance report source table schema
Parámetro | Descripción | Obligatorio | Notas |
| Identificador de usuario | Sí | Un identificador único de usuario, como un UID, |
| Identificador del experimento | Sí | El identificador del experimento que devuelve el servicio de pruebas A/B y que se registra mediante el seguimiento de eventos. Si utiliza su propio servicio de recomendación, establezca un identificador personalizado. Por ejemplo: |
| Identificador del elemento | Sí | |
| Identificador de la solicitud | Sí | |
Campo de dimensión | Campo que se usa para generar reportes estadísticos más detallados. | No | Utilice este campo para agrupar y mostrar las métricas correspondientes. Por ejemplo, agregue un campo Especifique hasta dos campos de dimensión, como Un campo de dimensión común es |
Campo de cálculo | Puede incluir varios campos de cálculo. Por ejemplo: Otro ejemplo: | Sí | Un campo numérico proporcionado por usted, como el conteo de exposiciones o el conteo de clics. |
| Partición de fecha | Sí | Formato: |
II. Real-time experiment reports
Real-time experiment report source table code
CREATE TABLE IF NOT EXISTS experiment_report_real (
user_id STRING COMMENT 'User ID',
exp_id STRING COMMENT 'Experiment ID',
exposure_count BIGINT COMMENT 'Exposure count',
click_count BIGINT COMMENT 'Click count',
like_comment_collect_count BIGINT COMMENT 'Like, comment, and collect count'
)
PARTITIONED by (
dt string
,hh string
)
STORED AS ALIORC;
INSERT OVERWRITE TABLE experiment_report_real PARTITION (dt = '${bdp.system.bizdate}',hh = '${hour}')
SELECT user_id
,exp_id
,SUM(IF(event == 'expose',1,0))
,SUM(IF(event == 'click',1,0))
,SUM(IF(event IN ('like','comment','collect'),1,0))
FROM rec_sln_demo_behavior_table_v1
WHERE ds = '${bdp.system.bizdate}'
AND hh = hour(now()) -1
GROUP BY user_id
,exp_id;
Real-time experiment report source table schema
|
Parameter |
Description |
Required |
Notes |
|
|
User ID |
Yes |
A unique user identifier, such as a UID, |
|
|
Experiment ID |
Yes |
The experiment ID returned by the A/B testing service and logged via event tracking. If you use your own recommendation service, you can set a custom identifier. Example: |
|
Dimension field |
Example: |
No |
Used to filter report data by this dimension. |
|
Compute field |
You can have multiple compute fields. Example: |
Yes |
A numeric field that you provide, such as exposure count, click count, or view duration. |
|
|
Date partition |
Yes |
Format: |
|
|
Hour partition |
Yes |
24-hour format: |
|
|
Minute partition |
No |
|
Offline metrics and real-time metrics cannot use the same result table. A result table for offline metrics requires only the dt date partition, whereas a real-time table must include at least the hh hour partition.
After you create the experiment report source table, go to Metric Management > Data Registration in the console to add the new MaxCompute data table.
III. Register a MaxCompute table
Click Create Data Table, select your bound MaxCompute project, choose the MaxCompute data table, provide a custom name, and then click Start Import to import the table data.
Field configuration
After registration, the data table appears in the list. Click View Fields to review and edit the fields. The user_id, exp_id, and dt fields are required. Together, these fields track behavior totals such as exposures, clicks, and likes for a specific user (user_id) in a specific experiment (exp_id) on a given day (dt). Custom metrics are defined and calculated based on this table.
Dimension fields
Puede agregar uno o dos campos de dimensión a la tabla. Por ejemplo, si establece city como dimensión, el reporte del experimento muestra una comparación de los resultados por cada ciudad. Si configura tanto city como gender como campos de dimensión, el reporte presenta los resultados agrupados según la combinación de ambos campos.