<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Machine Learning Tooling</title>
    <description>The latest articles on DEV Community by Machine Learning Tooling (@mltooling).</description>
    <link>https://dev.to/mltooling</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F559411%2F6b93f730-6418-4b79-9e41-71551f99975c.png</url>
      <title>DEV Community: Machine Learning Tooling</title>
      <link>https://dev.to/mltooling</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mltooling"/>
    <language>en</language>
    <item>
      <title>best-of-web-python: A ranked list of awesome Python libraries for web development</title>
      <dc:creator>Machine Learning Tooling</dc:creator>
      <pubDate>Fri, 15 Jan 2021 19:16:11 +0000</pubDate>
      <link>https://dev.to/mltooling/best-of-python-web-a-ranked-list-of-awesome-python-libraries-for-web-development-4kn1</link>
      <guid>https://dev.to/mltooling/best-of-python-web-a-ranked-list-of-awesome-python-libraries-for-web-development-4kn1</guid>
      <description>&lt;p&gt;&lt;a href="https://github.com/ml-tooling/best-of-web-python"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ONH8u-9_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8474tdmn1wcv3mwx5i1z.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We've curated a list of the &lt;strong&gt;best Python libraries for web-development&lt;/strong&gt;! With awesome utilities for Django, Flask, FastAPI, an much more.&lt;/p&gt;

&lt;p&gt;The list is fully automated via GitHub Actions, so it will never get outdated. Every week it collects metadata from GitHub and package managers, calculates quality scores to rank projects inside categories, and identifies trending projects.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/ml-tooling"&gt;
        ml-tooling
      &lt;/a&gt; / &lt;a href="https://github.com/ml-tooling/best-of-web-python"&gt;
        best-of-web-python
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      🏆  A ranked list of awesome python libraries for web development. Updated weekly.
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;📫  For updates on trending projects, new additions and detailed comparisons, follow us on &lt;a href="https://twitter.com/mltooling"&gt;Twitter&lt;/a&gt; or subscribe to our weekly &lt;a href="https://mltooling.substack.com/subscribe"&gt;newsletter&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>python</category>
      <category>webdev</category>
      <category>django</category>
      <category>githunt</category>
    </item>
    <item>
      <title>best-of-ml-python: A ranked list of awesome machine learning Python libraries</title>
      <dc:creator>Machine Learning Tooling</dc:creator>
      <pubDate>Thu, 14 Jan 2021 17:35:22 +0000</pubDate>
      <link>https://dev.to/mltooling/best-of-ml-python-a-ranked-list-of-awesome-machine-learning-python-libraries-e64</link>
      <guid>https://dev.to/mltooling/best-of-ml-python-a-ranked-list-of-awesome-machine-learning-python-libraries-e64</guid>
      <description>&lt;p&gt;&lt;a href="https://github.com/ml-tooling/best-of-ml-python" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6ml8eq8d0vp4sci956bx.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We've curated a list of the &lt;strong&gt;best machine learning Python libraries&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;The list is fully automated via GitHub Actions, so it will never get outdated. Every week it collects metadata from GitHub and package managers, calculates quality scores to rank projects inside categories, and identifies trending projects.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/ml-tooling" rel="noopener noreferrer"&gt;
        ml-tooling
      &lt;/a&gt; / &lt;a href="https://github.com/ml-tooling/best-of-ml-python" rel="noopener noreferrer"&gt;
        best-of-ml-python
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      🏆 A ranked list of awesome machine learning Python libraries. Updated weekly.
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;📫  For updates on trending projects, new additions and detailed comparisons, follow us on &lt;a href="https://twitter.com/mltooling" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; or subscribe to our weekly &lt;a href="https://mltooling.substack.com/subscribe" rel="noopener noreferrer"&gt;newsletter&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>python</category>
      <category>machinelearning</category>
      <category>datascience</category>
      <category>github</category>
    </item>
    <item>
      <title>Top 5 Model Interpretability Libraries for Python</title>
      <dc:creator>Machine Learning Tooling</dc:creator>
      <pubDate>Thu, 14 Jan 2021 15:14:48 +0000</pubDate>
      <link>https://dev.to/mltooling/top-5-model-interpretability-libraries-for-python-5go0</link>
      <guid>https://dev.to/mltooling/top-5-model-interpretability-libraries-for-python-5go0</guid>
      <description>&lt;p&gt;Welcome to the post about the Top 5 Python ML Model Interpretability libraries! You ask yourself how we selected the libraries? Well, we took them from our &lt;a href="https://github.com/ml-tooling/best-of-ml-python#model-interpretability" rel="noopener noreferrer"&gt;Best of Machine Learning with Python list&lt;/a&gt;.  All libraries on this best-of list are automatically ranked by a quality score based on a variety of metrics, such as GitHub stars, code activity, used license and other factors. You can find more details in the &lt;a href="https://github.com/best-of-lists/best-of-generator" rel="noopener noreferrer"&gt;best-of-generator repo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Model interpretability - also known as model explainability - is an important field of machine learning that helps, for instance, with debugging models or detecting issues around biases, or overall increases trust in the results. The overall goal of deploying models to production is to make decisions or build upon them, which can only work when you trust them in the first place!&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;We recently started a newsletter and blog post series with focus on machine learning and the Python ecosystem. In this newsletter, we usually give a high-level overview of interesting libraries from our &lt;a href="https://github.com/ml-tooling/best-of-ml-python" rel="noopener noreferrer"&gt;best-of list&lt;/a&gt; and &lt;a href="https://github.com/ml-tooling/best-of-ml-python" rel="noopener noreferrer"&gt;projects&lt;/a&gt; we work on to support your machine learning efforts! Feel free to subscribe to stay updated 🙂&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://mltooling.substack.com" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwnqkp8xev047b5bjqskh.png" alt="Discover the best-of machine learning tooling to improve your productivity."&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;The intention of this post is to highlight some of the most popular libraries in the field based on our metric and give a crisp overview to make it hopefully easy for you to gain some high-level understanding! If you want to try them out, we can recommend our &lt;a href="https://github.com/ml-tooling/ml-workspace/tree/master/resources" rel="noopener noreferrer"&gt;ml-workspace container&lt;/a&gt; to do so, as it comes pre-installed with all but the last of the libraries in the list!&lt;/p&gt;

