# Covariate shift

The covariate shift dashboard enables visualization of drift in all features (multivariate) and in a single feature, using six drift detection tests. If you prefer a video walkthrough, here is our guide explaining how to use the covariate shift page:

{% embed url="<https://youtu.be/9BWh6PkL9II>" %}

Here, you can find detailed descriptions of various elements on the covariate shift page:

<figure><img src="https://1673962307-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fvipr4qR9MrP243sDPhAQ%2Fuploads%2FcQuO22FwDX1xHUIlYD0g%2Fcov%20shift.001.jpeg?alt=media&#x26;token=5063ef24-33df-456a-bcee-8aa6148761e0" alt=""><figcaption><p>Covariate shift dashboard.</p></figcaption></figure>

The **Covariate shift** dashboard consists of three main components:

### **1. Filters**

{% tabs %}
{% tab title="1.1 Segmentation" %}

Segmentation allows you to split your data into groups and analyze them separately.

For a given model, each of the columns that are selected for segmentation during configuration or in the model settings appears under the segmentation filter. Segments are then created for each of the distinct values within that column.&#x20;

In the filter section, you can select the segments you want to see visualized. You can also select **All data** to visualize results for the entire dataset.

<figure><img src="https://1673962307-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fvipr4qR9MrP243sDPhAQ%2Fuploads%2FF8HuhNnWDo8RLkONcgkF%2FScreen%20Shot%202024-07-25%20at%206.41.58%20PM.png?alt=media&#x26;token=417b0c0c-3131-473a-8aba-26a5288473fb" alt="" width="292"><figcaption><p>Select segments of interest</p></figcaption></figure>
{% endtab %}

