Demystifying Machine Learning: A Guide to Building Explainable Models and XAI

Demystifying Machine Learning: Ensuring Transparency and Accountability in AI Models

Thomas Wood
Fast Data Science
2 min readSep 17, 2023

--

Building Explainable Machine Learning Models

As data scientists, we often have to balance between creating the most accurate model and ensuring its decisions are understandable to those who will use it. An opaque ‘black box’ machine learning model may draw skepticism or even legal concerns, especially when the model’s predictions directly impact everyday life, such as a loan approval or a medical diagnosis.

In a detailed tutorial on Fast Data Science’s blog, we compare different types of models and discuss how to make even the most complex ones somewhat more ‘explainable’.

The Importance of Explainability

When a bank denies a loan or a doctor recommends additional testing based on these models’ predictions, people want, and often legally have the right to, an explanation. This is where making our machine learning models explainable becomes critical.

Explainability doesn’t mean sacrificing model performance. It is about finding a balance between accuracy and transparency.

Making Machine Learning Models Explainable

Strategies to make machine learning models explainable range from using simpler linear models to clever preprocessing steps. For example, one technique is to transform categorical variables into a one-hot encoding and use them in a linear regression model.

In computer vision, Convolutional Neural Networks (CNNs) are notorious for their complexity. However, one way to understand what’s going on inside these models is to study the activation layers. In this post, we go into detail on how different layers are activated by recognizing different characters or traits.

A more in-depth investigation can occur by masking parts of the input image and observing the effect on activation layers. Using these techniques, you may start to ‘explain’ what the model is looking at when making a prediction.

Explaining Recommendation Algorithms

Netflix and other companies use recommendation systems to suggest products or movies based on a user’s previous interactions. However, their suggestions can sometimes raise eyebrows. A solution Netflix uses is to display a simple message to the user, such as ‘we’re recommending you The Wire because you watched Breaking Bad’.

A Universal Method for All Models

For a broader approach, Marco Tulio Ribeiro et al.’s LIME (Local Interpretable Model-Agnostic Explanations) provides a way to ‘explain’ predictions of any machine learning model by perturbing the input and examining the changes in predictions.

By making our machine learning models more explainable, we can help end users trust these models and ensure that their decisions are transparent and fair. To learn more about building explainable machine learning models, visit Fast Data Science’s guide to explainable AI.

--

--

Thomas Wood
Fast Data Science

Data science consultant at www.fastdatascience.com. I am interested in all things AI and natural language processing. www.freelancedatascientist.net