class TrainTestLabelDrift[source]#

Calculate label drift between train dataset and test dataset, using statistical measures.

Check calculates a drift score for the label in test dataset, by comparing its distribution to the train dataset. As the label may be complex, we calculate different properties of the label and check their distribution.

A label property is any function that gets labels and returns list of values. each value represents a property on the label, such as number of objects in image or tilt of each bounding box in image.

There are default properties per task: For classification: - distribution of classes

For object detection: - distribution of classes - distribution of bounding box areas - distribution of number of bounding boxes per image

For numerical distributions, we use the Earth Movers Distance. See

For categorical distributions, we use the Cramer’s V. See We also support Population Stability Index (PSI). See

label_propertiesList[Dict[str, Any]], default: None

List of properties. Replaces the default deepchecks properties. Each property is a dictionary with keys 'name' (str), method (Callable) and 'output_type' (str), representing attributes of said method. ‘output_type’ must be one of:

  • 'numeric' - for continuous ordinal outputs.

  • 'categorical' - for discrete, non-ordinal outputs. These can still be numbers, but these numbers do not have inherent value.

  • 'class_id' - for properties that return the class_id. This is used because these properties are later matched with the VisionData.label_map, if one was given.

For more on image / label properties, see the guide about Data Properties.

margin_quantile_filterfloat, default: 0.025

float in range [0,0.5), representing which margins (high and low quantiles) of the distribution will be filtered out of the EMD calculation. This is done in order for extreme values not to affect the calculation disproportionally. This filter is applied to both distributions, in both margins.

min_category_size_ratiofloat, default 0.01

minimum size ratio for categories. Categories with size ratio lower than this number are binned into an “Other” category.

max_num_categories_for_driftint, default: None

Only for discrete properties. Max number of allowed categories. If there are more, they are binned into an “Other” category. This limit applies for both drift calculation and distribution plots.

max_num_categories_for_display: int, default: 10

Max number of categories to show in plot.

show_categories_bystr, default: ‘largest_difference’

Specify which categories to show for categorical features’ graphs, as the number of shown categories is limited by max_num_categories_for_display. Possible values: - ‘train_largest’: Show the largest train categories. - ‘test_largest’: Show the largest test categories. - ‘largest_difference’: Show the largest difference between categories.

categorical_drift_methodstr, default: “cramer_v”

decides which method to use on categorical variables. Possible values are: “cramer_v” for Cramer’s V, “PSI” for Population Stability Index (PSI).

aggregation_method: str, default: ‘none’

argument for the reduce_output functionality, decides how to aggregate the individual properties drift scores for a collective score between 0 and 1. Possible values are: ‘mean’: Mean of all properties scores. ‘none’: No averaging. Return a dict with a drift score for each property. ‘max’: Maximum of all the properties drift scores.

__init__(label_properties: Optional[List[Dict[str, Any]]] = None, margin_quantile_filter: float = 0.025, max_num_categories_for_drift: Optional[int] = None, min_category_size_ratio: float = 0.01, max_num_categories_for_display: int = 10, show_categories_by: str = 'largest_difference', categorical_drift_method='cramer_v', aggregation_method: str = 'none', **kwargs)[source]#
__new__(*args, **kwargs)#


TrainTestLabelDrift.add_condition(name, ...)

Add new condition function to the check.


Add condition - require label properties drift score to be less than a certain threshold.


Remove all conditions from this check instance.


Calculate drift on label properties samples that were collected during update() calls.


Run conditions on given result.


Return check configuration.

TrainTestLabelDrift.from_config(conf[, ...])

Return check object from a CheckConfig object.

TrainTestLabelDrift.from_json(conf[, ...])

Deserialize check instance from JSON string.


Initialize run.


Return check metadata.

Name of class in split camel case.


Return parameters to show when printing the check.


Return an aggregated drift score based on aggregation method defined.


Return label drift score per label property.


Remove given condition by index., ...)

Run check.


Serialize check instance to JSON string.

TrainTestLabelDrift.update(context, batch, ...)

Perform update on batch for train or test properties.