<?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 Kirti Pande on Medium]]></title>
        <description><![CDATA[Stories by Kirti Pande on Medium]]></description>
        <link>https://medium.com/@kirti.kp.94?source=rss-12116ee2bf36------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hYEJcWy0wBxVz__O_VHhOA.jpeg</url>
            <title>Stories by Kirti Pande on Medium</title>
            <link>https://medium.com/@kirti.kp.94?source=rss-12116ee2bf36------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 03:33:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kirti.kp.94/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[Enrich your pre-existing data and build lighter and compact models!]]></title>
            <link>https://medium.com/walmartglobaltech/enrich-your-pre-existing-data-and-build-lighter-and-compact-models-976540093f54?source=rss-12116ee2bf36------2</link>
            <guid isPermaLink="false">https://medium.com/p/976540093f54</guid>
            <category><![CDATA[walmart]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-enrichment]]></category>
            <category><![CDATA[ml-model]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Kirti Pande]]></dc:creator>
            <pubDate>Tue, 23 Aug 2022 16:51:00 GMT</pubDate>
            <atom:updated>2022-08-23T17:39:26.412Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*32vY3qFaeN38adreXr4gxQ.jpeg" /><figcaption>Picture credit: <a href="https://pixabay.com/">PixaBay</a></figcaption></figure><h4><strong>A guide to evaluating vendors within data science organizations</strong></h4><p>Leveraging Data Science and data intelligence has made its way into almost every business domain bolstering decision making. However, every company has a limitation on the kind of data it may capture as well as the infrastructure to support complex data models. This blog post talks about how companies may utilize data intelligence provided by external vendors to enrich their pre-existing data collection as well as build lighter and compact models. This article also introduces the process of evaluating external vendors before onboarding them.</p><p><strong><em>What are the benefits of vendor data?</em></strong></p><p>A product or business owner such as an e-Commerce merchant can access internal data, related to activities within their ecosystem alone. However, having access to customer behavior and information outside this ecosystem can provide a different perspective. This additional information in conjunction with the existing data collection normally result in improved feature intelligence.</p><blockquote>The addition of external vendor data is particularly beneficial to aid decision on thin files or new customers on the product</blockquote><p>This is because external data vendors normally establish consortiums of data collected from omni channels such as banks, e-commerce, social media, etc. Nevertheless, the type of data supply varies amongst different vendors. Some vendors simply provide raw data, and many others carry out feature engineering and/or provide scores based on their internal machine learning models. Usually vendors with sophisticated business models, require the merchant to share its data to enrich the former’s consortium as well, when utilizing their services.</p><p><strong><em>How can a merchant choose amongst various external data vendors in the market?</em></strong></p><p>The author has worked on vendor evaluation for E-Commerce payment risk management in the past few years and drove the process from end to end, including vendor research, proof of concept, evaluation, comparison, and onboarding. Here are the highlights of the process:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*9wn3h72HYL5ZGOTKfTDwEQ.png" /></figure><h3><strong>Problem assessment:</strong></h3><p><strong>Step 1:</strong> Before reaching out to a vendor, problem assessment and a good understanding of the data needs and business goals should be established. This helps a merchant narrow down the search scope.</p><p><strong>Step 2:</strong> Once the goals and the data needs are understood, an initial assessment of the vendors based on criteria around a merchant’s policies, internal onboarding process requirements, budget, etc. should be conducted. The business should participate in this assessment process. Some key points to keep in mind when screening these vendors:</p><p><em>a. Understanding the customer base of the vendors and whether they match the merchant’s customer</em></p><p><em>b. The age and status of the vendor and the product offered</em></p><p><em>c. The vendor reputation or presence of any legal action against them</em></p><p><em>d. Sometimes, the vendor’s product depends on technology providers which compete with the merchant, communications regarding the merchant’s concerns should be taken place before the POC stage</em></p><p><strong>Step 3:</strong> Before starting the next steps, the cost of the Proof-of-Concept stage and Evaluation should be finalized and approved by business. <strong><em>Also, it should go through any privacy and compliance assessment especially if sensitive information is involved.</em></strong></p><h3><strong>Proof of Concept:</strong></h3><p><strong>Steps 4:</strong> Next, kicking off the Proof-of-Concept process. The data science or analytics team prepares an encrypted dataset according to the merchant’s policies and shares it with all vendors under evaluation. It is worth noting that the data set should <strong><em>include an identifier</em></strong> for every entry to link it back to the original or other records. Besides, the data set should <strong><em>include a timestamp</em></strong> (when the event occurred) for every entry. A merchant should never include confidential information such as performance in the data set.</p><p><strong>Step 5:</strong> The vendor is supposed to <strong><em>return point-in-time data</em> </strong>subject to (on or before) the timestamp. This is because the purpose of Proof of Concept is to evaluate the vendor data provided at the point of time when the particular transaction or data entry took place to simulate real time response from the vendor.</p><h3><strong>Evaluation:</strong></h3><p><em>Once the vendor appends the data set with its own data intelligence and returns to the merchant, what are the next steps?</em></p><p><strong>Step 6:</strong> Generally speaking, there are three major approaches to evaluate the vendor’s data:</p><p>i. Check for a <strong><em>lift in the performance</em></strong> or essential KPIs of the existing models/solutions while consuming the vendor’s data directly</p><p>ii. Ensemble the existing models/solutions with feature engineering on the vendor’s data and check for any lift in the performance or essential KPIs. This improvement in performance can be measured by assessing<strong> <em>lift/gains charts as well as improvement in the precision and recall </em></strong>of the solutions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*myw24g5TTwzwR72m70pUjw.png" /></figure><blockquote>Note that due to the possible high correlation between the variables which generate the existing models and the new vendor data, it is not unusual that a merchant may observe a declined performance while comparing to the baseline performance</blockquote><p>iii. The <strong><em>data coverage or response rate</em></strong><em> </em>is also a critical evaluation metrics to consider. It is always appealing to choose the vendor whose data has a high coverage rate as opposed to others.</p><p>iv. The <strong><em>Return-on-Investment analysis/calculation</em></strong> should be carried out to assess if the benefits or lift in the performance is worth the investment being made on onboarding the vendor</p><p><strong>Step 7:</strong> Discussions with the engineering team about the<strong> <em>additional SLA</em></strong> due to the time taken by the vendor to provide the response in real time should be conducted. After all, a merchant does not expect the vendor integration in real time to adversely impact customer experience.</p><p><strong>Step 8:</strong> The <strong><em>Tech support</em></strong> offered by the vendor post the implementation should be discussed before finalizing the vendor</p><h3><strong>Implementation:</strong></h3><p><strong>Step 9:</strong> When a vendor has been finalized it is always beneficial to incorporate the vendor data in stage environment first for thorough end to end testing before going into production. All involved stakeholders should be a part of this process to assess no errors on their fronts.</p><p><strong>Step 10:</strong> Once the vendor integration completes and the data goes live, a merchant should continue monitoring and <strong><em>setup alerting calls</em></strong> in case of any drop in the response from the vendor due to technical issues or outages.</p><blockquote>Lastly, it is a good practice to continuously evaluate the value of the vendor data every couple of months. Touching base with the vendor involved regularly and understanding new observations in customer behavior from their perspective is a beneficial practice.</blockquote><p>A well-functioning data enrichment process is fundamental to the providing successful customer experience for a product in this data centric world. In this data driven day and age there are numerous vendors providing access to variety of data like geographical, behavioral, financial, etc. but it is designing the right data enrichment strategy and choosing the appropriate vendor which is integral in making this process truly value-adding to one’s business needs and objectives.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=976540093f54" width="1" height="1" alt=""><hr><p><a href="https://medium.com/walmartglobaltech/enrich-your-pre-existing-data-and-build-lighter-and-compact-models-976540093f54">Enrich your pre-existing data and build lighter and compact models!</a> was originally published in <a href="https://medium.com/walmartglobaltech">Walmart Global Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Questions pairs identification]]></title>
            <link>https://medium.com/data-science/questions-pairs-identification-f8abcafb5b17?source=rss-12116ee2bf36------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8abcafb5b17</guid>
            <category><![CDATA[questions]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[attention]]></category>
            <category><![CDATA[quora]]></category>
            <dc:creator><![CDATA[Kirti Pande]]></dc:creator>
            <pubDate>Fri, 15 Mar 2019 20:44:38 GMT</pubDate>
            <atom:updated>2019-03-17T06:31:08.382Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Question pairs identification</strong></h3><h4><em>There are no stupid questions…only duplicates!</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KDndaWBDKNZueHu__K4bwg.jpeg" /></figure><h3>Background</h3><p>You have a burning question — you login to Quora, post your question and wait for responses. There is a chance that what you asked is truly unique but more often than not if you have a question, someone has had it too. Did you notice that Quora tells you that a similar question has been asked before and gives you links directing you to it? How does Quora detect that the question you just asked matches with the other questions already asked before?</p><p>Intrigued by this question, my team — <a href="https://medium.com/u/14b152ad8569">Jui Gupta</a>, <a href="https://medium.com/u/140754e8ee4d">Sagar Chadha</a>, <a href="https://medium.com/u/7dcece871f74">Cuiting Zhong</a> and I decided to work on the Kaggle Quora duplicate questions challenge. The goal was to use sophisticated techniques to understand question semantics and highlight duplicate (similar) questions.</p><p><strong><em>But why would a company want to highlight duplicate questions?</em></strong></p><ol><li><em>Cheaper data storage</em> — Storing less questions! Obviously!</li><li><em>Improved Customer Experience </em>— Faster responses to questions.</li><li><em>Re-use content </em>— If a question has been answered before, it is very efficient to use the same answer for a similar question.</li></ol><h3><strong>The Data</strong></h3><p>The data set consisted of around 400,000 pairs of questions organized in the form of 6 columns as explained -</p><p><strong>id:</strong> Row ID</p><p><strong>qid 1, qid 2:</strong> The unique ID of each question in the pair</p><p><strong>Question 1, question 2:</strong> The actual textual contents of the questions.</p><p><strong>is_duplicate:</strong> Label is 0 for questions which are semantically different and 1 for questions which essentially would have only one answer (duplicate questions). 63% of the questions pairs are semantically non-similar and 37% are duplicate questions pairs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EdV50Fi5ye59bjQn" /><figcaption>A look at the data</figcaption></figure><h4><strong>Data</strong> <strong>exploration</strong></h4><p>An analysis of the data showed the most common words in the questions were the following -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jGFfJobHCiyibh-Z" /><figcaption>Word cloud for most common words</figcaption></figure><p><strong>Duplicate questions marked as not duplicate</strong></p><p>We also found some question pairs that, although duplicate, were marked as 0 in the labels. Some of these are shown below -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hNqfExrf3kmxVqUU9eFvUA.png" /><figcaption>Duplicates marked as different</figcaption></figure><p>The labels for these questions were changed to 1 to improve the accuracy of the model!</p><p><strong>Modelling Approach</strong></p><p>A very simple approach to detecting similarity between a pair of questions would be to look at unique words in the first question that are also present in the second question as a ratio of the total words in both questions. This number could then be used in a simple model such as logistic regression to predict duplicate versus different questions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uw32LZtTvSVbXexwY51dcA.png" /><figcaption>Word Similarity between questions</figcaption></figure><p>This approach has limitations since two questions with very few words in common can still have the same meaning. This could be due to different sentence structures, use of synonyms, etc. Consider the sentences “<em>What to do to be a data scientist</em>” and “<em>What qualities make a good data scientist</em>”. While these have very few common words (exclude stopwords), the intent of the asker is the same. In order to go beyond comparing words in a sentence, we need a way to understand the semantic meaning of the questions in consideration.</p><h4><strong>Sentence Embedding</strong></h4><p>Generating sentence embedding is a three step process -</p><ol><li><strong>Sentence Tokenization</strong> — Using all the questions in our data, we create a large dictionary that maps each word to a unique integer index. This dictionary is then used to convert sentences from sequences of strings to sequences of integers.</li><li><strong>Zero Padding — </strong>The next step in the process is to ensure that the input to the model (neural network) is of uniform length. To accomplish this, we chose a maximum length for each of the questions — 25 in our analysis— and then truncated or 0 padded the sentences to this length. 0s are inserted at the beginning of sentences that are fewer than 25 words in length.</li><li><strong>Embedding matrix — </strong>Finally, we use a pretrained word embedding to convert each word into a vector representation. Each word is converted into a 300 long vector.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h3ZmArCWVGS-px60" /><figcaption>Process to get sentence embedding</figcaption></figure><p>The process described above creates a data tensor from our text data of dimensions — (200000, 25, 300) for each of question 1 and question 2. This serves a dual purpose -</p><ol><li>Converts text strings to numbers that can be used to train a neural network</li><li>Gives a representation of our data that encodes the meaning of and relationship between the words. Using simple mathematics, we can determine if two words are similar in meaning or completely opposite.</li></ol><p>The data tensor so created is then sent through a neural network model for training which we describe below.</p><h4><strong>Bag of Embedding Approach</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Kq1y8uKLPGpBIFER" /></figure><p>The embedding created using the methodology above is then to be passed through the network drawn above. Let’s see what is happening in the network above -</p><p><strong>Time Distributed Dense Layers</strong> — These are used for temporal data when we want to apply the same transformation to every time-step. In our data set, each question has 25 words which correspond to 25 time steps. We use a dense layer with 300 hidden inputs — since our data has 300 dimensional embedding, we get 90,000 + 300 (bias) = 90,300 weights for the layer. Both question 1 and question 2 pass through similar time distributed layers.</p><p>The below diagram makes clear the transformation —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*V-NEHyPW01q2BXgC" /><figcaption>Time Distributed Dense Layers</figcaption></figure><p>Each of the 300 hidden units in the time distributed dense layer (shown in orange) connect with the word vectors at each time step (shown in blue) and produce higher order representations (shown in green). All the dense layer units have the ‘Relu’ activation for non-linearity.</p><p><strong>Lambda layers</strong> — Lambdas in Keras are like the <em>‘def</em>’ keyword in python — they allow us to use custom layers in our model. We use the lambda layer on the higher order representations obtained after the time distributed dense layers to get an average sense of the meanings of all the words in the question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tGgjtgAyBXyqj8IM" /><figcaption>Lambda layers</figcaption></figure><p>Computing the average, in essence, computes an aggregate representation of the question in 300 dimension. This encapsulates the meaning of the entire question in those dimensions. Average is just one of the possible aggregations, there are others possible aggregations such as max, sum, etc.</p><h4><strong>Bi-LSTM with Attention Approach</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xiFq0B-qvV9bqe7H" /></figure><p>The simple bag of embedding model architecture mentioned above did achieve a pretty good accuracy. Then why bother to use Bidirectional LSTM and attention layer?</p><p>When we went back and manually checked the question pairs causing the highest mis-classifications, we found that it was mostly due to the longer sentences. This makes sense because we had not accounted for a way to capture and implement words in the previous and future state into our present state. This requires to implement an adaptive gating mechanism which is provided by networks like LSTMs. On researching we were lucky to find a paper on using Bidirectional LSTMs for relational classification, which was used in tasks like image captioning, question answering and so on.</p><p>Now coming to the model, the changes we made involved adding a Bidirectional LSTM after the word embedding stage to incorporate higher level features into out embedding vectors. After this, unlike before where we were concatenating the questions, we implement attention by carrying out similarity between the pairs.</p><p><strong>Attention layer </strong>— Unlike the previous bag of words the attention layer involves calculation of a dot product between the questions followed by a dense layer without any non linearity.</p><p>After finishing modeling, how did we evaluate our models?</p><p>Since it was a binary classification task we used the <strong>binary cross entropy (log loss)</strong> to calculate our accuracy.</p><p><strong>Binary cross entropy</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cPAA-ndYYcfsQ7Vo" /></figure><p>The baseline accuracy is 63% because that’s how our data was split. Here’s the model performance for models we built.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XBm5DhCUpm3-6_d6" /><figcaption>Model accuracy for our analysis</figcaption></figure><p><strong>Future Work</strong></p><ul><li>Use different pretrained embeddings for the model. e.g. Word2Vec, fasttext</li><li>Try different similarity measure in embedding concatenation. e.g. Manhattan distance</li><li>Extract and combine other additional NLP features. e.g. number/proportion of common words</li><li>Another interesting problem that utilizes the same concept is that of question answering using a context passage. We can attempt that.</li></ul><h3>References</h3><p>None of this work could have been done on our own. Check out the following references to get access to all the great resources we used:</p><ul><li><a href="https://www.aclweb.org/anthology/P/P16/P16-2034.pdf">https://www.aclweb.org/anthology/P/P16/P16-2034.pd</a>f</li><li><a href="https://nlp.stanford.edu/pubs/snli_paper.pdf">https://nlp.stanford.edu/pubs/snli_paper.pdf</a></li><li><a href="https://www.kaggle.com/c/quora-question-pairs/data">https://www.kaggle.com/c/quora-question-pairs/data</a></li><li><a href="https://github.com/bradleypallen/keras-quora-question-pairs">https://github.com/bradleypallen/keras-quora-question-pairs</a></li><li><a href="https://github.com/Smerity/keras_snli">https://github.com/Smerity/keras_snli</a></li><li><a href="https://towardsdatascience.com/building-a-question-answering-system-part-1-9388aadff507">https://towardsdatascience.com/building-a-question-answering-system-part-1-9388aadff507</a></li></ul><p>Feel free to let us know what you think and ways we can improve upon what we have! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8abcafb5b17" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/questions-pairs-identification-f8abcafb5b17">Questions pairs identification</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Doodling with Deep Learning!]]></title>
            <link>https://medium.com/data-science/doodling-with-deep-learning-1b0e11b858aa?source=rss-12116ee2bf36------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b0e11b858aa</guid>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[image-classification]]></category>
            <category><![CDATA[kaggle-competition]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Kirti Pande]]></dc:creator>
            <pubDate>Fri, 14 Dec 2018 23:11:10 GMT</pubDate>
            <atom:updated>2018-12-15T15:33:59.786Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zMhUUzPiTtZO9BkzlbdFvQ.jpeg" /></figure><h4><strong><em>Our Journey with Sketch recognition</em></strong></h4><p>In this blog post, we describe our process understanding, fitting models on, and finding a fun application of the Google Quick, Draw! dataset. Walk with us through this journey to see how we have tackled the challenge of successfully classifying what is “arguably the world’s cutest research dataset!”</p><p>This project was built by Akhilesh Reddy, Vincent Kuo, Kirti Pande, Tiffany Sung, and Helena Shi. To see the full code used, find our <a href="https://github.com/QuickDraw-sketchRecognition/Sketch_Recognition/">github</a>:</p><h3><strong>I. Background</strong></h3><p>In 2016, Google released an online game titled “Quick, Draw!” — an AI experiment that has educated the public on neural networks and built an enormous dataset of over a billion drawings. The game itself is simple. It prompts the player to doodle an image in a certain category, and while the player is drawing, the neural network guesses what the image depicts in a human-to-computer game of Pictionary. You can find more information on the game <a href="https://cloud.google.com/blog/products/gcp/drawings-in-the-cloud-introducing-the-quick-draw-dataset">here</a> or play the <a href="https://quickdraw.withgoogle.com/">game yourself</a>!</p><p>Since the release of 50 million drawings in the dataset, the ML community has already begun exploring applications of the data in improving handwriting recognition, training the <a href="https://ai.googleblog.com/2017/04/teaching-machines-to-draw.html">Sketch RNN</a> model to teach machines to draw, and more. Notably, it has robust potential in OCR (Optical Character Recognition), ASR (Automatic Speech Recognition) &amp; NLP (Natural Language Processing), and reveals lovely insights into how people around the world are<a href="https://www.blog.google/technology/ai/quick-draw-one-billion-drawings-around-world/"> different, yet the same</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*Y4rwYwnMP0yGRfgkOgrGQA.gif" /></figure><h3><strong>II. The Data</strong></h3><p>Our total data size is 73GB with 50 million drawings in 340 label classes. Each drawing comes with specific variables:</p><ul><li>“<strong>word</strong>” — the class label of that drawing</li><li>“<strong>country code</strong>” — country of origin of the drawer</li><li>“<strong>timestamp</strong>” — timestamp of the drawing</li><li>“<strong>recognized</strong>” — indication of the app’s successful prediction</li><li>“<strong>drawing</strong>” — stroke-base data specific for doodle images; each drawing is made up of multiple strokes in the form of matrices</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Rh_7QVwsl52eUlqo" /><figcaption>As seen here, each point in a stroke corresponds to an x-coordinate, y-coordinate, and time point</figcaption></figure><h3><strong>III. Approach</strong></h3><p>We began by understanding the structure of arrays that make up a sketch and pre-processing the data. Then, we delve into fitting some simple classifiers and a basic convolutional neural network, or CNN. From there, we tackle CNN architectures such as ResNet and MobileNet. Finally, we shared our results with the world by participating in a <a href="https://www.kaggle.com/c/quickdraw-doodle-recognition">Kaggle competition</a>.</p><p>Due to the large size of the data and need for a higher capacity GPU, we implemented CNN structures on the Google Cloud Platform, which has a handy free trial with $300 of credits. To find out how we did so, follow links <a href="https://medium.com/@alamhanz/jupyter-notebook-on-gcp-for-pythoners-18a8e7a73a56">here</a> and <a href="https://medium.com/google-cloud/using-a-gpu-tensorflow-on-google-cloud-platform-1a2458f42b0">here.</a></p><h3><strong>IV. Data Preprocessing</strong></h3><p>The data exists in a format of separate CSV files for drawings of each class label. Therefore, we first shuffled the CSVs, creating 100 new files with data from all classes to ensure the model received a random sample of images as input and remove bias.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/204c1898f6a7e6c1373e78e854a4d947/href">https://medium.com/media/204c1898f6a7e6c1373e78e854a4d947/href</a></iframe><p>Most people draw doodles in similar ways. For example, if I asked you to draw a sun, you would begin with a single circle, and then dash lines radiating from the center in clockwise order. To capture this information, we used greyscale/color-coded processing<strong> </strong>to take advantage of the RGB channel while building the CNN so the model could recognize differences between each stroke. We assigned a color to each chronological stroke of a doodle, thus allowing the model to gain information on individual strokes instead of only the whole image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EpwcOTYXQlX2qvqT27J5CQ.png" /><figcaption>Violin (left) in black &amp; white; Mermaid (right) color-encoded</figcaption></figure><p>We also augmented the images by randomly flipping, rotating or blocking parts to introduce noise into the images and increase the capacity of the model to tackle noise. In the course of the game, some players don’t finish their doodles or draw in different angles. The augmentation can yield information to the model in those cases.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ea5cdd546011779f8eccf1c9f6d05c68/href">https://medium.com/media/ea5cdd546011779f8eccf1c9f6d05c68/href</a></iframe><p>Both the greyscale/color encoding and image augmentation used OpenCV and ImageGenerator from keras<strong>,</strong> which loads batches of raw data from csv files and transforms them into images.</p><h3><strong>V. Building Models</strong></h3><p>After completing all the data collection and preprocessing steps, it was time to get started on the most interesting part of the project — model building!</p><p>Before we dove into CNN, we tried some basic classifiers to compare different machine learning algorithms and familiarize ourselves with the data. We pulled numpy files of the data from <a href="https://console.cloud.google.com/storage/browser/quickdraw_dataset/full/numpy_bitmap//">Google Cloud Storage</a>. This data has already been preprocessed and rendered into a 28x28 grayscale bitmap in numpy .npy format. Since the entire dataset included over 345 categories, we eventually went with a small subset that only contains the following 5 classes: airplane, alarm clock, ambulance, angel and animal migration.</p><h4><strong>Random Forest</strong></h4><p>We first began with a Random Forest classifier. We utilized GridSearchCV to cross-validate the model and optimize parameters. We found that accuracy tends to plateau after 100 trees, so we used n_estimators = 100 as our final model, returning an accuracy of 0.8291.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff508111f2b91b42b913770a54a4a40f/href">https://medium.com/media/ff508111f2b91b42b913770a54a4a40f/href</a></iframe><h4><strong>KNN</strong></h4><p>Secondly, we tried the k-Nearest Neighbor (kNN) classifier, arguably the simplest and easiest model to understand. Its algorithm classifies unknown data points by finding the most common class among the k-closest examples. We cross validated the n_neighbors and found that the best model given is k = 5, which returns 0.8752 accuracy.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b51752afb4e537143594f083ed307d4e/href">https://medium.com/media/b51752afb4e537143594f083ed307d4e/href</a></iframe><h4><strong>Multi-Layer Perceptron (MLP)</strong></h4><p>Lastly, we tried the Multi-Layer Perceptron (MLP) from scikit-learn. We cross validated over different hidden layer sizes and learning rates, deciding on a hidden layer size of (784,) and learning rate alpha = 0.001, which gave accuracy of 0.8654.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/13cfb289d93ebdfcc0d3a4f1d9d49f5c/href">https://medium.com/media/13cfb289d93ebdfcc0d3a4f1d9d49f5c/href</a></iframe><h4><strong>Convolutional Neural Network</strong></h4><p>We then moved on to a simple CNN model to set a lower threshold for model performance and understand the nuances and execution time of the model. In this model, we used the drawing information in the data to create an image of the desired size using OpenCV. Here we tried a bunch of different parameters as shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JerL1vSPnC-21bFLWu9_Sw.png" /></figure><p>Here is some intuition behind our parameters settings. Firstly, a larger batch size would help in addressing the noise due to mislabeled training data. The size parameter denotes the image size/resolution and has significant impact on accuracy. For example, a comparison of 32x32 and 128x128 shows us that a size of 32x32 is too pixelated to achieve an accurate model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RWYJH28fDFahfnRIhJXryw.png" /><figcaption>32x32 (left), 128x128 (right)</figcaption></figure><p>The first model used two convolutional layers, each with depth of 128. Such an increase in image size, however, required either a larger receptive field conv layer or an additional conv layer. Accordingly, we included one more layer when training with larger image size. Below is the custom CNN model that we created with number of convolutional layers, dense layers, dropout and size as the parameters while building the model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/39e26033d7522909011f53abf0ebb6c2/href">https://medium.com/media/39e26033d7522909011f53abf0ebb6c2/href</a></iframe><p>As we were still deciding on the best model to proceed further with the analysis, we used limited data at the initial step to lessen execution time.</p><h4>Selecting an Optimizer</h4><p>A key step before proceeding with training is deciding which optimizer to use. After referring to the literature and taking advice from experts on various Kaggle forums, we decided to compare the performance of the Adam optimizer and the SGD optimizer on our data. After multiple iterations, we chose the Adam optimizer because we observed that it showed slightly better results and converged faster than SGD.</p><p>After running the model on 25000 images per class for about 3 hrs, we obtained a MAP@3 score of 0.76 on Kaggle’s Public Leaderboard — not a bad result for merely 25000 images per class! To put this into perspective, the average class in the dataset contains 150000 images. However, when we increased the model complexity, the accuracy slightly degraded, which led us to our next step: ResNet.</p><h4><strong>SE-ResNet-34, SE-ResNet-50:</strong></h4><p>When increasing the depth of the model, it is likely to face issues like vanishing gradient and degradation; comparatively, deeper models perform worse than simpler ones. A Residual Network, or ResNet is a neural network architecture that solves the problem of vanishing gradients and degradation issue in the simplest way possible by using deep residual learning.</p><p>In simple words, during back propagation, when the signal is sent backwards, the gradient always must pass through <em>f(x)</em> (where <em>f(x)</em> is our convolution, matrix multiplication, or batch normalization, etc), which can cause trouble due to the non-linearities which are involved.</p><p>The “<em>+ x</em>” at the end is the shortcut. It allows the gradient to pass backwards directly. By stacking these layers, the gradient could theoretically “skip” over all the intermediate layers and reach the bottom without being diminished.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LQihgrosKsSy_z0LMNLxMw.png" /></figure><p>You can refer to the <a href="https://arxiv.org/pdf/1512.03385.pdf">original paper</a> to further understand the comparisons between a 34 layer plain network and and a 34 layer residual network.</p><p>In this step of the process, we trained SE-ResNet-34 and 50 as a step further from simple CNN. The term SE refers to Squeeze and Excitation Net; with it, an additional block gives weights to different channels. The SE blocks were proven to provide additional accuracy by giving the weights yet merely increased less than 10% of total parameters. More information on Squeeze &amp; Excitation Nets can be found <a href="https://arxiv.org/pdf/1709.01507.pdf">here</a>.</p><p>While training of SE-ResNet-50, we tried different parameters as the following for 50 to 60 epochs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_xsWmk91oK9F6C5dBvXp3A.png" /></figure><p>Finally, out of all the combinations, the batch size of 512 and image size of 128x128 gave the best improvement to the score, boosting it to 0.9093. It is important to note that changing the batch size and image size is based on the GPU that we were using and that these were the maximum possible parameters on Tesla k80 for our data.</p><h4>MobileNet</h4><p>After multiple iterations with SE-ResNet and with the competition deadline quickly approaching, we decided to explore MobileNet, which gave comparable accuracy yet executed much more quickly.</p><p>MobileNet was introduced by Google to enable the delivery of the latest technologies such as object, logo, and text recognition for customers anytime, anywhere, irrespective of Internet connection. MobileNets are based on a streamlined architecture that uses depth-wise separable convolutions to build lightweight deep neural networks.</p><p>To put this into perspective, a standard convolution does the application of filters across all input channels and the combination of these values in a single step. In comparison, a depthwise separable convolution performs two different steps:</p><ol><li><em>Depthwise convolution</em> applies a single filter to each input channel</li><li><em>Pointwise convolution</em>, a simple 1×1 convolution, is then used to create a linear combination of the output of the depthwise layer</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RZQdgPu1yEtw-INA_G2XyQ.png" /></figure><p>This factorization drastically reduces computation and model size as it breaks the interaction between the number of output channels and the size of the kernel. According to the original paper on MobileNet, MobileNet showed a reduction in computation costs by at least 9 times. For further details, you can refer to the <a href="https://arxiv.org/pdf/1704.04861.pdf">original paper on MobileNet</a>.</p><p>For simplicity’s sake, we used the simple, 2-line, standard module of MobileNet in keras.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f636da95d2543f2b63ba7e465ebf4a7f/href">https://medium.com/media/f636da95d2543f2b63ba7e465ebf4a7f/href</a></iframe><p>Before training the mode, we ensured that we used all 50 MM images to train the model and included the order of stroke information through a greyscale gradient for each stroke. After multiple iterations, we came upon the following parameters as optimal parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*msvVPuAbaX3VH_BgjkYWYw.png" /></figure><h3>VI. Results</h3><p>We began training the model on 50MM drawings and 340 classes on a Tesla P100 GPU provided by Google Cloud platform. After training for 20 hours and spending $50 of GCP credits, we finally reached a score of 0.9211 using MobileNet on the Kaggle leaderboard, which helped us secure a rank of 268 among the 1316 teams that participated in the competition!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*evWJa5_ePq89sil9" /></figure><p>Here you can see an overall summary of our models’ parameters and results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kn10jVBU_Gp81CapU-hzFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GewRz58IEGF1jLcRrCNAgQ.png" /></figure><p>Following are some examples of our predictions!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KrVPXIFWyS01fvdDZrkXCA.png" /></figure><h3>A Fun Bonus!</h3><p>If you’ve stuck it through and read to this point, extra points for you! As a fun treat, we decided to also spice things up a little and created an application that could capture doodles via webcam! The app used our model to carry out predictions in real time. OpenCV functions were utilized to capture the video from the webcam and extract the images drawn.</p><p>We used the first Simple CNN model as our back-end since it was the lightest model we had run. The model is trained on the 15 classes (listed below) and achieves an 87% accuracy to detecting the doodle drawn.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WJdHXy06O_XREZ864TS41Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Ys_EtaceCKyQw5TyiowcUQ.gif" /></figure><h3>VII. Conclusion</h3><p>As a conclusion, we’ll summarize the steps taken in this winding journey:</p><ol><li>Wracked our brains to understand the unique structure of doodle data and figured out how to connect with Google Cloud Platform to run the models</li><li>Performed data cleaning &amp; preprocessing through shuffling csvs and augmenting images with stroke information and more</li><li>Ran reduced dataset of five classes on three simple classifiers on our local system</li><li>Implemented Deep learning models from a simple CNN to ResNets and MobileNets</li><li>Submitted results to the competition, gave ourselves a big pat on the back, and celebrated the end of the project by creating an app!</li></ol><p>Following are some lessons learned while training a deep learning network:</p><ul><li>Get one basic implementation of the algorithm and test it on a smaller dataset first to save execution time</li><li>Explore all the available GPU options and alternate between them based on the computational intensity that is required for the task</li><li>Reduce learning rate with increases in epochs. We have a built in function called ReduceLRonplateau to perform this operation. This impacts the learning of the model during the plateau</li></ul><p>Overall, this project was incredibly rewarding! As graduate students, we seized the opportunity to both (hopefully!) impress our professor and participate in prestigious competition. We were able to challenge ourselves by tackling image classification for the first time and came out with more than satisfactory results.</p><h3>References</h3><p>None of this work could have been done on our own. Check out the following references to get access to all the great resources we used:</p><p><a href="https://cloud.google.com/blog/products/gcp/drawings-in-the-cloud-introducing-the-quick-draw-dataset">https://cloud.google.com/blog/products/gcp/drawings-in-the-cloud-introducing-the-quick-draw-dataset</a><br><a href="https://ai.googleblog.com/2017/04/teaching-machines-to-draw.html">https://ai.googleblog.com/2017/04/teaching-machines-to-draw.html</a><br><a href="https://www.kaggle.com/c/quickdraw-doodle-recognition">https://www.kaggle.com/c/quickdraw-doodle-recognition</a><br><a href="https://www.blog.google/technology/ai/quick-draw-one-billion-drawings-around-world/">https://www.blog.google/technology/ai/quick-draw-one-billion-drawings-around-world/</a><br><a href="https://www.kaggle.com/gaborfodor/shuffle-csvs">https://www.kaggle.com/gaborfodor/shuffle-csvs</a><br><a href="https://www.kaggle.com/remidi/simple-strokes-to-rgb-kernel">https://www.kaggle.com/remidi/simple-strokes-to-rgb-kernel</a><br><a href="https://www.kaggle.com/titericz/black-white-cnn-lb-0-782">https://www.kaggle.com/titericz/black-white-cnn-lb-0-782</a><br><a href="https://stats.stackexchange.com/questions/148139/rules-for-selecting-convolutional-neural-network-hyperparameters">https://www.google.com/url?q=https://stats.stackexchange.com/questions/148139/rules-for-selecting-convolutional-neural-network-hyperparameters&amp;sa=D&amp;ust=1544740608219000&amp;usg=AFQjCNGwJl5GpZwWpKmpFclt6qiNwwQnHA</a><br><a href="http://ruder.io/optimizing-gradient-descent/index.html#adam">http://ruder.io/optimizing-gradient-descent/index.html#adam</a><br><a href="http://cs231n.stanford.edu/reports/2016/pdfs/264_Report.pdf">http://cs231n.stanford.edu/reports/2016/pdfs/264_Report.pdf</a><br><a href="https://chatbotslife.com/resnets-highwaynets-and-densenets-oh-my-9bb15918ee32">https://chatbotslife.com/resnets-highwaynets-and-densenets-oh-my-9bb15918ee32</a><br><a href="https://www.kaggle.com/jpmiller/image-based-cnn">https://www.kaggle.com/jpmiller/image-based-cnn</a><br><a href="https://console.cloud.google.com/storage/browser/quickdraw_dataset/full/numpy_bitmap//">https://console.cloud.google.com/storage/browser/quickdraw_dataset/full/numpy_bitmap//</a><br><a href="https://github.com/akshaybahadur21/QuickDraw">https://github.com/akshaybahadur21/QuickDraw</a><br><a href="https://chatbotslife.com/resnets-highwaynets-and-densenets-oh-my-9bb15918ee32">https://chatbotslife.com/resnets-highwaynets-and-densenets-oh-my-9bb15918ee32</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b0e11b858aa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/doodling-with-deep-learning-1b0e11b858aa">Doodling with Deep Learning!</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>