Interpretable Machine Learning with Python
eBook - ePub

Interpretable Machine Learning with Python

Learn to build interpretable high-performance models with hands-on real-world examples

Serg MasĂ­s

  1. 736 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Interpretable Machine Learning with Python

Learn to build interpretable high-performance models with hands-on real-world examples

Serg MasĂ­s

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

A deep and detailed dive into the key aspects and challenges of machine learning interpretability, complete with the know-how on how to overcome and leverage them to build fairer, safer, and more reliable models

Key Features

  • Learn how to extract easy-to-understand insights from any machine learning model
  • Become well-versed with interpretability techniques to build fairer, safer, and more reliable models
  • Mitigate risks in AI systems before they have broader implications by learning how to debug black-box models

Book Description

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.

What you will learn

  • Recognize the importance of interpretability in business
  • Study models that are intrinsically interpretable such as linear models, decision trees, and NaĂŻve Bayes
  • Become well-versed in interpreting models with model-agnostic methods
  • Visualize how an image classifier works and what it learns
  • Understand how to mitigate the influence of bias in datasets
  • Discover how to make models more reliable with adversarial robustness
  • Use monotonic constraints to make fairer and safer models

Who this book is for

This book is primarily written for data scientists, machine learning developers, and data stewards who find themselves under increasing pressures to explain the workings of AI systems, their impacts on decision making, and how they identify and manage bias. It's also a useful resource for self-taught ML enthusiasts and beginners who want to go deeper into the subject matter, though a solid grasp on the Python programming language and ML fundamentals is needed to follow along.

]]>

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Interpretable Machine Learning with Python est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Interpretable Machine Learning with Python par Serg MasĂ­s en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Computer Science et Computer Science General. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2021
ISBN
9781800206571

Section 1: Introduction to Machine Learning Interpretation

In this section, you will recognize the importance of interpretability in business and understand its key aspects and challenges.
This section includes the following chapters:
  • Chapter 1, Interpretation, Interpretability and Explainability; and why does it all matter?
  • Chapter 2, Key Concepts of Interpretability
  • Chapter 3, Interpretation Challenges

Chapter 1: Interpretation, Interpretability, and Explainability; and Why Does It All Matter?

We live in a world whose rules and procedures are governed by data and algorithms.
For instance, there are rules as to who gets approved for credit or released on bail, and which social media posts might get censored. There are also procedures to determine which marketing tactics are most effective and which chest x-ray features might diagnose a positive case of pneumonia.
You expect this because it is nothing new!
But not so long ago, rules and procedures such as these used to be hardcoded into software, textbooks, and paper forms, and humans were the ultimate decision-makers. Often, it was entirely up to human discretion. Decisions depended on human discretion because rules and procedures were rigid and, therefore, not always applicable. There were always exceptions, so a human was needed to make them.
For example, if you would ask for a mortgage, your approval depended on an acceptable and reasonably lengthy credit history. This data, in turn, would produce a credit score using a scoring algorithm. Then, the bank had rules that determined what score was good enough for the mortgage you wanted. Your loan officer could follow it or override it.
These days, financial institutions train models on thousands of mortgage outcomes, with dozens of variables. These models can be used to determine the likelihood that you would default on a mortgage with a presumed high accuracy. If there is a loan officer to stamp the approval or denial, it's no longer merely a guideline but an algorithmic decision. How could it be wrong? How could it be right?
Hold on to that thought because, throughout this book, we will be learning the answers to these questions and many more!
To interpret decisions made by a machine learning model is to find meaning in it, but furthermore, you can trace it back to its source and the process that transformed it. This chapter introduces machine learning interpretation and related concepts such as interpretability, explainability, black-box models, and transparency. This chapter provides definitions for these terms to avoid ambiguity and underpins the value of machine learning interpretability. These are the main topics we are going to cover:
  • What is machine learning interpretation?
  • Understanding the difference between interpretation and explainability
  • A business case for interpretability
Let's get started!

Technical requirements

To follow the example in this chapter, you will need Python 3, either running in a Jupyter environment or in your favorite integrated development environment (IDE) such as PyCharm, Atom, VSCode, PyDev, or Idle. The example also requires the requests, bs4, pandas, sklearn , matplotlib, and scipy Python libraries. The code for this chapter is located here: https://github.com/PacktPublishing/Interpretable-Machine-Learning-with-Python/tree/master/Chapter01.

What is machine learning interpretation?