{% tab title="1.2 Methods" %}
Select which drift methods you want to have results displayed for. Drift methods that are not calculated are not visible under the filter. Selecting which drift measures you want to have calculated can be done under [model settings.](https://docs.nannyml.com/cloud/v0.21.0/product-tour/model-side-panel/model-settings) &#x20;

{% hint style="info" %}
Please find more info about statistical and distance measures in the [NannyML Open Source documentation.](https://nannyml.readthedocs.io/en/stable/how_it_works/univariate_drift_detection.html)
{% endhint %}

<figure><img src="https://content.gitbook.com/content/vipr4qR9MrP243sDPhAQ/blobs/lJFUl4fpnnBm0jmOobRE/new_methods%20.png" alt="" width="307"><figcaption><p>Covariate shift methods filter.</p></figcaption></figure>
{% endtab %}

{% tab title="1.3 Columns" %}
Filter charts for the columns you want to see. NannyML automatically identifies feature types such as targets, model outputs, and continuous and categorical features, making it easier for you to find the relevant ones.

{% hint style="info" %}
Note that the univariate drift detection methods can also be applied to the model output and the target, not just the features.
{% endhint %}

<figure><img src="https://content.gitbook.com/content/vipr4qR9MrP243sDPhAQ/blobs/vmgrOPWdWMR8MwIHhPg5/new_columns.png" alt="" width="310"><figcaption><p>Columns filter.</p></figcaption></figure>
{% endtab %}

{% tab title="1.4 Alert status" %}
Select which drift measures to display depending on whether there are alerts in the last chunk, alerts in the previous chunks, or no alerts at all, or include all charts regardless of when and if any alerts occurred.

<figure><img src="https://content.gitbook.com/content/vipr4qR9MrP243sDPhAQ/blobs/dFaqhnC21fdxujiwUvh6/new_alert_status.png" alt="" width="233"><figcaption><p>Alert status filter.</p></figcaption></figure>
{% endtab %}

{% tab title="1.5 Tags" %}
Filter charts by the previously specified tags.

<figure><img src="https://content.gitbook.com/content/vipr4qR9MrP243sDPhAQ/blobs/eJuTloor1LkXnTlT1nw9/covariate_shift_tags.png" alt="" width="199"><figcaption><p>Tags filter.</p></figcaption></figure>
{% endtab %}
{% endtabs %}

### **2. Visualisations**

{% tabs %}
{% tab title="2.1 Sort by" %}
You can change the order of charts based on the metric name, number, or recency of the alerts.

<figure><img src="https://content.gitbook.com/content/vipr4qR9MrP243sDPhAQ/blobs/ih6fKatDNBj7nmJ4Lptg/covariate_shift_sort_by.png" alt="" width="194"><figcaption><p>Sort by window.</p></figcaption></figure>
{% endtab %}

{% tab title="2.2 Ascending/descending order" %}
For all sorting methods, the icons shown below toggle between ascending and descending order. The icon displayed depends on the selected sorting method.

* **Column Name and Method Name**: The icon toggles between alphabetical order and reverse alphabetical order. The default mode is alphabetical order.
* **Nr of Alerts**: The icon toggles between ascending and descending order based on the number of alerts. The default mode displays plots with the most alerts first.
* **Recency of Alerts**: The icon toggles between showing newer alerts first and older alerts first. The default mode shows the most recent alerts first.

<div><figure><img src="https://1673962307-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fvipr4qR9MrP243sDPhAQ%2Fuploads%2F9EYgud4Rj44XlcAlLq6M%2FScreen%20Shot%202024-07-25%20at%205.42.46%20PM.png?alt=media&#x26;token=a774ea0e-2494-44b0-aaa2-48659fea0006" alt="" width="118"><figcaption><p>Toggle for 'Nr of alerts'</p></figcaption></figure> <figure><img src="https://1673962307-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fvipr4qR9MrP243sDPhAQ%2Fuploads%2FjS0QlFaJ1g8SDqAbmM5j%2FScreen%20Shot%202024-07-25%20at%205.36.52%20PM.png?alt=media&#x26;token=25f7dcc7-5d4e-4592-bf27-da36ec1bdf4f" alt="" width="120"><figcaption><p>Toggle for other sorting methods</p></figcaption></figure></div>
{% endtab %}

{% tab title="2.3 Date range" %}
You can select a specific period of interest which applies to all charts.

<figure><img src="https://content.gitbook.com/content/vipr4qR9MrP243sDPhAQ/blobs/BqWjqRPA1JMevsc8YiTq/date_range.png" alt="" width="342"><figcaption><p>Date range window.</p></figcaption></figure>
{% endtab %}

{% tab title="2.4 Date reset" %}
To reset a previously set date period, whether using the date range or slider, simply press the "Reset" button.

<figure><img src="https://content.gitbook.com/content/vipr4qR9MrP243sDPhAQ/blobs/UUQ3loRLVMpHulIim9sB/plot_data_format_gifs.gif" alt=""><figcaption><p>Date range reset.</p></figcaption></figure>
{% endtab %}

{% tab title="2.5 Date slider" %}
Similar to selecting a date range, you can choose a specific period of interest by simply moving the date slider.

<figure><img src="https://content.gitbook.com/content/vipr4qR9MrP243sDPhAQ/blobs/UUQ3loRLVMpHulIim9sB/plot_data_format_gifs.gif" alt=""><figcaption><p>Date slider.</p></figcaption></figure>
{% endtab %}

{% tab title="2.6 Chart" %}
The charts are interactive, allowing you to hover over them for more details. Red dotted lines indicate the thresholds, while the blue line shows the metric during the reference period. The light blue line represents the metric during the analysis period.&#x20;

You can also zoom in on any part of a chart. Simply press and hold your mouse button, then draw a square over your area of interest. To reset the zoom, just double-click on the chart.&#x20;

<figure><img src="https://content.gitbook.com/content/vipr4qR9MrP243sDPhAQ/blobs/WFpcYZ3JMs10j7snx08n/covariate_shift_plot.png" alt=""><figcaption><p>Covariate shift plot.</p></figcaption></figure>
{% endtab %}
{% endtabs %}

### 3. Plot config

{% tabs %}
{% tab title="3.1 Plot format" %}
There are three types of plot formats: **line**, **step**, and **distribution**. A line plot smoothly connects points with straight lines to show trends, while a step plot uses sharp vertical and horizontal lines to show exact changes between points clearly. The distribution plot gives you more insights into how feature distribution has changed over time.

<figure><img src="https://content.gitbook.com/content/vipr4qR9MrP243sDPhAQ/blobs/hncUAEyfCEHGSDG2q7kz/covariate_shift_gifs.gif" alt=""><figcaption><p>Plot formats.</p></figcaption></figure>
{% endtab %}

{% tab title="3.2 Datasets" %}
Select datasets to zoom in on reference, analysis, or create a separate subplot for both.&#x20;

<figure><img src="https://content.gitbook.com/content/vipr4qR9MrP243sDPhAQ/blobs/PTzI0pNubbBBnStBXy55/datasets_gif.gif" alt=""><figcaption><p>Datasets plots.</p></figcaption></figure>
{% endtab %}

{% tab title="3.3 Plot elements" %}
Toggle on or off some components on the charts, like alerts, confidence bands, thresholds, and legends.

<figure><img src="https://content.gitbook.com/content/vipr4qR9MrP243sDPhAQ/blobs/2VDyTr2Dgh9IXc0H63WC/plot_elements_correct_gif.gif" alt=""><figcaption><p>Plot elements.</p></figcaption></figure>
{% endtab %}
{% endtabs %}

###
