The preparations
- You will find the code for this example here: https://github.com/PacktPublishing/Interpretable-Machine-Learning-with-Python-2E/blob/main/05/ChocoRatings.ipynb
Loading the libraries
To run this example, you need to install the following libraries:
mldatasets
to load the datasetpandas
,numpy
, andnltk
to manipulate itsklearn
(scikit-learn) andlightgbm
to split the data and fit the modelsmatplotlib
,seaborn
,shap
, andlime
to visualize the interpretations
You should load all of them first, as follows:
import math
import mldatasets
import pandas as pd
import numpy as np
import re
import nltk
from nltk.probability import FreqDist
from nltk.tokenize import word_tokenize
from sklearn.model_selection import train_test_split
from sklearn.pipeline import make_pipeline
from sklearn import metrics, svm
from sklearn.feature_extraction.text import TfidfVectorizer
import lightgbm as lgb
import matplotlib.pyplot as...