<?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 Soumik Rakshit on Medium]]></title>
        <description><![CDATA[Stories by Soumik Rakshit on Medium]]></description>
        <link>https://medium.com/@19soumik.rakshit96?source=rss-75239884c307------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*mfyI86ccH8opycSdddcgsA.jpeg</url>
            <title>Stories by Soumik Rakshit on Medium</title>
            <link>https://medium.com/@19soumik.rakshit96?source=rss-75239884c307------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 27 May 2026 23:36:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@19soumik.rakshit96/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[Getting Started With  Kaggle Digit Recognizer Competition]]></title>
            <link>https://medium.com/koderunners/getting-started-with-kaggle-digit-recognizer-competition-22ff722dac9e?source=rss-75239884c307------2</link>
            <guid isPermaLink="false">https://medium.com/p/22ff722dac9e</guid>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[kaggle-competition]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[kaggle]]></category>
            <dc:creator><![CDATA[Soumik Rakshit]]></dc:creator>
            <pubDate>Thu, 18 Apr 2019 01:53:40 GMT</pubDate>
            <atom:updated>2019-04-18T01:53:40.560Z</atom:updated>
            <content:encoded><![CDATA[<h3>Getting Started With Kaggle Digit Recognizer Competition</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fTtS5c_CCABygI5c7Pzk6Q.png" /></figure><h3>What’s this competition all about???</h3><p>MNIST (“Modified National Institute of Standards and Technology”) is the de facto “Hello World” dataset of computer vision. Since its release in 1999, this classic dataset of handwritten images has served as the basis for benchmarking classification algorithms. As new machine learning techniques emerge, MNIST remains a reliable resource for researchers and learners alike.</p><p>In the Digit Reconizer competition hosted by Kaggle, your goal is to correctly identify digits from a dataset of tens of thousands of handwritten images. Link to the Competition: <a href="https://www.kaggle.com/c/digit-recognizer">https://www.kaggle.com/c/digit-recognizer</a>.</p><p>Currently, I reside on 41st position on the public leaderboard for the competition among the top 2% of contestants. It took me about a year to achieve the score of 1.00000 on this competition and I thought that it would be the best time to share my experience with the competition.</p><h3>How to start???</h3><p>The first approach that I could think of was the classic old LeNet-5.</p><p>Originally proposed by Yann LeCun, Leon Bottou, Yosuha Bengio and Patrick Haffner as a <strong>convolutional neural network</strong> (CNN) architecture for handwritten and machine-printed character recognition in 1990’s, it was used on large scale to automatically classify hand-written digits on bank cheques in the United States. Nowadays CNNs serve as the state-of-the art deep learning-based computer vision algorithms. These networks are built upon 3 main ideas: local receptive fields, shared weights and spacial sub-sampling. Local receptive fields with shared weights are the essence of the convolutional layer and most architectures described below use convolutional layers in one form or another.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WXCNXnA0ahn7VtgH.jpg" /><figcaption>LeNet-5 Architecture</figcaption></figure><p>When I originally submitted my first submission, I had implemented LeNet-5 using only <strong>Numpy</strong> in Python. The code was quite messy and I did not want to reproduce it. That’s why I recreated the solution using <strong>Tensorflow</strong> with the help of my friend <a href="https://www.linkedin.com/in/sohom17d/">Sohom Dey</a>. The notebook for the solution can be found at</p><p><a href="https://github.com/Koderunners/Convolutional-Neural-Networks/tree/master/Lenet-5">Koderunners/Convolutional-Neural-Networks</a></p><p>So let’s get started with the actual code.</p><h3>On With the Code….</h3><p>We did not use a wide range of libraries other that Numpy, Pandas, Matplotlib and Tensorflow which are available by default with the Kaggle Kernels environment.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/12ab439fdd0895b73ee04f5228cbf701/href">https://medium.com/media/12ab439fdd0895b73ee04f5228cbf701/href</a></iframe><h4>Output:</h4><pre>[&#39;train.csv&#39;, &#39;sample_submission.csv&#39;, &#39;test.csv&#39;]</pre><p>We will now implement a couple of utility functions that will be used both in the model training and visualization phase.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/459ad4177c91d950d1e641616bf75337/href">https://medium.com/media/459ad4177c91d950d1e641616bf75337/href</a></iframe><h4>Output:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*v5RBGenlywF4rg6RU1WEZQ.png" /></figure><h3>Exploring the data</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/38f1a768bf713881d30d93851386d74a/href">https://medium.com/media/38f1a768bf713881d30d93851386d74a/href</a></iframe><h4>Output:</h4><pre>Number of images in training dataset: 42000<br>Number of pixels in each image in training dataset: 784<br>Number of images in test dataset: 28000<br>Number of pixels in each image in test dataset: 784</pre><h3>Preprocessing the Data</h3><p>The images in the dataset have been given in 28 x 28 resolution. Since the LeNet-5 Architecture requires 32 x 32 images, we would convert the given images into 32 x 32 by applying extra zero padding on the images.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/abf6fcc2729a70806a4724e462bf9f65/href">https://medium.com/media/abf6fcc2729a70806a4724e462bf9f65/href</a></iframe><h4>Output:</h4><pre>((42000, 1024), (28000, 1024))</pre><p>We also need to convert the target labels into their respective One-Hot Encoded format.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a5ed68ed84e3b7b277ec7e4601654050/href">https://medium.com/media/a5ed68ed84e3b7b277ec7e4601654050/href</a></iframe><h4>Output:</h4><pre>Shape of Training Labels: (42000,)<br>Shape of y_train after encoding: (42000, 10)</pre><h3>Building LeNet-5</h3><p>We will first declare the training parameters and hyperparameters for the Neural Network.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01cdbf8a191f54ce23d6e40673e2b3b4/href">https://medium.com/media/01cdbf8a191f54ce23d6e40673e2b3b4/href</a></iframe><p>We will start building the model by creating the placeholders. Placeholders are a type of Tensorflow objects that are not inintialized with any value, rather receive their value during execution of the Tensorflow graph inside a Tensorflow Session by a feed dictionary. The placeholders that we will declare will correspond to the images and the one hot encoded training labels.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c73c8c48721d661126e7569591247450/href">https://medium.com/media/c73c8c48721d661126e7569591247450/href</a></iframe><p>We will not declare and initialize the Weights and Biases corresponding to each layer of the network that will be optimized during the training of the model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/066de2fdfa747d4db51f4d1fccff264e/href">https://medium.com/media/066de2fdfa747d4db51f4d1fccff264e/href</a></iframe><p>Now we will be building the actual model. We will create two utility functions for 2D Convolution and 2D Maxpooling with Valid padding. Then we will create the layers of the neural network.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e09bd71f570c9151b3d82829a168473a/href">https://medium.com/media/e09bd71f570c9151b3d82829a168473a/href</a></iframe><p>Now we will build the Tensorflow Graph for all of our operations. We will start by declaring the logits as out model, the loss operation (Softmax Cross Entropy with Logits), Optimizer (Adam optimizer). Then we will create the training operation that will be using the Optimizer to minimize the loss. We also create an operation to calculate the model accuracy and a Global Variable Initializer that initializes the global variables which in this case are the weights and biases.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c926adafad74813d0f92a0d210836e1/href">https://medium.com/media/8c926adafad74813d0f92a0d210836e1/href</a></iframe><h3>Trainig LeNet-5</h3><p>We will train the network inside a Tensorflow Session.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb6fc13a96172d30cf19f1b418983651/href">https://medium.com/media/eb6fc13a96172d30cf19f1b418983651/href</a></iframe><h4>Output:</h4><pre>Epoch 500, Cost: 28595476.4296875, Accuracy: 73.4375 %<br>Epoch 1000, Cost: 5947898.984375, Accuracy: 86.71875 %<br>Epoch 1500, Cost: 7127918.71875, Accuracy: 88.28125 %<br>Epoch 2000, Cost: 3046355.96875, Accuracy: 92.96875 %<br>Epoch 2500, Cost: 3755678.59375, Accuracy: 93.75 %<br>Epoch 3000, Cost: 1928981.6875, Accuracy: 92.1875 %<br>Epoch 3500, Cost: 769532.8125, Accuracy: 96.875 %<br>Epoch 4000, Cost: 1833259.3125, Accuracy: 93.75 %<br>Epoch 4500, Cost: 1317497.5, Accuracy: 96.09375 %<br>Epoch 5000, Cost: 1188782.34375, Accuracy: 93.75 %<br>Epoch 5500, Cost: 267834.515625, Accuracy: 98.4375 %<br>Epoch 6000, Cost: 1112221.875, Accuracy: 96.09375 %<br>Epoch 6500, Cost: 467607.857421875, Accuracy: 94.53125 %<br>Epoch 7000, Cost: 400827.03125, Accuracy: 97.65625 %<br>Epoch 7500, Cost: 22324.25, Accuracy: 99.21875 %<br>Epoch 8000, Cost: 394928.5625, Accuracy: 98.4375 %<br>Epoch 8500, Cost: 71348.0625, Accuracy: 99.21875 %<br>Epoch 9000, Cost: 0.0, Accuracy: 100.0 %<br>Epoch 9500, Cost: 24381.53125, Accuracy: 99.21875 %<br>Epoch 10000, Cost: 10489.375, Accuracy: 98.4375 %<br>----------------------------------------------------------------------<br><br>Optimization Finished<br><br>Accuracy on Training Data: 98.4071433544159 %</pre><p>Let’s visualize the training history, that is, the change is loss and accuracy during each epoch.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/abcf872837714154d42851c215222ec9/href">https://medium.com/media/abcf872837714154d42851c215222ec9/href</a></iframe><h4>Output:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*rlyD7TWEraEWsdfGHz9fuA.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37d440c9185aab19651c739d423ac9b1/href">https://medium.com/media/37d440c9185aab19651c739d423ac9b1/href</a></iframe><h4>Output:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*eNxwE84bCsD9qsmaegpL-A.png" /></figure><h3>Making Predictions:</h3><p>In order to get the predictions, we will have to first reinitialize the weights and bias variables using their optimized values. Then we would forward propagation through the neural network using these optimum weights and biases learnt during training.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb33fc4c43d97aed9f330b5db7312143/href">https://medium.com/media/fb33fc4c43d97aed9f330b5db7312143/href</a></iframe><h4>Output:</h4><pre>array([2, 0, 9, ..., 3, 9, 2])</pre><h3>Making Kaggle Submission</h3><p>We need to first save our predictions for the test images in the format given in the sample submission file which we will upload as our submission.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6eefddfbe8899748624295f4dfef4b9e/href">https://medium.com/media/6eefddfbe8899748624295f4dfef4b9e/href</a></iframe><p>This solution, being one of my earliest does not fetch a very good position on the leaderboard. Given the current scenario on the competition leaderboard, you might get which is around top 80%. Still, I think LeNet-5 is a good way to get started with the Digit Recognizer Competition in particular and Convolutional Neural Networks in general.</p><p>In my subsequent articles I will share better techniques that hepls you achieve much better positions on the leaderboard. So, stay tuned for more articles :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22ff722dac9e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/koderunners/getting-started-with-kaggle-digit-recognizer-competition-22ff722dac9e">Getting Started With  Kaggle Digit Recognizer Competition</a> was originally published in <a href="https://medium.com/koderunners">Koderunners</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Preprocessing Text Data for Machine Learning: Part 1]]></title>
            <link>https://medium.com/koderunners/preprocessing-text-data-for-machine-learning-part-1-3c1fd6f2a586?source=rss-75239884c307------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c1fd6f2a586</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[stemming]]></category>
            <category><![CDATA[lemmatization]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Soumik Rakshit]]></dc:creator>
            <pubDate>Mon, 15 Apr 2019 17:48:31 GMT</pubDate>
            <atom:updated>2019-04-15T17:48:31.627Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In the previous article we discussed various methods to perform <a href="https://medium.com/koderunners/semantic-slot-filling-part-1-7982d786928e">Semantic Slot Filling</a>, a very common problem in the field of Natural Language Processing. We discussed various methods for tackling such problems such as Rule Based Approaches and Machine Learning Approaches(including Deep Learning) and also discussed pros and cons of each method. Since Natural Language is a highly unstructured form of data, it needs to be preprocessed a lot to remove dialect-based or idiomatic inconsistencies to attain a state of uniformity and then converted to a mathematical form that can be then used to feed to a Machine Learning Models. In this article we would discuss various methods to preprocess text data.</p><h3>Machine Learning with Text Data</h3><p>Let us consider a Natural Language Problem that can be solved using Machine Learning: <strong>Sentiment Classification</strong>. Sentiment Classification based on user reviews is a very popular application as many businesses all over the world rely on the insights gathered from user reviews to take major decisions. In many cases, such decision-making is automated using <strong>Recommendation Systems</strong>. This means that we would have to create a system that would take as input raw text from user reviews (on a product or service) and output the class of sentiment, usually positive and negative. The possible outputs can be more than two is number or even a range of number if we would treat the problem as a <strong>Regression</strong> problem, but for the sake of simplicity we would consider the problem to be a <strong>Binary Classification</strong> problem. For example,</p><ul><li><em>“The watch was very stylish and comfortable to wear and also keeps time accurately”</em> — is considered to be a positive review.</li><li><em>“The band of the watch is loose and it kept loosing time 2 days after getting delivered. Best quality my ass -_-”</em> — is considered a negative review.</li></ul><p>Note that we won’t be considering sarcasm a seperate class in this example. So, reviews like <em>“The headphone is so good that I can listen to music from other galaxies”</em> or <em>“I robbed a bank to buy this headphone and now listening music inside jail”</em> would be classified positive or negative depending on our model.</p><h3>Text Preprocessing</h3><p>First of all we have to understand what text really is. We can consider text to be a sequence of low-level features like <em>characters</em> and <em>words</em> or high-level representations such as phrases, named entities or even bigger chunks like sentences, paragraphs, etc. Considering text as a sequence of words might seem a reasonable choice. In fact, we can easily find boundaries of words by splitting sentences by spaces of punctuation.</p><p>Defining boundaries of words could be much more difficult in many languages like German where there are ridiculously long compound words that are written without spaces or punctuation. For example, the 63 characters long word <em>rindfleischetikettierungsüberwachungsaufgabenübertragungsgesetz</em> means <em>the law for the delegation of monitoring beef labeling</em>. For the analysis of these words, it might be beneficial to break them up into separate words</p><p>Also, in some languages such as Japanese, there are no spaces.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/0*6P93zU5VXX6-fH9T.png" /></figure><h3>Tokenization</h3><p><strong>Tokenization</strong> is a process that splits an input sequence into several small chunks or <strong>tokens</strong>. You can think of a token as a useful unit for semantic processing. The most important thing to be noted is that a token in case of text need not always be a word, it can be singular characters, words, sentences, paragraphs etc.</p><p>Let us see the examples of some popular tokenization methods:</p><p><strong>Whitespace Tokenizer:</strong> It defines whitespaces as the boundary between tokens. For example,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/50fac598e69feb55ae302c9bd7642f6e/href">https://medium.com/media/50fac598e69feb55ae302c9bd7642f6e/href</a></iframe><p><strong>Output:</strong></p><pre>[&#39;This&#39;, &#39;is&#39;, &#39;an&#39;, &#39;example.&#39;, &#39;I&#39;, &#39;am&#39;, &#39;writing&#39;, &#39;gibberish.&#39;, &#39;By&#39;, &#39;the&#39;, &#39;way,&#39;, &#39;who&#39;, &#39;gave&#39;, &#39;Zack&#39;, &#39;Snyder&#39;, &#39;the&#39;, &#39;idea&#39;, &#39;of&#39;, &#39;Martha?&#39;, &#39;If&#39;, &quot;that&#39;s&quot;, &#39;Ben&#39;, &#39;Affleck&#39;, &#39;he&#39;, &#39;sure&#39;, &#39;is&#39;, &#39;crazy.&#39;]</pre><p>The problem in this case is that the tokens “<em>example</em>” and “<em>example.</em>” are treated differently although they have the same meaning.</p><p><strong>Word Punct Tokenizer:</strong> It seperates tokens by splitting the input sequence on the basis of punction and whitespace. We can easily implement it using Regular Expressions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/826ee6e91df9225eb45ed11961bcd1ea/href">https://medium.com/media/826ee6e91df9225eb45ed11961bcd1ea/href</a></iframe><p><strong>Output:</strong></p><pre>[&#39;This&#39;, &#39;is&#39;, &#39;an&#39;, &#39;example&#39;, &#39;.&#39;, &#39;I&#39;, &#39;am&#39;, &#39;writing&#39;, &#39;gibberish&#39;, &#39;.&#39;, &#39;By&#39;, &#39;the&#39;, &#39;way&#39;, &#39;,&#39;, &#39;who&#39;, &#39;gave&#39;, &#39;Zack&#39;, &#39;Snyder&#39;, &#39;the&#39;, &#39;idea&#39;, &#39;of&#39;, &#39;Martha&#39;, &#39;?&#39;, &#39;If&#39;, &#39;that&#39;, &quot;&#39;&quot;, &#39;s&#39;, &#39;Ben&#39;, &#39;Affleck&#39;, &#39;he&#39;, &#39;sure&#39;, &#39;is&#39;, &#39;crazy&#39;, &#39;.&#39;]</pre><p>The problem in this case is that it splits the word “<em>that’s</em>” into three seperate tokens that, &#39;, and s which is undesirable.</p><p><strong>Tree Bank Word Tokenizer:</strong> It uses a set of rules or heuristics that defines the grammar of the English language to produce tokenization that actually makes sense for further analysis. It can be implemented using the <strong>NLTK</strong> or <strong>Natural Language Toolkit</strong> in Python.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/29c9a141e228c00d81ca8151c3a2f232/href">https://medium.com/media/29c9a141e228c00d81ca8151c3a2f232/href</a></iframe><p><strong>Output:</strong></p><pre>[&#39;This&#39;, &#39;is&#39;, &#39;an&#39;, &#39;example.&#39;, &#39;I&#39;, &#39;am&#39;, &#39;writing&#39;, &#39;gibberish.&#39;, &#39;By&#39;, &#39;the&#39;, &#39;way&#39;, &#39;,&#39;, &#39;who&#39;, &#39;gave&#39;, &#39;Zack&#39;, &#39;Snyder&#39;, &#39;the&#39;, &#39;idea&#39;, &#39;of&#39;, &#39;Martha&#39;, &#39;?&#39;, &#39;If&#39;, &#39;that&#39;, &quot;&#39;s&quot;, &#39;Ben&#39;, &#39;Affleck&#39;, &#39;he&#39;, &#39;sure&#39;, &#39;is&#39;, &#39;crazy&#39;, &#39;.&#39;]</pre><p>Tree Bank Tokenizer produces the most meaningful tokens from text in the English Language.</p><h3>Token Normalization</h3><p><strong>Token Normalization</strong> refers to converting every token into a standard canonical form which it might not have had before. Normalizing Tokens ensures consistency in the data that is further preprocessed or analyzed. There are two processes of Normalizing Tokens:</p><p><strong>Stemming:</strong> It is the process of removing and replacing suffixes from the token to get the root form of the word which is called a <strong>stem</strong>. Stemming usually refers to heuristics that chop off suffixes.</p><p><strong>Porter’s Stemmer</strong> is the oldest stemmer for the English language. It has five heuristic phases of word reduction applied sequentially. These rules are simple rules like <strong>Regular Grammar</strong> or <strong>Context Free Grammar</strong>. Following are some example of rules in the first phase of Porter’s Stemmer:</p><pre>╔════════════╦═══════════════════╗<br>║   RULE     ║    EXAMPLE        ║<br>╠════════════╬═══════════════════╣<br>║ SSES -&gt; SS ║ caresses -&gt; caress║<br>║ IES -&gt; I   ║ ponies -&gt; poni    ║<br>║ SS -&gt; SS   ║ caress -&gt; caress  ║<br>║ S -&gt; null  ║ cats -&gt; cat       ║<br>╚════════════╩═══════════════════╝</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b2f85406db218b572d6f2e7fa77ace3/href">https://medium.com/media/0b2f85406db218b572d6f2e7fa77ace3/href</a></iframe><p><strong>Output:</strong></p><pre>[&#39;the&#39;, &#39;wolv&#39;, &#39;will&#39;, &#39;not&#39;, &#39;eat&#39;, &#39;the&#39;, &#39;fish&#39;, &#39;,&#39;, &#39;they&#39;, &#39;will&#39;, &#39;have&#39;, &#39;onli&#39;, &#39;lamb&#39;, &#39;.&#39;]</pre><p>The problem with porterstemmer is that due to strict heuristics it often produces irregularities, an example of which is wolves -&gt; wolv or feet -&gt; feet.</p><p><strong>Lemmatization:</strong> It is a Token Normalization process that uses liguistic processes to find the base or dictionary form of the word for every token which is also called a <em>lemma</em>. Lemmatization utilizes a vocabulary and morphological analysis for finding the lemma of every token.</p><p>The <strong>Wordnet Lemmatizer</strong> is a commonly used lemmatizer implemented in the NLTK library. It uses the <a href="https://wordnet.princeton.edu/">Wordnet Database</a> to look up lemmas which is a large lexical database of the English language created and maintained by Princeton University.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c12082318cfc06e9961b8b58870fadcd/href">https://medium.com/media/c12082318cfc06e9961b8b58870fadcd/href</a></iframe><p><strong>Output:</strong></p><pre>[&#39;The&#39;, &#39;wolf&#39;, &#39;will&#39;, &#39;not&#39;, &#39;eat&#39;, &#39;the&#39;, &#39;fish&#39;, &#39;,&#39;, &#39;they&#39;, &#39;will&#39;, &#39;have&#39;, &#39;only&#39;, &#39;lamb&#39;, &#39;.&#39;]</pre><p>Note that Wordnet Lemmatizer tackles some irregularities raised by Porter Stemmer such as wolves -&gt; wolf or feet -&gt; foot.</p><p>Although Wordnet Lemmatizer does a pretty good job, its not 100% accurate. It does a good job normalizing nouns, but might fail for verbs sometimes. Neither Stemming nor Lemmatization is perfect and we need to chose our normalization methodology depending on our track.</p><p><strong>Normalizing Upper Case Letters:</strong></p><ul><li>Us, us -&gt; us if both are pronouns but <em>us</em>, <em>US</em> could also be a pronoun or the name of a country.</li><li>We could define heuristics to solve this problem:<br>* lowercasing beginnning of the sentence<br>* lowercasing words in titles<br>* leave mid-sentence words as they are</li><li>We could also use Machine Learning to retrieve true case of tokens which would be quite complex.</li></ul><p>Stay tuned for subsequent articles :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c1fd6f2a586" width="1" height="1" alt=""><hr><p><a href="https://medium.com/koderunners/preprocessing-text-data-for-machine-learning-part-1-3c1fd6f2a586">Preprocessing Text Data for Machine Learning: Part 1</a> was originally published in <a href="https://medium.com/koderunners">Koderunners</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Semantic Slot Filling: Part 1]]></title>
            <link>https://medium.com/koderunners/semantic-slot-filling-part-1-7982d786928e?source=rss-75239884c307------2</link>
            <guid isPermaLink="false">https://medium.com/p/7982d786928e</guid>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[context-free-grammar]]></category>
            <dc:creator><![CDATA[Soumik Rakshit]]></dc:creator>
            <pubDate>Mon, 15 Apr 2019 14:25:44 GMT</pubDate>
            <atom:updated>2019-04-15T14:25:44.282Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uiHWFtG9pHXFBe1Z9CsKCg.png" /></figure><h3>Semantic Slot Filling: Part 1</h3><p>One way of making sense of a piece of text is to tag the words or tokens which carry meaning to the sentences. In the field of Natural Language Processing, this problem is known as <strong>Semantic Slot Filling</strong>. There are three main approaches to solve this problem:</p><ol><li>Rule Based Approaches</li><li>Machine Learning Approaches</li><li>Deep Learning Approaches</li></ol><p>Let us consider the following query text:</p><blockquote><strong>Show me all the Buses from Kolkata to Bhubanshwar on Friday.</strong></blockquote><p>Given this piece of text, we have to find some slots which may be Destination, City, Date etc. We will see how to fill these slots using the previously mentioned approaches.</p><h3>1. Rule Based Approach</h3><p>This approach consists on <strong>Semantic Slot Filling</strong> techniques using <strong>Regular Grammars</strong> or <strong>Context Free Grammars</strong>.</p><p>A <strong>Grammar</strong> is defined as a set of production rules which are used to generate strings of a language, which in this case may be a <strong>Regular</strong> or a <strong>Context Free Language</strong>.</p><p>In this case we would use a Context Free Grammar(CFG) to do Semantic Slot Filling. Effectively we can always chose to use Context Free Grammars since they are a super-set of Regular Grammar.</p><p>Let us consider the following CFG:</p><pre>S -&gt; SHOW BUSES ORIGIN DESTINATION DATE|...<br>SHOW -&gt; show me|i want|can i see|...<br>BUSES -&gt; bus|a bus|buses<br>ORIGIN -&gt; from CITY<br>DESTINATION -&gt; to CITY<br>CITY -&gt; kolkata|bhubaneshwar|Ahmedabad|...<br>DATE -&gt; sunday|monday|...|saturday</pre><p>Note that the Non-terminal strings in this case are the slots. Let us create the Parse tree of the above grammar</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*6BT7x3v3dpIxBZzvRfbZww.png" /><figcaption>Parse Tree</figcaption></figure><p>Now let us derive our query text from the parse tree</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*bpkI_VpU1j0wXv4VqW5e5Q.png" /><figcaption>Derivation of Query Text from Parse Tree</figcaption></figure><p>Since we can use this Context Free Grammar to parse our query string, we would know exactly which non-terminal strings produced the terminal tokens in the query string and we can tag the tokens in our string accordingly. This would result in the following tagging:</p><pre>&lt;SHOW&gt;Show me&lt;/SHOW&gt;<br>all the &lt;BUSES&gt;Buses&lt;/BUSES&gt;<br>&lt;ORIGIN&gt;from &lt;CITY&gt;Kolkata&lt;/CITY&gt;&lt;/ORIGIN&gt;<br>&lt;DESTINATION&gt;to &lt;CITY&gt;Bhubanshwar&lt;/CITY&gt;&lt;/DESTINATION&gt;<br>on &lt;DATE&gt;Friday&lt;/DATE&gt;.</pre><p><strong>Advantage:</strong> : This approach has very high precision.</p><p><strong>Disadvantage:</strong></p><ol><li>Someone(usually a linguist) would have to write down the rules manually which is very time consuming.</li><li>The recall of this process will not be good because, it would not be practical to write down every possible date.</li></ol><h3>2. Machine Learning Approach</h3><p>For a machine learning approach to solve this problem, we need some kind of data to learn from. This data usually comes in the form of a <strong>Training Corpus</strong> which is a large body of text with the necessary tags present in the form of Markup. For example,</p><pre>Are any &lt;BUSES&gt;buses&lt;/BUSES&gt; leaving &lt;DESTINATION&gt;for &lt;CITY&gt;Kolkata&lt;/CITY&gt;&lt;/DESTINATION&gt; &lt;DATE&gt;today&lt;/DATE&gt;?</pre><p>Once we have our training data, we have to do some feature engineering, and extract some useful features such as</p><ul><li>Is the word in uppercase?</li><li>Is the word present in the name of cities?</li><li>What are the previous words?</li><li>What are the next words?</li><li>What is the previous slots?</li></ul><p>and so on….</p><p>Feature engineering usually depends on the training corpus, the application at hand (which in this case is tagging words) and most importantly the creativity of the engineer.</p><p>Now we need to define our model. The model may be a probabilistic model that gives the probability of the tags associated with a given word. This probability will depend of the features representing some text and some <strong>parameters</strong>.</p><pre>model -&gt; p(tags|words) -&gt; function of features and parameters</pre><p>The parameters of the model should be trained. So we will need to take your train data and fit the model to this data and maximize the probability of what we see, by the parameters. Once we have the trained parameters, we can take the feature corresponding to a tag and infer that the tag with the maximum probability is associated with the word.</p><pre>predicted_tag = argmax(p(tags|words))</pre><h3>3. Deep Learning Approach</h3><p>The Deep Learning approach is largely similar to the machine learning approach except in the Deep Learning methodology, features do not need to be manually engineered, rather we feed an encoded sequence of words into a <strong>Neural Network</strong> and the different hidden layers of the Neural Network act as feature extractors.</p><p>Usually for Semantic Slot Filling and other Sequence Related Tasks, the most popular Deep Learning Models are <strong>Recrrent Neural Networks</strong>(RNNs).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LovDE6djem3k0Ox36PLSmg.png" /><figcaption>RNN Architecture</figcaption></figure><p>For practical purposes, <strong>Gated Recurrent Units or GRU</strong> blocks and <strong>Long Short Term Memory or LSTM</strong> blocks are used in the RNN architecture.</p><p>Stay tuned for subsequent articles :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7982d786928e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/koderunners/semantic-slot-filling-part-1-7982d786928e">Semantic Slot Filling: Part 1</a> was originally published in <a href="https://medium.com/koderunners">Koderunners</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Intersection Over Union]]></title>
            <link>https://medium.com/koderunners/intersection-over-union-516a3950269c?source=rss-75239884c307------2</link>
            <guid isPermaLink="false">https://medium.com/p/516a3950269c</guid>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[object-detection]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Soumik Rakshit]]></dc:creator>
            <pubDate>Mon, 15 Apr 2019 14:04:26 GMT</pubDate>
            <atom:updated>2019-04-15T14:04:26.059Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*3bTCvwKZqIxYfaX7GwgFJg.jpeg" /></figure><p>In the previous article, Indroduction to Object Detection, we have seen how a single object can be detected in an image by predicting a bounding box for the object. Like all Machine Learning Tasks, prediction of bounding box requires an accuracy metric to tell us how accurate the predictions are. In this article we will be discussing an accuracy metric that can be used for Object Detection.</p><h3>I Owe You</h3><p>Let us consider the following photo of a grumpy cat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*_6wMrpL2zlqCtu4g.jpg" /></figure><p>Now, in ideal case, an object detection algorithm should should be identifying him somewhat like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*5q24DtFRyZQzDUu1.jpg" /></figure><p>But, if an object detection algorithm outputs the following blue bounding box, how do we tell how much off the mark our prediction is???</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*hap_g5CpopiF9mOc.jpg" /></figure><p>In this case, we calculate <strong>IOU</strong> or <strong>Intersection</strong> Over Union for the following bounding boxes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*A_2KAwHTfMMvZaFc.jpg" /></figure><pre><strong>IOU(Box1, Box2) = Intersection_Size(Box1, Box2) / Union_Size(Box1, Box2)</strong></pre><h3>Implementing IOU</h3><p>The bounding box coordinates are in the form (x, y, width, height). We will first calculate the width and height of the Intersection Box and size of Intersection will be area of the Intersection Box. We can get the Union size by subtracting the Intersection size from total area. All the code is part of the following <a href="https://www.kaggle.com/soumikrakshit/object-detection-single-rectangle">Kaggle Notebook</a>.</p><h4>Code:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ac01449f9afd8d833623aca92197413/href">https://medium.com/media/2ac01449f9afd8d833623aca92197413/href</a></iframe><p>We will modify the visualization code to also show the respective IOU.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e826e0307a98bebecb2cbe63f6086fa1/href">https://medium.com/media/e826e0307a98bebecb2cbe63f6086fa1/href</a></iframe><h4>Output:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/0*BG4QsRqYg6S7OeZL.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=516a3950269c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/koderunners/intersection-over-union-516a3950269c">Intersection Over Union</a> was originally published in <a href="https://medium.com/koderunners">Koderunners</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Object Detection]]></title>
            <link>https://medium.com/koderunners/introduction-to-object-detection-b9ef0f1ad5c8?source=rss-75239884c307------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9ef0f1ad5c8</guid>
            <category><![CDATA[object-detection]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Soumik Rakshit]]></dc:creator>
            <pubDate>Mon, 15 Apr 2019 13:45:12 GMT</pubDate>
            <atom:updated>2019-04-15T13:52:03.625Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1tRZOxGD2fs15yhI-1D74g.png" /></figure><h3>Image Classification</h3><p>In Image Classification problems we classify an image to a specific class. The whole image represents one class. We don’t want to know exactly where are the object. Usually only one object is presented.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*2o86_RhFA_eeBu5jFGTzWg.jpeg" /></figure><h3>Object Detection</h3><p>Sometimes we need more information from an image rather than just a predicted class. Given an image we want to learn the class of the image and where are the class location in the image. We need to detect a class and a region of interest(usually a rectangle) of where that object is. This is especially useful if a single object is placed in a very small area of an image or multiple objects of same or different classes are present in the image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-YC7uiCtleTmtAA1H0NmWA.jpeg" /></figure><h3>Semantic Segmentation</h3><p>Semantic Segmentation allows us to gather even more information compared to Object Detection. While in Object Detection we usually identify a rectangular region of interest containing a classified object, in Semantic Segmentation we label each pixel in the image with a category label. Semantic Segmentation doesn’t differentiate instances, it only cares about individual pixels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*YLMhuTGxQDIcPIVCtNtkCQ.jpeg" /></figure><h3>Rectangle Detector</h3><p>We will be building a very simple object detection module for detecting single rectangles in images. We will be training a simple classifier using <strong>Keras</strong> that will be predicting the bounding boxes of the rectangles. The code used in this article can be found here on this <a href="https://www.kaggle.com/soumikrakshit/object-detection-single-rectangle">Kaggle Notebook</a>.</p><h3>Importing The Necessary Libraries</h3><p>We will be using <strong>Numpy</strong> for linear algebra, <strong>Matplotlib</strong> for visualization, <strong>Scikit-Learn</strong> for splitting the data into training and test set, <strong>Keras</strong> for building the classifier and <strong>Tensorflow</strong> as the backend of Keras.</p><h4>Code:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a86f4399088eeb072911167069020f91/href">https://medium.com/media/a86f4399088eeb072911167069020f91/href</a></iframe><h4>Output:</h4><pre>Using TensorFlow backend.</pre><h3>Generating the Dataset</h3><p>We will be generating 50000 images of height and width 16, where each image will contain an object. Minimum size of an object will be 1 and maximum size will be 8.</p><p>We will generate 50000 numpy arrays of shape (16, 16), initialize them with 0 and thus we get the background. Then we will take a random patch from the image and set it to 1. This patch will become our object and the coordinates of the object serve as the bounding boxes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8ba78227b018210427cb1f0b12c7ac18/href">https://medium.com/media/8ba78227b018210427cb1f0b12c7ac18/href</a></iframe><h4>Output:</h4><pre>Images shape: (50000, 16, 16)<br>Bounding Boxes shape: (50000, 1, 4)</pre><h3>Visualizing Samples from Generated Images</h3><p>We will display the image in binary format(0 = White and 1 = Black) and plot a rectangular patch on the image denoting the bounding box.</p><h4>Code:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a6d995959cbcc0711a91c62bb71a8ee5/href">https://medium.com/media/a6d995959cbcc0711a91c62bb71a8ee5/href</a></iframe><h4>Output:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/0*CJ-7hWc5coJgCLwP.png" /></figure><h3>Preprocessing</h3><p>In the preprocessing step, we will first flatten the images and the bounding boxes, then normalize the images and then split the dataset into training and test set with 33% of the data being in the test set.</p><h4>Code:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/03fb835b0432096b8ea9131179d9066e/href">https://medium.com/media/03fb835b0432096b8ea9131179d9066e/href</a></iframe><h4>Output:</h4><pre>(50000, 256), (50000, 4)</pre><h3>Model Training</h3><p>We will build a very simple neural network with fully connected layers.</p><ol><li>The Input Layer consists of 256 nodes, since each image has 256 pixels.</li><li>The hidden layer consists of 256 nodes, with an activation function ReLu(Rectified Linear Unit).</li><li>The Output Layer consists of 4 nodes corresponding to the 4 coordinates of a bounding box.</li></ol><h4>Code:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/922a0b766ddf1bcc75609e93987afc69/href">https://medium.com/media/922a0b766ddf1bcc75609e93987afc69/href</a></iframe><h4>Output:</h4><pre>_________________________________________________________________<br>Layer (type)                 Output Shape              Param #   <br>=================================================================<br>dense_1 (Dense)              (None, 256)               65792     <br>_________________________________________________________________<br>activation_1 (Activation)    (None, 256)               0         <br>_________________________________________________________________<br>dense_2 (Dense)              (None, 4)                 1028      <br>=================================================================<br>Total params: 66,820<br>Trainable params: 66,820<br>Non-trainable params: 0<br>_________________________________________________________________</pre><p>We will train the network with adadelta optimizer and the loss function will be mean_squared_error.</p><h4>Code:</h4><p>We will implement a callback to store the learning rate at each epoch and train the model till 30 epochs.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce3536adb44578bef3f46f477266419c/href">https://medium.com/media/ce3536adb44578bef3f46f477266419c/href</a></iframe><h4>Output:</h4><pre>Train on 30150 samples, validate on 3350 samples<br>Epoch 1/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 63us/step - loss: 0.0386 - acc: 0.6658 - val_loss: 0.0257 - val_acc: 0.7651<br>Epoch 2/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 52us/step - loss: 0.0058 - acc: 0.8290 - val_loss: 0.0042 - val_acc: 0.8490<br>Epoch 3/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 51us/step - loss: 0.0026 - acc: 0.8766 - val_loss: 0.0031 - val_acc: 0.8215<br>Epoch 4/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 52us/step - loss: 0.0019 - acc: 0.8901 - val_loss: 0.0019 - val_acc: 0.8991<br>Epoch 5/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 52us/step - loss: 0.0015 - acc: 0.9048 - val_loss: 0.0016 - val_acc: 0.8669<br>Epoch 6/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 53us/step - loss: 0.0013 - acc: 0.9059 - val_loss: 0.0012 - val_acc: 0.8940<br>Epoch 7/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 51us/step - loss: 0.0011 - acc: 0.9066 - val_loss: 0.0014 - val_acc: 0.8764<br>Epoch 8/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 51us/step - loss: 9.7049e-04 - acc: 0.9162 - val_loss: 0.0015 - val_acc: 0.8919<br>Epoch 9/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 51us/step - loss: 8.9787e-04 - acc: 0.9156 - val_loss: 0.0011 - val_acc: 0.9107<br>Epoch 10/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 51us/step - loss: 8.0017e-04 - acc: 0.9162 - val_loss: 9.8927e-04 - val_acc: 0.9364<br>Epoch 11/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 52us/step - loss: 7.3458e-04 - acc: 0.9198 - val_loss: 6.2795e-04 - val_acc: 0.9325<br>Epoch 12/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 52us/step - loss: 6.7894e-04 - acc: 0.9202 - val_loss: 6.7405e-04 - val_acc: 0.9063<br>Epoch 13/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 52us/step - loss: 6.3128e-04 - acc: 0.9209 - val_loss: 8.1824e-04 - val_acc: 0.9304<br>Epoch 14/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 51us/step - loss: 5.7864e-04 - acc: 0.9208 - val_loss: 5.4598e-04 - val_acc: 0.9534<br>Epoch 15/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 52us/step - loss: 5.3993e-04 - acc: 0.9206 - val_loss: 6.0319e-04 - val_acc: 0.9099<br>Epoch 16/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 52us/step - loss: 5.1695e-04 - acc: 0.9234 - val_loss: 4.6435e-04 - val_acc: 0.9242<br>Epoch 17/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 52us/step - loss: 4.7829e-04 - acc: 0.9239 - val_loss: 7.4663e-04 - val_acc: 0.9239<br>Epoch 18/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 51us/step - loss: 4.5803e-04 - acc: 0.9237 - val_loss: 6.2423e-04 - val_acc: 0.9110<br>Epoch 19/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 52us/step - loss: 4.3221e-04 - acc: 0.9238 - val_loss: 4.8555e-04 - val_acc: 0.9316<br>Epoch 20/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 53us/step - loss: 4.1499e-04 - acc: 0.9235 - val_loss: 4.5414e-04 - val_acc: 0.9469<br>Epoch 21/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 52us/step - loss: 3.8647e-04 - acc: 0.9258 - val_loss: 5.5298e-04 - val_acc: 0.9116<br>Epoch 22/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 52us/step - loss: 3.7609e-04 - acc: 0.9251 - val_loss: 4.3545e-04 - val_acc: 0.9269<br>Epoch 23/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 52us/step - loss: 3.4303e-04 - acc: 0.9255 - val_loss: 5.7299e-04 - val_acc: 0.9218<br>Epoch 24/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 52us/step - loss: 3.3132e-04 - acc: 0.9272 - val_loss: 8.2355e-04 - val_acc: 0.9173<br>Epoch 25/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 52us/step - loss: 3.1925e-04 - acc: 0.9266 - val_loss: 5.7306e-04 - val_acc: 0.9230<br>Epoch 26/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 52us/step - loss: 3.0340e-04 - acc: 0.9280 - val_loss: 4.8713e-04 - val_acc: 0.9364<br>Epoch 27/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 51us/step - loss: 2.9643e-04 - acc: 0.9249 - val_loss: 3.5696e-04 - val_acc: 0.8884<br>Epoch 28/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 52us/step - loss: 2.9189e-04 - acc: 0.9269 - val_loss: 3.7836e-04 - val_acc: 0.9555<br>Epoch 29/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 52us/step - loss: 2.7267e-04 - acc: 0.9261 - val_loss: 3.0140e-04 - val_acc: 0.9099<br>Epoch 30/30<br>Learning Rate: 1.0<br>30150/30150 [==============================] - 2s 52us/step - loss: 2.6856e-04 - acc: 0.9250 - val_loss: 3.7276e-04 - val_acc: 0.9469<br>&lt;keras.callbacks.History at 0x7f5d9e326a20&gt;</pre><h3>Prediction and Visualization on Test Set</h3><p>Now we will be get the predicted bounding boxes on the Test set.</p><h4>Code:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6856a2616d16e2b0dd0b08f50a910595/href">https://medium.com/media/6856a2616d16e2b0dd0b08f50a910595/href</a></iframe><h4>Output:</h4><pre>(16500, 4)</pre><p>Let us visualize the predicted bounding boxes on test data.</p><h4>Code:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f968c789d6808403e5d82c2d7bcc347/href">https://medium.com/media/5f968c789d6808403e5d82c2d7bcc347/href</a></iframe><h4>Output:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/0*V2tghjk_A9b1i-aY.png" /></figure><p>Thank you for reading and stay tuned for subsequent articles :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9ef0f1ad5c8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/koderunners/introduction-to-object-detection-b9ef0f1ad5c8">Introduction to Object Detection</a> was originally published in <a href="https://medium.com/koderunners">Koderunners</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pyside Chapter 1: GUI Development in Python]]></title>
            <link>https://medium.com/geekyrakshit/pyside-chapter-1-gui-development-in-python-c0bd5c62594a?source=rss-75239884c307------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0bd5c62594a</guid>
            <category><![CDATA[gui]]></category>
            <category><![CDATA[qt]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pyside]]></category>
            <category><![CDATA[pyside2]]></category>
            <dc:creator><![CDATA[Soumik Rakshit]]></dc:creator>
            <pubDate>Sun, 25 Nov 2018 21:20:43 GMT</pubDate>
            <atom:updated>2018-11-25T21:20:43.934Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*efpknvMvWs-eSu4sMKBIPw.jpeg" /></figure><h3>What is PySide???</h3><p>PySide is a Python binding of the cross-platform GUI development toolkit Qt, currently developed by the Qt company under the <strong>Qt for Python</strong> Project. Pyside provides LGPL-licensed Python bindings for the <strong>Qt 4</strong>. It also includes complete toolchain for rapidly generating bindings for any Qt-based C++ class hierarchies. PySide Qt bindings allow both free open source and proprietary software development and ultimately aim to support Qt platforms. Pyside is a really useful framework used for developing cool looking Graphical User Interfaces easily for your python applications. We would be using <strong>Pyside2</strong>, the latest version of Pyside.</p><h3>Installing Pyside2</h3><ol><li>Create a new conda environment using conda create — name pyside. This will create a new conda environment by the name pyside, which we will be using for installing the necessary dependencies.</li><li>Activate the environment created in the last step using activate pyside. In case you are on Linux, use source activate pyside.</li><li>Install PySide2 in this environment using conda install -c conda-forge pyside2 . It would install all the necessary dependencies along with PySide2.</li></ol><h3>Introduction to Pyside2</h3><p>We will start by creating a simple GUI application displaying a <em>Hello World</em> text on the interface. We will start by importing the necessary libraries.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f8bed6217814bf1c2571a6af8d5b3465/href">https://medium.com/media/f8bed6217814bf1c2571a6af8d5b3465/href</a></iframe><p>While developing a PySide application, we would usually start by importing the PySide2.QtWidgets classes since they have the main functions for implementing a Qt GUI in Python. Next we will start creating our application.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3af535d7cdb80f65730f39fa8c358fa2/href">https://medium.com/media/3af535d7cdb80f65730f39fa8c358fa2/href</a></iframe><p>We start by creating an app which is an instance of the PySide2.QtWidgets.QApplication class. It manages the GUI applications control flow and main settings.</p><p>Next we will be creating a widget. A widget is the smallest unit of a user interface; it receives mouse, keyboard and other events from the window system, and paints a representation of itself which is rectangular in shape on the screen.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/320102607f374efea6e24dbce04ddab1/href">https://medium.com/media/320102607f374efea6e24dbce04ddab1/href</a></iframe><p>We create a widget wid using PySide2.QtWidgets.QWidget class and display it on the screen using the show() method. The method app.exec_() lets us enter the Qt main loop and start executing the Qt code. After execution of the Qt code, when we close the application, the program is terminated by sys.exit().</p><p>We can also change the title of the GUI application using the setWindowTitle() method.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5af747d870b6f293c87fbed9e70fe3e0/href">https://medium.com/media/5af747d870b6f293c87fbed9e70fe3e0/href</a></iframe><p>When we execute the above script, we get the following result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*bkzZJ2LhlTeTUDXTvcwiYg.jpeg" /></figure><p>Now we will try to display some text on the User Interface. This can be achieved using the PySide2.QtWidgets.QLabel . While QWidget creates a blank widget, QLabel creates a widget that provides text or image display.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/edaef794783094a9f6732be3195ae301/href">https://medium.com/media/edaef794783094a9f6732be3195ae301/href</a></iframe><p>We create a label initialized with out display string “Hello World!”. Then we resize the label widget and set a title for it and display it using show(). The result on running this script will be:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*J-dVAN4QjfOyXPgiFC2EoA.jpeg" /></figure><p>As you can see that the display string is not only small in size but is also not properly aligned which surely does not make it look good. We can fix this by initializing the label with custom HTML instead of pain string.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/411db0ed100251b49329ca08b757c10d/href">https://medium.com/media/411db0ed100251b49329ca08b757c10d/href</a></iframe><p>The output this time will be:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*l5mNCFw6ONKAoilXToCT8A.jpeg" /></figure><p>For the next articles on PySide and more such articles, stay tuned on <a href="https://geekyrakshit.ml/">https://geekyrakshit.ml</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0bd5c62594a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekyrakshit/pyside-chapter-1-gui-development-in-python-c0bd5c62594a">Pyside Chapter 1: GUI Development in Python</a> was originally published in <a href="https://medium.com/geekyrakshit">GeekyRakshit</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>