How To Improve Your Feature Impact Charts

Justin Swansburg
3 min readMar 28, 2023

--

And better interpret your ML models

Lonely Robot holding a balloon in Banksy style (Dalle-2)

Overview

Feature impact charts are the modern day work horses of explainable AI. They are a visual representation of the importance of various features within machine learning models and are usually the first insight that data scientists turn to when interpreting their models.

These charts help data scientists and analysts better understand the contribution of each feature to the overall model performance. By assessing the impact of each feature, it becomes easier to identify the most significant variables and focus on improving the quality of the data used to train the model. In turn, this can lead to more accurate predictions and better overall model performance.

In a feature impact chart, the y-axis displays the features and the x-axis represents the magnitude of their importance. The features are ranked in descending order of importance, making it easy to identify which variables have the most significant impact on the model’s output. Let’s take a look at an example built on a churn model that I discussed in this post:

Feature impact chart

You can see that the total number of products a customer purchased is the single most important feature in our churn model, closely followed by customer’s five year average revenue.

In addition to helping explain how a model works, data scientists will also often use these charts to sanity check their model, flag target leakage, and select a reduced set of features.

So what’s the big improvement? 👀

Let’s look at how we can break down these charts to get even more insight into how our model is working:

Feature impact filtered to the positive class

Since these charts are built up from Shapely values we can aggregate them however we want. In this case, we can group by our feature names and the sign of the feature strength (i.e. whether the feature’s value increases or decreases our model’s prediction).

What’s interesting here is that there are two features that only positively impact our predictions: the total number of products purchased over the past 5 years and average recurring revenue (ARR) over the past 5 years.

The other twist in the above chart is filtering the data down to only observations with positive class predictions.

Feature impact split by predicted class labels

We can extend this analysis and include a separate feature impact chart for both our negative and positive predicted classes. In other words, we can drill in and see which factors positively and negatively influence churn for customers we expect are highly likely to renew and for customers we expect are highly unlikely to renew.

If you quickly scan these two charts you can see that the number of unique users over the past month (the top feature in the righthand chart) is a much more important features for customers that are predicted to churn.

We can take this a step further and filter down to a specific cohort of customers. Let’s take a look at how these charts change if we just looking at the banking industry:

Feature impact filtered to banking customers

You can tell that the feature impact ordering changed. Notably, total product usage is now more important for at-risk customers than beforehand and contract length is slightly less important.

And that’s it for today’s post. Let me know what you think in the comments. and go here to see the code and follow me on Medium and LinkedIn for more helpful data science tips. Thanks for reading!

--

--

Justin Swansburg

Data scientist and AI/ML leader | VP, Applied AI @ DataRobot.