To interpret something is to explain the meaning of it. In the context of machine learning, that something is an algorithm. More specifically, that algorithm is a mathematical one that takes input data and produces an output, much like with any formula.
Let's examine the most basic of models, simple linear regression, illustrated in the following formula:
Once fitted to the data, the meaning of this model is that
predictions are a weighted sum of the
features with the
coefficients. In this case, there's only one
feature or predictor variable, and the
variable is typically called the response or target variable. A simple linear regression formula single-handedly explains the transformation, which is performed on the input data
to produce the output
. The following example can illustrate this concept in further detail.

Understanding a simple weight prediction model

If you go to this web page maintained by the University of California, http://wiki.stat.ucla.edu/socr/index.php/SOCR_Data_Dinov_020108_HeightsWeights, you can find a link to download a dataset of
synthetic records of weights and heights of
-year-olds. We won't use the entire dataset but only the sample table on the web page itself with
records. We scrape the table from the web page and fit a linear regression model to the data. The model uses the height to predict the weight.
In other words,
and
, so the formula for the linear regression model would be as follows:
You can find the code for this example here: https://github.com/PacktPublishing/Interpretable-Machine-Learning-with-Python/blob/master/Chapter01/WeightPrediction.ipynb.
To run this example, you need to install the following libraries:
  • requests to fetch the web page
  • bs4 (Beautiful Soup) to scrape the table from the web page
  • pandas to load the table in to a dataframe
  • sklearn (scikit-learn) to fit the linear regression model and calculate its error
  • matplotlib to visualize the model
  • scipy to test the correlation
You should load all of them first, as follows:
Import math
import requests
from bs4 import BeautifulSoup
import pandas as pd
from sklearn import linear_model
from sklearn.metrics import mean_absolute_error
import matplotlib.pyplot as plt
from scipy.stats import pearsonr
Once the libraries are all loaded, you use requests to fetch the contents of the web page, like this:
url = \
'http://wiki.stat.ucla.edu/socr/index.php/SOCR_Data_Dinov_020108_HeightsWeights'
page = requests.get(url)
Then, take these contents and scrape out just the contents of the table with BeautifulSoup, as follows:
soup = BeautifulSoup(page.content, 'html.parser')
tbl = soup.find("table",{"class":"wikitable"})
pandas can turn the raw HyperText Markup Language (HTML) contents...

Table des matiĂšres

  1. Interpretable Machine Learning with Python
  2. Contributors
  3. Preface
  4. Section 1: Introduction to Machine Learning Interpretation
  5. Chapter 1: Interpretation, Interpretability, and Explainability; and Why Does It All Matter?
  6. Chapter 2: Key Concepts of Interpretability
  7. Chapter 3: Interpretation Challenges
  8. Section 2: Mastering Interpretation Methods
  9. Chapter 4: Fundamentals of Feature Importance and Impact
  10. Chapter 5: Global Model-Agnostic Interpretation Methods
  11. Chapter 6: Local Model-Agnostic Interpretation Methods
  12. Chapter 7: Anchor and Counterfactual Explanations
  13. Chapter 8: Visualizing Convolutional Neural Networks
  14. Chapter 9: Interpretation Methods for Multivariate Forecasting and Sensitivity Analysis
  15. Section 3:Tuning for Interpretability
  16. Chapter 10: Feature Selection and Engineering for Interpretability
  17. Chapter 11: Bias Mitigation and Causal Inference Methods
  18. Chapter 12: Monotonic Constraints and Model Tuning for Interpretability
  19. Chapter 13: Adversarial Robustness
  20. Chapter 14: What's Next for Machine Learning Interpretability?
  21. Other Books You May Enjoy
Normes de citation pour Interpretable Machine Learning with Python

APA 6 Citation

MasĂ­s, S. (2021). Interpretable Machine Learning with Python (1st ed.). Packt Publishing. Retrieved from https://www.perlego.com/book/2425241/interpretable-machine-learning-with-python-learn-to-build-interpretable-highperformance-models-with-handson-realworld-examples-pdf (Original work published 2021)

Chicago Citation

MasĂ­s, Serg. (2021) 2021. Interpretable Machine Learning with Python. 1st ed. Packt Publishing. https://www.perlego.com/book/2425241/interpretable-machine-learning-with-python-learn-to-build-interpretable-highperformance-models-with-handson-realworld-examples-pdf.

Harvard Citation

MasĂ­s, S. (2021) Interpretable Machine Learning with Python. 1st edn. Packt Publishing. Available at: https://www.perlego.com/book/2425241/interpretable-machine-learning-with-python-learn-to-build-interpretable-highperformance-models-with-handson-realworld-examples-pdf (Accessed: 15 October 2022).

MLA 7 Citation

MasĂ­s, Serg. Interpretable Machine Learning with Python. 1st ed. Packt Publishing, 2021. Web. 15 Oct. 2022.