&lt;p&gt;So, that is enough of an introduction, here comes the list of our top 5 interpretability libraries.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://github.com/slundberg/shap" rel="noopener noreferrer"&gt;1. SHAP&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;The first library on our list is SHAP and rightly so with an impressive number of 11.4k stars on GitHub and active maintenance with over 200 commits in December alone. SHAP, which is an acronym for SHapley Additive exPlanations, is a model-agnostic explainer library that follows a game theory approach to assign importance values to features. You can find the original paper from 2017 that appeared in NIPS on &lt;a href="https://arxiv.org/abs/1705.07874" rel="noopener noreferrer"&gt;arxiv&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;As the idea behind Shapley Values is already nicely explained by others, for example in this neat &lt;a href="https://christophm.github.io/interpretable-ml-book/shapley.html" rel="noopener noreferrer"&gt;book chapter&lt;/a&gt; or this well-written &lt;a href="https://towardsdatascience.com/shap-explained-the-way-i-wish-someone-explained-it-to-me-ab81cc69ef30" rel="noopener noreferrer"&gt;blog post&lt;/a&gt;, we keep it high-level: it distributes the contribution of a feature related to all combinations of other features. Based on this approach, the library allows to explain individual predictions but also can easily give a global overview.&lt;/p&gt;

&lt;p&gt;The theory and math behind it is not so easy to explain, but luckily the library hides all of this from the user. For example, the following image&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3f4wlm89t69gy9qawpp9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3f4wlm89t69gy9qawpp9.png" alt="SHAP explanation visualization"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;- &lt;a href="https://raw.githubusercontent.com/slundberg/shap/master/docs/artwork/boston_instance.png" rel="noopener noreferrer"&gt;source&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;can be generated with this code snippet&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;shap&lt;/span&gt;

&lt;span class="n"&gt;explainer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;shap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;TreeExplainer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;shap_values&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;explainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;shap_values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;shap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;force_plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;explainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;expected_value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;shap_values&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;:],&lt;/span&gt;
    &lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;iloc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;:],&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;where &lt;code&gt;model&lt;/code&gt; is the model to be explained and &lt;code&gt;X&lt;/code&gt; is the input data. As SHAP is model-agnostic, it works with all kinds of models. &lt;/p&gt;

