Home Page Icon
Home Page
Table of Contents for
cover
Close
cover
by Denis Rothman
Hands-On Explainable AI (XAI) with Python
Preface
Who this book is for
What this book covers
To get the most out of this book
Get in touch
Explaining Artificial Intelligence with Python
Defining explainable AI
Going from black box models to XAI white box models
Explaining and interpreting
Designing and extracting
The XAI executive function
The XAI medical diagnosis timeline
The standard AI program used by a general practitioner
Definition of a KNN algorithm
A KNN in Python
West Nile virus – a case of life or death
How can a lethal mosquito bite go unnoticed?
What is the West Nile virus?
How did the West Nile virus get to Chicago?
XAI can save lives using Google Location History
Downloading Google Location History
Google's Location History extraction tool
Reading and displaying Google Location History data
Installation of the basemap packages
The import instructions
Importing the data
Processing the data for XAI and basemap
Setting up the plotting options to display the map
Enhancing the AI diagnosis with XAI
Enhanced KNN
XAI applied to the medical diagnosis experimental program
Displaying the KNN plot
Natural language explanations
Displaying the Location History map
Showing mosquito detection data and natural language explanations
A critical diagnosis is reached with XAI
Summary
Questions
References
Further reading
White Box XAI for AI Bias and Ethics
Moral AI bias in self-driving cars
Life and death autopilot decision making
The trolley problem
The MIT Moral Machine experiment
Real life and death situations
Explaining the moral limits of ethical AI
Standard explanation of autopilot decision trees
The SDC autopilot dilemma
Importing the modules
Retrieving the dataset
Reading and splitting the data
Theoretical description of decision tree classifiers
Creating the default decision tree classifier
Training, measuring, and saving the model
Displaying a decision tree
XAI applied to an autopilot decision tree
Structure of a decision tree
The default output of the default structure of a decision tree
The customized output of a customized structure of a decision tree
The output of a customized structure of a decision tree
Using XAI and ethics to control a decision tree
Loading the model
Accuracy measurements
Simulating real-time cases
Introducing ML bias due to noise
Introducing ML ethics and laws
Case 1 – not overriding traffic regulations to save four pedestrians
Case 2 – overriding traffic regulations
Case 3 – introducing emotional intelligence in the autopilot
Summary
Questions
References
Further reading
Explaining Machine Learning with Facets
Getting started with Facets
Installing Facets on Google Colaboratory
Retrieving the datasets
Reading the data files
Facets Overview
Creating feature statistics for the datasets
Implementing the feature statistics code
Implementing the HTML code to display feature statistics
Sorting the Facets statistics overview
Sorting data by feature order
XAI motivation for sorting features
Sorting by non-uniformity
Sorting by alphabetical order
Sorting by amount missing/zero
Sorting by distribution distance
Facets Dive
Building the Facets Dive display code
Defining the labels of the data points
Defining the color of the data points
Defining the binning of the x axis and y axis
Defining the scatter plot of the x axis and the y axis
Summary
Questions
References
Further reading
Microsoft Azure Machine Learning Model Interpretability with SHAP
Introduction to SHAP
Key SHAP principles
Symmetry
Null player
Additivity
A mathematical expression of the Shapley value
Sentiment analysis example
Shapley value for the first feature, "good"
Shapley value for the second feature, "excellent"
Verifying the Shapley values
Getting started with SHAP
Installing SHAP
Importing the modules
Importing the data
Intercepting the dataset
Vectorizing the datasets
Linear models and logistic regression
Creating, training, and visualizing the output of a linear model
Defining a linear model
Agnostic model explaining with SHAP
Creating the linear model explainer
Creating the plot function
Explaining the output of the model's prediction
Explaining intercepted dataset reviews with SHAP
Explaining the original IMDb reviews with SHAP
Summary
Questions
References
Further reading
Additional publications
Building an Explainable AI Solution from Scratch
Moral, ethical, and legal perspectives
The U.S. census data problem
Using pandas to display the data
Moral and ethical perspectives
The moral perspective
The ethical perspective
The legal perspective
The machine learning perspective
Displaying the training data with Facets Dive
Analyzing the training data with Facets
Verifying the anticipated outputs
Using KMC to verify the anticipated results
Analyzing the output of the KMC algorithm
Conclusion of the analysis
Transforming the input data
WIT applied to a transformed dataset
Summary
Questions
References
Further reading
AI Fairness with Google's What-If Tool (WIT)
Interpretability and explainability from an ethical AI perspective
The ethical perspective
The legal perspective
Explaining and interpreting
Preparing an ethical dataset
Getting started with WIT
Importing the dataset
Preprocessing the data
Creating data structures to train and test the model
Creating a DNN model
Training the model
Creating a SHAP explainer
The plot of Shapley values
Model outputs and SHAP values
The WIT datapoint explorer and editor
Creating WIT
The datapoint editor
Features
Performance and fairness
Ground truth
Cost ratio
Slicing
Fairness
The ROC curve and AUC
The PR curve
The confusion matrix
Summary
Questions
References
Further reading
A Python Client for Explainable AI Chatbots
The Python client for Dialogflow
Installing the Python client for Google Dialogflow
Creating a Google Dialogflow agent
Enabling APIs and services
The Google Dialogflow Python client
Enhancing the Google Dialogflow Python client
Creating a dialog function
The constraints of an XAI implementation on Dialogflow
Creating an intent in Dialogflow
The training phrases of the intent
The response of an intent
Defining a follow-up intent for an intent
The XAI Python client
Inserting interactions in the MDP
Interacting with Dialogflow with the Python client
A CUI XAI dialog using Google Dialogflow
Dialogflow integration for a website
A Jupyter Notebook XAI agent manager
Google Assistant
Summary
Questions
Further reading
Local Interpretable Model-Agnostic Explanations (LIME)
Introducing LIME
A mathematical representation of LIME
Getting started with LIME
Installing LIME on Google Colaboratory
Retrieving the datasets and vectorizing the dataset
An experimental AutoML module
Creating an agnostic AutoML template
Bagging classifiers
Gradient boosting classifiers
Decision tree classifiers
Extra trees classifiers
Interpreting the scores
Training the model and making predictions
The interactive choice of classifier
Finalizing the prediction process
Interception functions
The LIME explainer
Creating the LIME explainer
Interpreting LIME explanations
Explaining the predictions as a list
Explaining with a plot
Conclusions of the LIME explanation process
Summary
Questions
References
Further reading
The Counterfactual Explanations Method
The counterfactual explanations method
Dataset and motivations
Visualizing counterfactual distances in WIT
Exploring data point distances with the default view
The logic of counterfactual explanations
Belief
Truth
Justification
Sensitivity
The choice of distance functions
The L1 norm
The L2 norm
Custom distance functions
The architecture of the deep learning model
Invoking WIT
The custom prediction function for WIT
Loading a Keras model
Retrieving the dataset and model
Summary
Questions
References
Further reading
Contrastive XAI
The contrastive explanations method
Getting started with the CEM applied to MNIST
Installing Alibi and importing the modules
Importing the modules and the dataset
Importing the modules
Importing the dataset
Preparing the data
Defining and training the CNN model
Creating the CNN model
Training the CNN model
Loading and testing the accuracy of the model
Defining and training the autoencoder
Creating the autoencoder
Training and saving the autoencoder
Comparing the original images with the decoded images
Pertinent negatives
CEM parameters
Initializing the CEM explainer
Pertinent negative explanations
Summary
Questions
References
Further reading
Anchors XAI
Anchors AI explanations
Predicting income
Classifying newsgroup discussions
Anchor explanations for ImageNet
Installing Alibi and importing the modules
Loading an InceptionV3 model
Downloading an image
Processing the image and making predictions
Building the anchor image explainer
Explaining other categories
Other images and difficulties
Summary
Questions
References
Further reading
Cognitive XAI
Cognitive rule-based explanations
From XAI tools to XAI concepts
Defining cognitive XAI explanations
A cognitive XAI method
Importing the modules and the data
The dictionaries
The global parameters
The cognitive explanation function
The marginal contribution of a feature
A mathematical perspective
The Python marginal cognitive contribution function
A cognitive approach to vectorizers
Explaining the vectorizer for LIME
Explaining the IMDb vectorizer for SHAP
Human cognitive input for the CEM
Rule-based perspectives
Summary
Questions
Further reading
Answers to the Questions
Chapter 1, Explaining Artificial Intelligence with Python
Chapter 2, White Box XAI for AI Bias and Ethics
Chapter 3, Explaining Machine Learning with Facets
Chapter 4, Microsoft Azure Machine Learning Model Interpretability with SHAP
Chapter 5, Building an Explainable AI Solution from Scratch
Chapter 6, AI Fairness with Google's What-If Tool (WIT)
Chapter 7, A Python Client for Explainable AI Chatbots
Chapter 8, Local Interpretable Model-Agnostic Explanations (LIME)
Chapter 9, The Counterfactual Explanations Method
Chapter 10, Contrastive XAI
Chapter 11, Anchors XAI
Chapter 12, Cognitive XAI
Other Books You May Enjoy
Index
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Next
Next Chapter
Title_Page
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset