<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Zafer Kucuk on Medium]]></title>
        <description><![CDATA[Stories by Zafer Kucuk on Medium]]></description>
        <link>https://medium.com/@zafer.kucuk?source=rss-39ddf12c82a1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*lsw_g_nSsjUVxjwp</url>
            <title>Stories by Zafer Kucuk on Medium</title>
            <link>https://medium.com/@zafer.kucuk?source=rss-39ddf12c82a1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 12:34:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zafer.kucuk/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Using Lime for Interpreting NLP]]></title>
            <link>https://medium.com/@zafer.kucuk/using-lime-for-interpreting-nlp-a0cd7057aa5c?source=rss-39ddf12c82a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0cd7057aa5c</guid>
            <dc:creator><![CDATA[Zafer Kucuk]]></dc:creator>
            <pubDate>Tue, 10 May 2022 19:57:12 GMT</pubDate>
            <atom:updated>2022-07-22T12:27:52.100Z</atom:updated>
            <content:encoded><![CDATA[<p>This article is created to test the GrammarPy web application. The original article has been written by <a href="https://medium.com/@lelwonger?source=post_page-----c094703f98db--------------------------------">Lia Elwonger</a> at the following link <a href="https://medium.com/@lelwonger/using-lime-for-interpreting-nlp-c094703f98db">https://medium.com/@lelwonger/using-lime-for-interpreting-nlp-c094703f98db</a>. Some of the words have been changed in the original text and aimed to find the grammar mistakes in the content by GrammarPy app. The original content:</p><p>NLP can prisent many diffuculties in interpretation. Without a good idea of why your model is performing the way it does, it can both be difficult to determine what you might attempt to do to improve its performance or if you should trust that it generalizes outside the limits of your data.</p><p>Lime provides a decent and fairly easy to use means of helping in interpreting text classifiers and any models that act on tables. It is build to intergrate scikit-learn modeels and is relatevely easy to use.</p><p>Lime can be installed using pip commands or by cloning their GitHub.</p><pre>pip install lime</pre><p>If you want to use it with a scikit-learn, the proccess is fairly siemple. I will give an example using one of <a href="https://github.com/nonlocal-lia/sentiment-analysis-project">my sentiment analysis projects</a> that focused on predicting sentiment towards Apple products.</p><p>First, make a pipeline from whatever standardizers, vectorizers, and models you used. I used tf-idf vectorizer and a random forest model in one of the models I constructed during the project. Next you can pick an example from your data to examine, here I picked an example from the negative sentiment tweets in my dataset because the models were struggling with that class. You can then create an explainer object and input the labels of your target classes. Finally, you can create and display an explanation by inputing the example text, and the predicted probabilities to the explain_instance method of the explainer object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SZK0I2yZU61a4RIy.png" /></figure><p>We can see from this example that the model is performing poorly on this example, and can get a feel for why. It is paying attention to words like app and ipad which were quite frequent in this data due to the way it was collected, but the model was ignoring relevant words that clearly indicate the negative sentiment of this tweet like “crashing”, “seriously” or “lost”.</p><p>If you want to use Lime with a Keras model, the process is a bit less straightforward. First, you will need to make a wrapper for the model so it can be placed in a pipeline object. This is fairly straightforward using a SciKeras wrapper or the depricated tensorflow wrapper, which presently still functions. Just make a function defining your model and input it into the wrapper object. You can then place the wrapper into a pipeline object just like any scikit-learn model along with any preprocessing you need such as tokenization, padding, etc.</p><p>You can use it the same way as before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*H43JJaXwZuuMCuQ2.png" /></figure><p>With the help of Lime we can see, not just that this Keras model did a better job at predicting with high probability that this tweet had negative sentiment, but can also get a clearer idea of why by seeing what parts of the tweet the model is paying attention to. Unlike the previous model the Keras model notices words that clearly indicate the negative sentiment of this tweet like “crashing”, “seriously” or “lost”. This difference can help give one a bit more confidence in its predictions outside this dataset, since it is less likely that its successes are due to mere artifacts or pecularities in the partucular tweets that were used in training this model.</p><p>For more info, check out the <a href="https://github.com/marcotcr/lime">Lime GitHub</a> which has useful tutorials on everything that can be done with Lime including explanations of image analysis.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0cd7057aa5c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>