&lt;p&gt;As you can imagine, the computation of the various combinations for many features can be very expensive and so the authors provide a fast C++ implementation for tree models as explained &lt;a href="https://github.com/slundberg/shap#tree-ensemble-example-with-treeexplainer-xgboostlightgbmcatboostscikit-learnpyspark-models" rel="noopener noreferrer"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;The GitHub page contains nice examples and tutorial notebooks, so it should be quite easy to start with it!&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;a href="https://github.com/marcotcr/lime" rel="noopener noreferrer"&gt;2. Lime&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;The library Lime, short for &lt;em&gt;Local interpretable model-agnostic explanations&lt;/em&gt;, follows second on our list with an impressive number of 8.3k stars, last activity 21 days ago, and some nice &lt;a href="https://github.com/marcotcr/lime#tutorials-and-api" rel="noopener noreferrer"&gt;tutorials&lt;/a&gt; and &lt;a href="https://lime-ml.readthedocs.io/en/latest/" rel="noopener noreferrer"&gt;API definition&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Lime is able to explain tabular data classifiers and text classifiers independent of the actual model. As the authors of SHAP, the authors of Lime came from the University of Washington - well done Washington to have 2 libraries in the top 5 👏 - and you can find their original paper from 2016 also on &lt;a href="https://arxiv.org/abs/1602.04938" rel="noopener noreferrer"&gt;arxiv&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Lime is a concrete implementation of so-called &lt;em&gt;local surrogate models&lt;/em&gt;, which focus on explaining individual predictions of black box models. To do so, Lime generates new data around the data point you want to have an explanation for and trains a linear, interpretable classifier.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0usevkqqtok81flzk8nr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0usevkqqtok81flzk8nr.png" alt="Lime local linear model"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;- &lt;a href="https://github.com/marcotcr/lime#what-are-explanations" rel="noopener noreferrer"&gt;source&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You can then see what features were responsible for the local model's classification (in this example, it shows which words in the text contributed to the text belonging to the class &lt;em&gt;atheism&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fuqh3uwincvypeh6xei49.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fuqh3uwincvypeh6xei49.png" alt="Class feature contribution"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;- &lt;a href="https://marcotcr.github.io/lime/tutorials/Lime%20-%20basic%20usage%2C%20two%20class%20case.html" rel="noopener noreferrer"&gt;source&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In contrast to SHAP, it does not look like Lime offers an API to conveniently generate a global explanation or at least we missed this. However, by generating multiple explanations for different examples, you could gain an understanding of the original model's behavior.&lt;/p&gt;


&lt;h2&gt;
  
  
  &lt;a href="https://github.com/TeamHG-Memex/eli5/blob/master/docs/source/index.rst" rel="noopener noreferrer"&gt;3. ELI5&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;The Python library ELI5 provides a unified API for debugging and explaining machine learning classifiers. The term ELI5 can be found &lt;a href="https://www.urbandictionary.com/define.php?term=ELI5" rel="noopener noreferrer"&gt;in the urban dictionary&lt;/a&gt; and is slang for &lt;em&gt;Explain Like I am 5.&lt;/em&gt; For black-box models it offers an implementation of the Lime algorithm for texts. Besides that, it offers support for &lt;a href="https://eli5.readthedocs.io/en/latest/libraries/sklearn.html#library-scikit-learn" rel="noopener noreferrer"&gt;scikit-learn&lt;/a&gt;, &lt;a href="https://eli5.readthedocs.io/en/latest/libraries/xgboost.html#library-xgboost" rel="noopener noreferrer"&gt;XGBoost&lt;/a&gt;, &lt;a href="https://eli5.readthedocs.io/en/latest/libraries/lightgbm.html#library-lightgbm" rel="noopener noreferrer"&gt;LightGBM&lt;/a&gt;, &lt;a href="https://eli5.readthedocs.io/en/latest/libraries/catboost.html#library-catboost" rel="noopener noreferrer"&gt;CatBoost&lt;/a&gt;, &lt;a href="https://eli5.readthedocs.io/en/latest/libraries/lightning.html#library-lightning" rel="noopener noreferrer"&gt;lightning&lt;/a&gt;, &lt;a href="https://eli5.readthedocs.io/en/latest/libraries/sklearn_crfsuite.html#library-sklearn-crfsuite" rel="noopener noreferrer"&gt;sklearn-crfsuite&lt;/a&gt;, and &lt;a href="https://eli5.readthedocs.io/en/latest/libraries/keras.html#library-keras" rel="noopener noreferrer"&gt;Keras&lt;/a&gt;. &lt;a href="https://eli5.read" rel="noopener noreferrer"&gt;Check out their documentation&lt;/a&gt; for examples and an API reference. &lt;/p&gt;

