Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Interpretable Machine Learning with Python

You're reading from   Interpretable Machine Learning with Python Learn to build interpretable high-performance models with hands-on real-world examples

Arrow left icon
Product type Paperback
Published in Mar 2021
Publisher Packt
ISBN-13 9781800203907
Length 736 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Serg Masís Serg Masís
Author Profile Icon Serg Masís
Serg Masís
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

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

Evaluating misclassifications with gradient-based attribution methods

Gradient-based methods calculate attribution maps for each classification with both forward and background passes through the CNN. As the name suggests, these methods leverage the gradients in the backward pass to compute the attribution maps. All of these methods are local interpretation methods because they only derive a single interpretation per sample. Incidentally, attributions in this context means that we are attributing the predicted labels to areas of an image. They are often called sensitivity maps in academic literature, too.

To get started, we will first need to create an array with all of our misclassification samples (X_misclass) from the validation dataset (X_val). Many of these methods can compute the attribution maps in batch, so this facilitates the process. We can then print the shape of our misclassifications array to ensure that all 17 samples are there:

idxs = avocado_FN_idxs + grapefruit_FP_idxs...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime