# SHAP Distributions Per Feature
URL: https://docs.datarobot.com/en/docs/workbench/nxt-workbench/experiments/experiment-insights/shap-distribution.html

> Provides feature-by-feature detail about Individual Prediction Explanations, representing a probability distribution.

# SHAP Distributions: Per Feature

| Tab | Description |
| --- | --- |
| Explanations | Helps to understand what drives predictions by providing an estimation of how much each feature contributes to a given prediction differing from the average. |

Two insights are available to provide alternative visualizations of how features contribute to a prediction:

| Insight | Description |
| --- | --- |
| SHAP Distributions: Per Feature (this page) | Shows the distribution and density of scores per feature using a violin plot for the visualization. |
| SHAP Individual Prediction Explanations | Shows the effect of each feature on prediction on a row-by-row basis. |

**Predictive:**
[https://docs.datarobot.com/en/docs/images/wb-violin-1.png](https://docs.datarobot.com/en/docs/images/wb-violin-1.png)

**Time-aware:**
[https://docs.datarobot.com/en/docs/images/wb-violin-1a.png](https://docs.datarobot.com/en/docs/images/wb-violin-1a.png)


See the [deep dive](https://docs.datarobot.com/en/docs/workbench/nxt-workbench/experiments/experiment-insights/shap-distribution.html#deep-dive-interpret-shap-distributions) for more information on methodology and interpretability. For more details about working with SHAP in DataRobot, see the related [considerations](https://docs.datarobot.com/en/docs/workbench/nxt-workbench/experiments/experiment-insights/shap-predex.html#shap-considerations) and the [SHAP reference](https://docs.datarobot.com/en/docs/reference/pred-ai-ref/shap-ref.html) for predictive and time-aware experiments.

## Visualization overview

The SHAP Distributions: Per Feature, also called a violin plot, is a statistical graphic for comparing probability distributions of a dataset across different categories. They show the smooth, continuous shape of your data. The vertical axis represents the features in the dataset while the horizontal axis represents the SHAP score. As a result, the plotted density shapes represent the distribution, based on a sampling of up to 1,000 rows, of the data at different values. The width of the "violin" at a given value shows how many data points fall around that value—do they cluster, peak, or spread evenly? See the [distribution specifics](https://docs.datarobot.com/en/docs/workbench/nxt-workbench/experiments/experiment-insights/shap-distribution.html#visualize-feature-distribution) for examples.

The visualization shows the top 10 features, based on the sort order, with an option to Load more features.

## Insight filters

Use the controls in the insight to change the prediction distribution chart. Options are dependent on experiment type.

| Option | Description | Type |
| --- | --- | --- |
| Data slice | Select or create (by selecting Create slice) a data slice to see a how a specific cohort impacts prediction outcome. | Predictive |
| Compare to All Data | Show the feature's impact for a subpopulation (slice). Results are overlaid with the impact when the full population is considered. | Predictive |
| Series ID | Choose a series identifier to display explanations only for that series or choose None to see explanations for all series. | Time-aware |
| Forecast distance | Select None or a specific forecast distance. Available values are derived from the range of time steps that were created when you set the number of values to forecast in the forecast window configuration. | Time-aware |
| Sort by | Set the sort method—either by impact (importance) or alphabetically by name—and the sort order. The default is sorting by decreasing impact, that is, most impactful features first. | All |
| Auto-scale y-axis | Scale feature distributions relative to the feature with the most rows present. | All |
| Show outliers | Adjust the scale to include outlier values. | All |
| Search | Adjust the display to show only features matching the search string. | All |
| Export | Download the data, image, or both for the visualization. | All |

### Data slice

For predictive experiments, [data slices](https://docs.datarobot.com/en/docs/reference/pred-ai-ref/sliced-insights.html) are a way to view a subpopulation of a model's data based on feature value. When a slice is selected, note that the order of features changes to match the sort selection according to the new population. For example:

**All data:**
Without a slice, the plot shows:

[https://docs.datarobot.com/en/docs/images/wb-violin-12.png](https://docs.datarobot.com/en/docs/images/wb-violin-12.png)

**With a slice:**
Showing males over the age of 70:

[https://docs.datarobot.com/en/docs/images/wb-violin-13.png](https://docs.datarobot.com/en/docs/images/wb-violin-13.png)


### Compare to All Data

When one or more slices are configured, enable the Compare to All Data toggle. This allows you to compare a selected slice against the full dataset option, helping to visualize how the distribution differs (or doesn't) when compared to unsliced data.

When toggled on, the transparent violin with a white outline represents the unsliced data, and the colored violin within represents the selected slice.

If a slice matches All data very closely, the white outline of the violin appears transparent because it closely matches the sliced subset.

### Auto-scale y-axis

Use the toggle to normalize vertical scaling. The setting controls whether the insight shows all distribution detail for each violin or shows a distribution that scales proportionally to the feature with the least distributed (most consistent) value count. At-a-glance you can see distribution—tall, short, wide, narrow. This option provides a rough idea of how impactful the distribution is. The more spread out a violin, the more dispersed the values. For example:

**Without scaling:**
[https://docs.datarobot.com/en/docs/images/wb-violin-8.png](https://docs.datarobot.com/en/docs/images/wb-violin-8.png)

**With scaling:**
[https://docs.datarobot.com/en/docs/images/wb-violin-9.png](https://docs.datarobot.com/en/docs/images/wb-violin-9.png)


See more about auto-scaling [below](https://docs.datarobot.com/en/docs/workbench/nxt-workbench/experiments/experiment-insights/shap-distribution.html#auto-scaling).

### Show outliers

Where auto-scaling applies to the vertical access (distribution height), outliers apply to the horizontal axis. Outliers show values that are far, relatively speaking, from the main violin and are calculated after binning. For example:

**Without outliers shown:**
[https://docs.datarobot.com/en/docs/images/wb-violin-10.png](https://docs.datarobot.com/en/docs/images/wb-violin-10.png)

**With outliers shown:**
[https://docs.datarobot.com/en/docs/images/wb-violin-11.png](https://docs.datarobot.com/en/docs/images/wb-violin-11.png)


See more about calculating outliers [below](https://docs.datarobot.com/en/docs/workbench/nxt-workbench/experiments/experiment-insights/shap-distribution.html#calculating-outliers).

## Deep dive: Interpret SHAP distributions

Each violin shown is based on up to 1,000 rows of SHAP values. If there are fewer than 1,000 rows—either in the entire dataset or in a sliced subset of the dataset— the violin will have fewer. For each feature, DataRobot then divides the 1,000 data points into uniform bins. In general, use the insight to compare shapes, which represent the distributions. Assessing whether violins are clusters (cohorts) or uniform tells you whether a feature has groups of values that are strongly, positively, or barely impactful.

The SHAP per-feature visualization uses color to represent the density and distribution of features that have impact on the predictions:

- Numeric and binary (continuous) features are plotted on a color spectrum of purple (low frequency) to yellow (high frequency), indicating where higher and lower feature values lie.
- Categorical (discrete) features are shown as gray, with violins embedded within each violin, representing the different categories.
- All other values are shown as blue.

The horizontal axis represents the effect of features on prediction outcomes, with `0` representing no effect. A large cohort of the violin on the left side of zero (i.e., less than zero) means the feature subtracts from the prediction outcome; cohorts on the right of zero add to the prediction outcome. Features often fall to both sides because of the values of individual rows. See [below](https://docs.datarobot.com/en/docs/workbench/nxt-workbench/experiments/experiment-insights/shap-distribution.html#interpret-the-distribution-plot) for help further interpreting the visualization.

### Visualize feature distribution

The example below, the continuous feature `num_lab_procedures`, you can see a majority of the cohort on the right side, meaning it adds to the prediction outcome.

- The more purple seen in the full violin, the fewer the number of lab procedures; the more yellow, the higher the number of lab procedure.
- While it is not all purple or all yellow on either side of zero, coloration indicates that higher number of lab procedures tend to add to the prediction value. Hover on the feature to understand its individual distribution (up to 1,000 rows) in the context of the displayed data (all data or a selected slice).

Hover on a discrete feature (gray on the full plot) to see up to the top seven classes in the full distribution. All others are represented as gray. For example, from `admission_type_id` for patients under 40 you can see that the value `emergency` seems to have little impact on the outcome whereas `urgent` more strongly influences prediction outcomes.

### Auto-scaling

DataRobot bins the same number of rows (up to 1,000) to plot a violin and each violin row uses the same vertical pixel height. The maximum height on the plot is reflects the bin containing the most rows, i.e., it is the "tallest peak".

Distribution of rows for each violin row differs, and sometimes by quite large amounts. One row may have the majority of its values in a (horizontally) narrow span, which in turn results in a tall peak as the height of the distribution. Another may have rows distributed broader horizontally, which in turn means a smaller peak of the height of the distribution.

The maximum height is dynamically computed from the features present in the visualization at any given time. If you change the display—with slices, search, loading more features, for example—that changes the maximum height and other violins will be rescaled accordingly.

### Calculating outliers

If both of the following conditions both are met, the bin is considered an [outlier](https://docs.datarobot.com/en/docs/workbench/nxt-workbench/experiments/experiment-insights/shap-distribution.html#show-outliers):

- The bin contains less than 2% membership of the maximum bin.
- The bin is at least one empty bin away from the nearest bin.

Outliers are always marked with a circle of the same size regardless of the number of outliers in the outlier bin. That is, there is no distinction between a bin with 0.3% membership and a bin with 0.7% membership.

---
