# How to interpret shapley force plot for feature importance?

I am trying to practice and learn shapley value approach to explain my predictions on a binary classification problem. However am having difficulty in understanding the below plot.

1) Does it indicate the day_2_balance influences prediction to 1? or does blue values leads to prediction 1

2) What about the axis scale? (-4.357 to 5.643)

3) What does base value mean?

4) When I hover around the pink color , I see few more column names with some values. What do they indicate?

5) does the size of features represent their importance? Meaning PEEP_min=5 has a larger size than other features?

6) What does higher to lower and lower to higher indicate?

Can someone help me with this?

Taken from this question on Github and if you are using a tree-based classifier like XGBoost:

This is because the XGBoost Tree SHAP algorithm computes the SHAP values with respect to the margin not the transformed probability. So the values you are seeing are log odds values (what XGBoost would output if pred_margin=True were set).

This means, the values on the force diagram are not showing the probabilities and it totally makes sense if they are not between 0 and 1.

• Thanks. Upvoted Nov 10, 2020 at 12:37

I've never practiced this package myself, but I've read a few analyses based on SHAP, so here's what I can say:

1. A day_2_balance of 532 contributes to increase the predicted output. In this area, such a value of day_2_balance would let to higher predictions.
2. The axis scale represents the predicted output value scale. The actually predicted value is in bold font (-2.98). I don't know if the min and max values of the scale represent true min and max of the model predicted values. They more likely result from automatic scaling of the plot.
3. Base value should be the mean value of the estimator over the whole input space.
4. Those indicate the other features of which value influence the prediction to a higher value. Features are sorted by local importance, so those are features that have lower influence than those visible.
5. Yes, but only locally. On some other locations, you could have other contributions
6. higher/lower is a caption. It indicates if each feature value influences the prediction to a higher or lower output value.

From the example plot, you can draw the following interpretation: "sample n°4100 is predicted to be -2.92, which is much lower than the average predicted value (~0.643), mostly due to the specific values of features PEEP_min(5), Fi02_100_max (50), etc., and although day_2_balance is 532".

• Hi, upvoted for the help.but when my output class is 0 or 1 why does it predict it as -2.92? I mean am working on binary classification problem Dec 27, 2019 at 9:08
• Sorry, did not get that at first sight. Explanations above are for regression. I'm not quite sure how it works for multi-output cases (including classification), this should be some kind of score for the selected class, higher score meaning that the prediction tends towards this class. So in that case, the tested class would not be favoured by the model, due to the explanations listed in my original answer. As this is a binary problem, if you try the other class, you should get reversed results, with more red. Dec 27, 2019 at 21:55

After much consideration, I reached out the following points:

• Visualization of the first prediction's explanation shap.force_plot(explainer.expected_value, shap_values[0,:], X.iloc[0,:]) according to this doc shows:

1. features pushing the prediction higher are shown in red (e.g. $$\text{SHAP}_\text{day_2_balance} = 532$$), those pushing the prediction lower are in blue (e.g. $$\text{SHAP}_\text{PEEP_min} = 5$$ , $$\text{SHAP}_\text{Fi02_100_max} = 50$$, etc.) when $$\text{Model}_\text{predicted output} = -2.92$$ for your binary classification model.

2. Apart from @Sarah answer, the scale of SHAP values based on the discussion in this issue could transform via inverse_transform() as follows:

x_scaler.inverse_transform(shap_values)


3. Based on Github the base value:

The average model output over the training dataset has been passed

• $$\text{Model}_\text{Base value} = 0.6427$$
• In other words, it is the mean prediction which can be computed by:
Y_test.mean()


4. They haven't been shown due to their contributions to the quality rating are nearly zero.

5. Yes. This amount of contribution (magnitude) also has been highlighted under "Feature impact" in Figure 4 of the paper from Lundberg et al. [Nature BME] slightly better on the feature named "Total volume" with annotation as follows:

• in your case feature contributions to push the prediction to the left (lower end) for a certain observation:

$$\text{Feature impact}_\text{PEEP_min} > \text{Feature impact}_\text{Fi02_100_max} > \text{Feature impact}_\text{MV_dur_vae} > etc.$$

6. Features have a positive impact pushing the prediction higher ( are indicated in red), those have a negative impact pushing the prediction lower ( are shown in blue).

• Note: It is possible to compute the mean of variables using:
X_train.mean()


Although this issue is under discussion, from my personal perception it depends on their positive or negative impact local values. It would drive the prediction to the left or right for a certain observation. $$\text{SHAP}_\text{predicted} > \text{variable}_\text{mean}$$  or  $$\text{SHAP}_\text{predicted} < \text{variable}_\text{mean}$$