&lt;p&gt;The following image shows how an explanation by ELI5 looks like for a text classification, where it shows which words contribute how much to a specific class.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fas75ak0kzithk29dpexx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fas75ak0kzithk29dpexx.png" alt="ELI5 text classification explanation visualization"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;- &lt;a href="https://eli5.readthedocs.io/en/latest/tutorials/sklearn-text.html#baseline-model" rel="noopener noreferrer"&gt;source&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It is generated by this code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;eli5&lt;/span&gt;

&lt;span class="n"&gt;eli5&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;show_weights&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;clf&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vec&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;vec&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;top&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target_names&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;target_names&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;where &lt;code&gt;clf&lt;/code&gt; is, for example, an &lt;a href="https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegressionCV.html#sklearn-linear-model-logisticregressioncv" rel="noopener noreferrer"&gt;sklearn LogisticRegressionCV&lt;/a&gt;, &lt;code&gt;vec&lt;/code&gt; is a vectorizer, for example an &lt;a href="https://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.CountVectorizer.html" rel="noopener noreferrer"&gt;sklearn CountVectorizer&lt;/a&gt; that transform texts into a token count matrix, &lt;code&gt;top&lt;/code&gt; is the number of features to show per class in the image, and &lt;code&gt;target_names&lt;/code&gt; tells &lt;em&gt;eli5&lt;/em&gt; the actual labels of the classification based on the input data.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;a href="https://github.com/bmabey/pyLDAvis" rel="noopener noreferrer"&gt;4. pyLDAvis&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;As the name already suggests, pyLDAvis focuses on &lt;a href="https://en.wikipedia.org/wiki/Latent_Dirichlet_allocation" rel="noopener noreferrer"&gt;LDA topic models&lt;/a&gt;. It can be used to interactively visualize them within &lt;a href="https://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=&amp;amp;cad=rja&amp;amp;uact=8&amp;amp;ved=2ahUKEwid3pmStY3uAhWnyYUKHRi8DrUQFjAAegQIARAD&amp;amp;url=https%3A%2F%2Fipython.org%2Fnotebook.html&amp;amp;usg=AOvVaw2VRRFs60Sx4Mh2FsoDzD45" rel="noopener noreferrer"&gt;Jupyter Notebooks&lt;/a&gt;. &lt;a href="https://pyldavis.readthedocs.io/en/latest/readme.html#usage" rel="noopener noreferrer"&gt;The documentation&lt;/a&gt; contains example videos and also an overview notebook, though compared with the other libraries the API could have been documented a little bit better. The original paper from 2014 explains the methodology and can be found &lt;a href="https://nlp.stanford.edu/events/illvi2014/papers/sievert-illvi2014.pdf" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The documentation states that this lib is agnostic to how the model was trained, as you only need the &lt;em&gt;topic-term distribution&lt;/em&gt;, &lt;em&gt;document-topic distributions&lt;/em&gt;, and &lt;em&gt;basic corpus information&lt;/em&gt;. For &lt;a href="https://scikit-learn.org/stable/" rel="noopener noreferrer"&gt;sklearn&lt;/a&gt;, &lt;a href="https://github.com/RaRe-Technologies/gensim" rel="noopener noreferrer"&gt;gensim&lt;/a&gt;, and &lt;a href="https://github.com/apple/turicreate/" rel="noopener noreferrer"&gt;graphlab&lt;/a&gt; it even has convenient methods. For example, the following code utilizing the gensim helper function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pyLDAvis.gensim&lt;/span&gt;

