Hands-On Machine Learning Model Interpretation - Towards Data Science
Hands-On Machine Learning Model Interpretation - Towards Data Science
Images haven’t loaded yet. Please exit printing, wait for images to load, and try to print again.
Explainable Arti cial Intelligence (Part 3)
Hands-on Machine Learning Model
Interpretation
A comprehensive guide to interpreting machine
learning models
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 1/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Introduction
Interpreting Machine Learning models is no longer a luxury but a
necessity given the rapid adoption of AI in the industry. This article in a
continuation in my series of articles aimed at ‘Explainable Arti cial
Intelligence (XAI)’. The idea here is to cut through the hype and enable
you with the tools and techniques needed to start interpreting any
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 2/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
black box machine learning model. Following are the previous articles
in the series in case you want to give them a quick skim (but are not
mandatory for this article).
In this article we will give you hands-on guides which showcase various
ways to explain potential black-box machine learning models in a
model-agnostic way. We will be working on a real-world dataset on
Census income, also known as the Adult dataset available in the UCI ML
Repository where we will be predicting if the potential income of people
is more than $50K/yr or not.
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 3/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
• ELI5
• Skater
• SHAP
• Feature Importances
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 4/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 5/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 6/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
In [6]: Counter(labels)
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 7/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Attribute
Type Description
Name
Numeric
representation of
educational
qualification.
Ranges from 1-16.
(Bachelors, Some-
Education- college, 11th, HS-
Categorical
Num grad, Prof-school,
Assoc-acdm, Assoc-
voc,
9th, 7th-8th, 12th,
M t 1 t 4th
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 8/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Masters, 1st-4th,
10th, Doctorate, 5th-
6th, Preschool)
Represents the
marital status of the
1 cat_cols = data.select_dtypes(['category']).columns
2 data[cat_cols] = data[cat_cols].apply(lambda x: x.cat.c
3 data.head()
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 9/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Time to build our train and test datasets before we build our
classi cation model.
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 10/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
We also maintain our base dataset with the actual (not encoded) values
also in a separate dataframe (useful for model interpretation later).
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 11/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
We will now train and build a basic boosting classi cation model on our
training data using the popular XGBoost framework, an optimized
distributed gradient boosting library designed to be highly e cient,
exible and portable.
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 12/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
array([0, 0, 1, 0, 0, 1, 1, 0, 0, 1])
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 13/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 14/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
• Gain: This is based on the average gain of splits which use the
feature
Note that they all contradict each other, which motivates the use of
model interpretation frameworks like SHAP which uses something
known as SHAP values, which claim to come with consistency
guarantees (meaning they will typically order the features correctly).
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 15/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 16/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 17/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Installation Instructions
We recommend installing this framework using pip install eli5
since the conda version appears to be a bit out-dated. Also feel free to
check out the documentation as needed.
eli5.show_weights(xgc.get_booster())
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 18/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 19/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Here we can see the most in uential features being the Age , Hours
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 20/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 21/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 22/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Install Skater
You can typically install Skater using a simple pip install skater . For
detailed information on the dependencies and intallation instruction
check out installing skater.
📖 Documentation
We recommend you to check out the detailed documentation of Skater.
Algorithms
Skater has a suite of model interpretation techniques some of which are
mentioned below.
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 23/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 24/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 25/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
types and formats. Out of the box, skater allows models return
numpy arrays and pandas dataframes.
• Perform interpretations
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 26/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 27/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Partial Dependence
Partial Dependence describes the marginal impact of a feature on
model prediction, holding other features in the model constant. The
derivative of partial dependence describes the impact of a feature
(analogous to a feature coe cient in a regression model). This has
been adapted from T. Hastie, R. Tibshirani and J. Friedman, Elements of
Statistical Learning Ed. 2, Springer. 2009.
The partial dependence plot (PDP or PD plot) shows the marginal e ect
of a feature on the predicted outcome of a previously t model. PDPs
can show if the relationship between the target and a feature is linear,
monotonic or more complex. Skater can show 1-D as well as 2-D PDPs
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 28/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 29/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 30/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Looks like higher the education level, the better the chance of making
more money. Not surprising!
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 31/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 32/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Let’s now take a look at how the Relationship feature a ects model
predictions.
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 33/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 34/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 35/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Interesting to see higher the education level and the middle-aged folks
(30–50) having the highest chance of making more money!
and also their e ect on the probability of the model predicting if the
person will make more money, with the help of a two-way partial
dependence plot.
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 36/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Two-way PDP showing e ects of the Education-Num and Capital Gain features
Basically having a better education and more capital gain leads to you
making more money!
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 37/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
The idea is very intuitive. To start with, just try and unlearn what you
have done so far! Forget about the training data, forget about how your
model works! Think that your model is a black box model with some
magic happening inside, where you can input data points and get the
models predicted outcomes. You can probe this magic black box as
often as you want with inputs and get output predictions.
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 38/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
• Perturb your dataset and get the black box predictions for these
new points.
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 39/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Since XGBoost has some issues with feature name ordering when
building models with dataframes, we will build our same model with
numpy arrays to make LIME work without additional hassles of feature
re-ordering. Remember the model being built is the same ensemble
model which we treat as our black box machine learning model.
XGBClassifier(base_score=0.5, booster='gbtree',
colsample_bylevel=1,
colsample_bytree=1, gamma=0,
learning_rate=0.1,
max_delta_step=0, max_depth=5,
min_child_weight=1,
missing=None, n_estimators=500, n_jobs=1,
nthread=None, objective='binary:logistic',
random_state=42, reg_alpha=0, reg_lambda=1,
scale_pos_weight=1, seed=None, silent=True,
subsample=1)
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 40/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 41/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 42/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 43/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 44/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
• A set of constraints.
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 45/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 46/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
0.009
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 47/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 48/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 49/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Here are some interesting rules you can observe from the above tree.
Feel free to derive more interesting rules from this and also your own
models! Let’s look at how our surrogate model performs on the test
dataset now.
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 50/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Just as expected, the model performance drops a fair bit but still we get
an overall F1-score of 83% as compared to our boosted model’s score
of 87% which is quite good!
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 51/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Installation
SHAP can be installed from PyPI
or conda-forge
The really awesome aspect about this framework is while SHAP values
can explain the output of any machine learning model, for really
complex ensemble models it can be slow. But they have developed a
high-speed exact algorithm for tree ensemble methods (Tree SHAP
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 52/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 53/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Let’s now dive into SHAP and leverage it for interpreting our model!
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 54/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 55/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 56/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 57/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 58/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
• The rst 100 test samples all probably earn more than $50K and
they are married or\and have a good capital gain or\and have a
higher education level!
• The next 170+ test samples all probably earn less than or equal
to $50K and they are mostly un-married and\or are very young
in age or divorced!
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 59/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
This basically takes the average of the SHAP value magnitudes across
the dataset and plots it as a simple bar chart.
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 60/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 61/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
It is interesting to note that the age and marital status feature has
more total model impact than the capital gain feature, but for those
samples where capital gain matters it has more impact than age or
marital status. In other words, capital gain a ects a few predictions
by a large amount, while age or marital status a ects all predictions by
a smaller amount.
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 62/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
You will also notice its similarity with Skater’s Partial Dependence
Plots!
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 63/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 64/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Higher education levels have higher shap values, pushing the model’s
prediction decisions to say that these individuals make more money as
compared to people with lower education levels.
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 65/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 66/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 67/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 68/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 69/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Two-way PDP showing e ects of the Age and Capital Gain features
Interesting to see higher the higher capital gain and the middle-aged
folks (30–50) having the highest chance of making more money!
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 70/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 71/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 72/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Two-way PDP showing e ects of the Marital Status and Relationship features
Interesting to see higher the higher education level and the husband or
wife (married) folks having the highest chance of making more money!
week and also their e ect on the SHAP values which lead to the model
predicting if the person will make more money or not, with the help of
a two-way partial dependence plot.
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 73/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Two-way PDP showing e ects of the Age and Hours per week features
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 74/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Conclusion
If you are reading this, I would like to really commend your e orts on
going through this huge and comprehensive tutorial on machine
learning model interpretation. This article should help you leverage the
state-of-the-art tools and techniques which should help you in your
journey on the road towards Explanable AI (XAI). Based on the
concepts and techniques we learnt in Part 2, in this article, we actually
implemented them all on a complex machine learning ensemble model
trained on a real-world dataset. I encourage you to try out some of
these frameworks with your own models and datasets and explore the
world of model interpretation!
. . .
What’s next?
In Part 4 of this series, we will be looking at a comprehensive guide to
building interpreting models on unstructured data like text and maybe
even deep learning models!
. . .
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 75/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
Note: There are a lot of rapid developments in this area including a lot of
new tools and frameworks being released over time. In case you want me to
cover any other popular frameworks, feel free to reach out to me. I’m
de nitely interested and will be starting by taking a look into H2O’s model
interpretation capabilities some time in the future.
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 76/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 77/78
12/27/2018 Hands-on Machine Learning Model Interpretation – Towards Data Science
https://towardsdatascience.com/explainable-artificial-intelligence-part-3-hands-on-machine-learning-model-interpretation-e8ebe5afc608 78/78