Categories:

Model monitor functions

MODEL_MONITOR_DRIFT_METRIC

Gets drift metrics from a model monitor. Each model monitor monitors one machine learning model.

See also:

Querying monitoring results for more information.

语法

MODEL_MONITOR_DRIFT_METRIC(
  <model_monitor_name>, <drift_metric_name>, <column_name>
  [ , <granularity> [ , <start_time>  [ , <end_time> [ , <extra_args> ] ] ] ]
)

实参

必填:

model_monitor_name

用于计算指标的模型监视器名称。

有效值:模型监视器名称字符串。它可以是一个简单或完全限定的名称。

drift_metric_name

指标的名称。

有效值:

  • 'JENSEN_SHANNON'
  • 'DIFFERENCE_OF_MEANS'
  • 'WASSERSTEIN'
  • 'POPULATION_STABILITY_INDEX'
column_name

用于计算漂移的列名称。

有效值:作为模型监视器中的特征列、预测列或实际列存在的任何字符串。

可选:

granularity

Granularity of the time range being queried. Default value is 1 DAY.

有效值:

  • '<num> DAY'
  • '<num> WEEK'
  • '<num> MONTH'
  • '<num> QUARTER'
  • '<num> YEAR'
  • 'ALL'
  • NULL
start_time

用于计算指标的时间范围的起始点。默认值为当前时间前 60 天,每次调用该函数时都会计算。

Valid values: A timestamp expression or NULL.

end_time

用于计算指标的时间范围的终点。默认值是当前时间,每次调用该函数时都会计算。

Valid values: A timestamp expression or NULL.

extra_args

Additional arguments for segment-specific queries. This parameter is optional - if not provided, the query returns metrics for all data (non-segment query).

Valid values: A string in JSON format specifying segment column and value pairs: '{"SEGMENTS": [{"column": "<segment_column_name>", "value": "<segment_value>"}]}'

Note

Currently, segment queries support only 1 segment column:value pair per query. You cannot query multiple segments simultaneously in a single function call.

For more information about segments, see ML Observability: Monitoring model behavior over time.

返回

ColumnDescriptionExample values
EVENT_TIMESTAMPTimestamp at the start of the time range.2024-01-01 00:00:00.000
METRIC_VALUEValue of the metric within the specified time range.5
COL_COUNT_USEDNumber of records used to compute the metric.100
COL_COUNT_UNUSEDNumber of records excluded from the metric computation.10
BASELINE_COL_COUNT_USEDNumber of records used to compute the metric.10
BASELINE_COL_COUNT_UNUSEDNumber of records excluded from the metric computation.0
METRIC_NAMEName of the drift metric that has been computed.DIFFERENCE_OF_MEANS
COLUMN_NAMEName of the column for which the drift metric has been computed.FEATURE_NAME
SEGMENT_COLUMNName of the segment column for which the metric is computed (or NULL for non-segment queries).CUSTOMER_TIER
SEGMENT_VALUESegment value for which the metric is computed (or NULL for non-segment queries).PREMIUM

使用说明

要计算漂移指标,模型监视器必须设置一个基线。

如果您执行以下操作,可能会遇到错误:

  • 不设置模型监视器基线。
  • 请求非数字特征的数值漂移指标。
  • 使用模型监视器中不存在的漂移指标。

If values you’ve specified for column_name or model_monitor_name are case-sensitive, or contain special characters or spaces, enclose them in double quotes. You must enclose the double quotes within single quotes, such as '"<model_monitor_name>"'.

If double-quotes are not provided in these two fields, the column_name or model_monitor_name will be assumed to be case-insensitive.

To minimize potential impact from schema changes, update your queries to explicitly select only the necessary columns instead of using a wildcard (*).

示例

The following example gets the differences of means drift metric for MY_MONITOR over a one-day period:

SELECT * FROM TABLE(MODEL_MONITOR_DRIFT_METRIC(
'MY_MONITOR', 'DIFFERENCE_OF_MEANS', 'MODEL_PREDICTION', '1 DAY', TO_TIMESTAMP_TZ('2024-01-01'), TO_TIMESTAMP_TZ('2024-01-02'))
)

The following example gets the Jensen-Shannon drift metric for MY_MONITOR over the last 30 days:

SELECT * FROM TABLE(MODEL_MONITOR_DRIFT_METRIC(
'MY_MONITOR', 'JENSEN_SHANNON', 'MODEL_PREDICTION', '1 DAY', DATEADD('DAY', -30, CURRENT_DATE()), CURRENT_DATE())
)