The preparations
You will find the code for this example here: https://github.com/PacktPublishing/Interpretable-Machine-Learning-with-Python-2E/tree/main/04/UsedCars.ipynb
Loading the libraries
To run this example, you need to install the following libraries:
mldatasets
to load the datasetpandas
andnumpy
to manipulate itsklearn
(scikit-learn) andcatboost
to load and configure the modelmatplotlib
,seaborn
,shap
,pdpbox
, andpyale
to generate and visualize the model interpretations
You should load all of them first:
import math
import os, random
import numpy as np
import pandas as pd
import mldatasets
from sklearn import metrics, ensemble, tree, inspection,\
model_selection
import catboost as cb
import matplotlib.pyplot as plt
import seaborn as sns
import shap
from pdpbox import pdp, info_plots
from PyALE import ale
from lime.lime_tabular import LimeTabularExplainer
The following snippet of code will load...