CREATE MODEL MONITOR

Create or replace a model monitor in the current or specified schema.

See also:

ALTER MODEL MONITOR, SHOW MODEL MONITORS, DESCRIBE MODEL MONITOR, DROP MODEL MONITOR

Syntax

CREATE [ OR REPLACE ] MODEL MONITOR [ IF NOT EXISTS ] <monitor_name> WITH
    MODEL = <model_name>
    VERSION = '<version_name>'
    FUNCTION = '<function_name>'
    SOURCE = <source_name>
    WAREHOUSE = <warehouse_name>
    REFRESH_INTERVAL = '<refresh_interval>'
    AGGREGATION_WINDOW = '<aggregation_window>'
    TIMESTAMP_COLUMN = <timestamp_name>
    [ BASELINE = <baseline_name> ]
    [ ID_COLUMNS = <id_column_name_array> ]
    [ PREDICTION_CLASS_COLUMNS = <prediction_class_column_name_array> ]
    [ PREDICTION_SCORE_COLUMNS = <prediction_column-name_array> ]
    [ ACTUAL_CLASS_COLUMNS = <actual_class_column_name_array> ]
    [ ACTUAL_SCORE_COLUMNS = <actual_column_name_array> ]
Copy

Required parameters

monitor_name

Specifies the identifier for the model monitor; must be unique in the schema where the monitor is created, and must be in the same schema as the model being monitored.

If the monitor identifier is not fully qualified (in the form of db_name.schema_name.name or schema_name.name), the command creates the model in the current schema for the session.

In addition, the identifier must start with an alphabetic character and cannot contain spaces or special characters unless the entire identifier string is enclosed in double quotes (for example, "My object"). Identifiers enclosed in double quotes are also case-sensitive.

For more information, see Identifier requirements.

MODEL = model_name

The name of the model to be monitored. Must be in the same schema where the monitor is created.

VERSION = 'version_name'

Name of the model version to be monitored.

FUNCTION = function_name

Name of the specific function in the model version to be monitored.

SOURCE = source_name

Name of the source table or view that contains the feature, inferences and ground truth labels.

WAREHOUSE = warehouse_name

The name of the Snowflake warehouse to use for the monitor’s internal compute operations.

REFRESH_INTERVAL = 'refresh_interval'

The interval at which the monitor refreshes its internal state. The value must be a string representing a time period, such as '1 day'. Supported units include seconds, minutes, hours, days, weeks, months, quarters, and years. You may use singular (“hour”) or plural (“hours”) for the interval name, but may not abbreviate.

AGGREGATION_WINDOW = 'aggregation_window'

The window over which the monitor aggregates data. The value must be a string representing a time period, such as '1 day'. Only days are supported. You may use singular (“day”) or plural (“days”) for the interval name, but may not abbreviate.

TIMESTAMP_COLUMN = timestamp_name

Name of the column in the source data that contains the timestamps. Must be of type TIMESTAMP_NTZ or DATE.

Optional parameters

BASELINE = baseline_name

Name of the baseline table or view that contanis a snapshot of data similar to SOURCE, which is used to compute drift. A snapshot of this data is embedded within the monitor object. Although thi parameter is optional, if is not set, the monitor cannot detect drift.

ID_COLUMNS = id_column_name_array

An array of string column names that, together, uniquely identify each row in the source data. See ARRAY constants.

Note

At least one prediction column (either a prediction score or a prediction class) is mandatory.

  • For classification models: Predictions can be either scores or classes; actuals must be classes.

  • For regression models: Both predcitions and actual

PREDICTION_CLASS_COLUMNS = prediction_class_column_name_array

An array of strings naming all prediction class columns in the data source. See ARRAY constants. Columns must be of type NUMBER.

PREDICTION_SCORE_COLUMNS = prediction_column_name_array

An array of of strings naming all prediction score columns in the data source. See ARRAY constants. Columns must be of type NUMBER.

ACTUAL_CLASS_COLUMNS = actual_class_column_name_array

An array of strings naming all actual class columns in the data source. See ARRAY constants. Columns must be of type NUMBER.

ACTUAL_SCORE_COLUMNS = actual_column_name_array

An array of strings naming all actual score columns in the data source. See ARRAY constants. Columns must be of type NUMBER.

Access control requirements

A role used to execute this SQL command must have the following privileges at a minimum:

Privilege

Object

Notes

OWNERSHIP

Model monitor

OWNERSHIP is a special privilege on an object that is automatically granted to the role that created the object, but can also be transferred using the GRANT OWNERSHIP command to a different role by the owning role (or any role with the MANAGE GRANTS privilege).

CREATE MODEL MONITOR

Schema

SELECT

Table or view specified by the SOURCE parameter

USAGE

Warehouse specified by the WAREHOUSE parameter

USAGE

Model specified by the MODEL parameter

The USAGE privilege on the parent database and schema are required to perform operations on any object in a schema.

For instructions on creating a custom role with a specified set of privileges, see Creating custom roles.

For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.

Usage notes

The following requirements apply to the parameters:

  • Model task must be tabular_binary_classification or tabular_regression.

  • Multiple-output models are not currently supported. Although the prediction and actual columns are arrays, the arrays must have only one element.

  • At least one of the prediction columns must be specified.

  • Actual columns are optional, but accuracy metrics are not computed if they are not specified.

  • A column may be specified once across all parameters (for example, an ID column cannot also be a prediction column).

The number of monitored features is limited to 500.

The basic configuration of MODEL MONITOR instances, including the model it monitors and data sources it uses, cannot be changed after the monitor is created. You can modify only a few options using ALTER MODEL MONITOR. To change a monitor’s configuration, drop the instance and create a new one.

Replication is supported only for instances of the CUSTOM_CLASSIFIER class.