Book Image

Interpretable Machine Learning with Python

By : Serg Masís
Book Image

Interpretable Machine Learning with Python

By: Serg Masís

Overview of this book

Do you want to gain a deeper understanding of your models and better mitigate poor prediction risks associated with machine learning interpretation? If so, then Interpretable Machine Learning with Python deserves a place on your bookshelf. We’ll be starting off with the fundamentals of interpretability, its relevance in business, and exploring its key aspects and challenges. As you progress through the chapters, you'll then focus on how white-box models work, compare them to black-box and glass-box models, and examine their trade-off. You’ll also get you up to speed with a vast array of interpretation methods, also known as Explainable AI (XAI) methods, and how to apply them to different use cases, be it for classification or regression, for tabular, time-series, image or text. In addition to the step-by-step code, this book will also help you interpret model outcomes using examples. You’ll get hands-on with tuning models and training data for interpretability by reducing complexity, mitigating bias, placing guardrails, and enhancing reliability. The methods you’ll explore here range from state-of-the-art feature selection and dataset debiasing methods to monotonic constraints and adversarial retraining. By the end of this book, you'll be able to understand ML models better and enhance them through interpretability tuning.
Table of Contents (19 chapters)
Section 1: Introduction to Machine Learning Interpretation
Section 2: Mastering Interpretation Methods
Section 3:Tuning for Interpretability

To get the most out of this book

You will need a Jupyter environment with Python 3.6+. You can do either of the following:

  • Install one on your machine locally via Anaconda Navigator or from scratch with pip.
  • Use a cloud-based one such as Google Colaboratory, Kaggle Notebooks, Azure Notebooks, or Amazon Sagemaker.

The instructions on how to get started will vary accordingly, so we strongly suggest that you search online for the latest instructions for setting them up.

For instructions on installing the many packages employed throughout the book, please go to the Git repository, which will have the updated instructions in the readme file. We expect these to change from time to time, given how often packages change. We also tested the code with specific versions detailed in the readme, so should anything fail with later versions, please install the specific version instead.

Individual chapters begin with instructions on how to install packages in this form:

!pip install --upgrade nltk lightgbm lime

But depending on the way Jupyter was set up, installing packages might be best done through the command line or using conda, so we suggest you adapt these installation instructions to suit your needs.

If you are using the digital version of this book, we advise you to type the code yourself or access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

If you are not a machine learning practitioner or are a beginner, the advice is to read the book sequentially since many concepts are only explained in great detail in earlier chapters. The recommendation for practitioners skilled in machine learning but not acquainted with interpretability is that they can skim the first three chapters to get the ethical context and concept definitions they need to make sense of the rest, but read in the rest in order. As for advanced practitioners that have the foundations of interpretability, reading in any order should be fine.

As for the code, you can read the book without running the code simultaneously or strictly for the theory. But if you plan to run the code, it is best to do it with the book as a guide to assist with the interpretation of outcomes, and to strengthen your understanding of the theory.

While you are reading the book, think of ways in which you could use the tools learned, and by the end of it, hopefully, you will be inspired to put this newly gained knowledge into action!