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:
mldatasetsto load the datasetpandas,numpy, andnltkto manipulate itsklearn(scikit-learn) andlightgbmto split the data and fit the modelsmatplotlib,seaborn,shap, andlimeto 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...