In this post, I will deliver some techniques and tools that will help you to do some hands-on with this Python library.
In ELI5 “explanation” is separated from output format: eli5.explain_weights() and eli5.explain_prediction() return Explanation instances; then functions from eli5.formatters can be used to get HTML, text, dict/JSON, pandas DataFrame, or PIL image representation of the explanation.
It is not convenient to do that all when working interactively in IPython notebooks, so there are eli5.show_weights() and eli5.show_prediction() functions which do explanation and formatting in a single step.
Explain functions are not doing any work by themselves; they call a concrete implementation based on estimator type. So e.g. eli5.explain_weights() calls eli5.sklearn.explain_weights.explain_linear_classifier_weights() if sklearn.linear_model.LogisticRegression classifier is passed as an estimator.
For some classifiers inspection and debugging are easy, for others this is hard. It is not rocket science to take coefficients of a linear classifier, relate them to feature names, and show them in an HTML table. ELI5 aims to handle not only simple cases but even for simple cases having a unified API for inspection has a value.
You can call a ready-made function from ELI5 and get a nicely formatted result immediately;
formatting code can be reused between machine learning frameworks;
‘drill-down’ code like feature filtering or text highlighting can be reused;
there are lots of gotchas and small differences which ELI5 takes care of;
algorithms like LIME (paper) try to explain a black-box classifier through a locally-fit simple, interpretable classifier. It means that with each additional supported “simple” classifier/regressor algorithms like LIME are getting more options automatically.
While eli5 supports many classifiers and preprocessing methods, it can’t support them all.
If a library is not supported by eli5 directly, or the text processing pipeline is too complex for eli5, eli5 can still help — it provides an implementation of LIME (Ribeiro et al., 2016) algorithm which allows explaining predictions of arbitrary classifiers, including text classifiers. eli5.lime can also help when it is hard to get an exact mapping between model coefficients and text features, e.g. if there is dimension reduction involved.
ELI5 is a Python package that helps to debug machine learning classifiers and explain their predictions. It provides…
Eli5 builds digital solutions with expertise in augmented reality, desktop applications, iOS apps, and design to streamline the business.