&lt;span class="n"&gt;pyLDAvis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gensim&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;prepare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lda&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;corpus&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dictionary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;would output an interactive graphic which is displayed in the following image. The params &lt;code&gt;lda&lt;/code&gt; is a gensim lda model, &lt;code&gt;corpus&lt;/code&gt; is a &lt;a href="https://radimrehurek.com/gensim/corpora/mmcorpus.html#module-gensim.corpora.mmcorpus" rel="noopener noreferrer"&gt;gensim matrix market corpus&lt;/a&gt;, and &lt;code&gt;dictionary&lt;/code&gt; is a gensim dictionary (&lt;a href="https://nbviewer.jupyter.org/github/bmabey/pyLDAvis/blob/master/notebooks/pyLDAvis_overview.ipynb#Making-the-common-case-easy---Gensim-and-others!" rel="noopener noreferrer"&gt;see their docs for the complete example&lt;/a&gt;). That's it!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Finkzm458x0bse1eupz5w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Finkzm458x0bse1eupz5w.png" alt="pyLDAvis visualization"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;- Screenshot taken from executed tutorial code&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the interactive visualization, you can click on the different topics, see which words belong to them, change the weighting parameter and such things!&lt;/p&gt;


&lt;h2&gt;
  
  
  &lt;a href="https://github.com/interpretml/interpret" rel="noopener noreferrer"&gt;5. InterpretML&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;InterpretML is in Alpha Release but already made it into the top 5 and is under active development; even one of our &lt;a href="https://github.com/interpretml/interpret/pull/192" rel="noopener noreferrer"&gt;Pull Requests on GitHub&lt;/a&gt; we created during writing this post was merged within 7 hours 🥳! It is a library from Microsoft and has two functionalities: first, training glassbox models that are interpretable and, second, explaining blackbox models. Their paper can be found &lt;a href="https://arxiv.org/pdf/1909.09223.pdf" rel="noopener noreferrer"&gt;here&lt;/a&gt;. &lt;a href="https://github.com/interpretml/interpret#supported-techniques" rel="noopener noreferrer"&gt;In their Supported Techniques&lt;/a&gt; section they mention the techniques the library brings with it, for example Decision Tree and SHAP Kernel Explainer as a glassbox model or blackbox explainer, respectively. As you can see, in the interpretability library world, the same techniques and libraries show up and are cross-referenced or used from each other.&lt;/p&gt;

&lt;p&gt;The library is supposed to work for shedding light on individual predictions as well as making the global behavior understandable, which is also reflected in the API. With following lines of code, you can train one of their glassbox models and get some visualization for local and global interpretability&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;interpret.glassbox&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ExplainableBoostingClassifier&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;interpret&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;show&lt;/span&gt;

&lt;span class="c1"&gt;# train
&lt;/span&gt;&lt;span class="n"&gt;ebm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ExplainableBoostingClassifier&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;ebm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# global
&lt;/span&gt;&lt;span class="n"&gt;ebm_global&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ebm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;explain_global&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nf"&gt;show&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ebm_global&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# local
&lt;/span&gt;&lt;span class="n"&gt;ebm_local&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ebm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;explain_local&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;show&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ebm_local&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can even pass an array of explanations to their &lt;code&gt;show&lt;/code&gt; function to get a comparison visualization.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fy90pbqc0hlwffukd3vkk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fy90pbqc0hlwffukd3vkk.png" alt="InterpretML explanation comparison"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;- &lt;a href="https://github.com/interpretml/interpret#train-a-glassbox-model" rel="noopener noreferrer"&gt;source&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The documentation links some more example notebooks for the other techniques, too, as well as tutorial videos or blog posts which are interesting to check out for those of you who want to go more into breadth or depth!&lt;/p&gt;




&lt;p&gt;We hope you enjoyed the read and learned something about the most popular libraries that allow you to interpret and explain your models 💡 &lt;/p&gt;

&lt;p&gt;If you liked this overview, have a look at the other &lt;a href="https://github.com/ml-tooling/best-of-ml-python" rel="noopener noreferrer"&gt;Python Machine Learning Libraries&lt;/a&gt; we ranked in our best-of list. For updates on trending projects and detailed library comparisons, follow us on &lt;a href="https://twitter.com/mltooling" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; or subscribe to our &lt;a href="https://mltooling.substack.com/subscribe" rel="noopener noreferrer"&gt;newsletter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And, of course, we are very happy about all kinds of feedback! Leave a comment or get in touch with us via &lt;a href="//mailto:team@mltooling.org"&gt;team@mltooling.org&lt;/a&gt; or via &lt;a href="https://twitter.com/mltooling" rel="noopener noreferrer"&gt;Twitter @mltooling&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With ❤️ from Berlin!&lt;/p&gt;

</description>
      <category>python</category>
      <category>machinelearning</category>
      <category>datascience</category>
      <category>deeplearning</category>
    </item>
  </channel>
</rss>
