Skip to main content
All Metrics and Presets that evaluate shift in data distributions use the default Data Drift algorithm. It automatically selects the drift detection method based on the column type (text, categorical, numerical) and volume. You can override the defaults by passing a custom parameter to the chosen Metric or Preset. You can modify the drift detection method (choose from 20+ available), thresholds, or both. You can also implement fully custom drift detection methods. Pre-requisites:

Data drift parameters

Setting conditions for data drift works differently from the usual Test API (with gt, lt, etc.) This accounts for nuances like varying role of thresholds across drift detection methods, where “greater” can be better or worse depending on the method.

Dataset-level

Dataset drift share. You can set the share of drifting columns that signals dataset drift (default: 0.5) in the relevant Metrics or Presets. For example, to set it at 70%:
This will detect dataset drift if over 70% columns are drifting, using defaults for each column. Drift methods. You can also specify the drift detection methods used on the column level. For example, to use PSI (Population Stability Index) for all columns in the dataset:
This will check if over 70% columns are drifting, using PSI method with default thresholds.
See all available methods in the table below.
Drift thresholds. You can set thresholds for each method. For example, use PSI with a threshold of 0.3 for categorical columns.
In this case, if PSI is ≥ 0.3 for any categorical column, drift will be detected for that column. The rest of the checks will use defaults: default methods for numerical and text columns (if present), and 50% as the drift_share threshold.

Column-level

For column-level metrics, you can set the drift method/threshold directly for each column:

All parameters

Use the following parameters to pass chosen drift methods. See methods and their defaults below.

Data drift detection methods

Tabular data

The following methods apply to tabular data: numerical or categorical columns in data definition. Pass them using the stattest (or num_stattest, etc.) parameter.

Text data

Text drift detection applies to columns with raw text data, as specified in data definition. Pass them using the stattest (or text_stattest) parameter.
Text descriptors drift. If you work with raw text data, you can also check for distribution drift in text descriptors (such as text length, etc.) To use this method, first compute the selected text descriptors. Then, use numerical / categorical drift detection methods as usual.

Add a custom method

If you do not find a suitable drift detection method, you can implement a custom function:
We recommended writing a specific instance of the StatTest class for that function. You need: The StatTest function itself should match (reference_data: pd.Series, current_data: pd.Series, threshold: float) -> Tuple[float, bool] signature. Accepts:
  • reference_data: pd.Series - The reference data series.
  • current_data: pd.Series - The current data series to compare.
  • feature_type: str - The type of feature being analyzed.
  • threshold: float - The test threshold for drift detection.
Returns:
  • score: float - Stat Test score (actual value)
  • drift_detected: bool - indicates is drift detected with given threshold