<?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 Murali M K on Medium]]></title>
        <description><![CDATA[Stories by Murali M K on Medium]]></description>
        <link>https://medium.com/@murali_munna?source=rss-9049a2aeeed7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pNj_L9ABjLt2fxDITWMvFA.png</url>
            <title>Stories by Murali M K on Medium</title>
            <link>https://medium.com/@murali_munna?source=rss-9049a2aeeed7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 03:55:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@murali_munna/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[Twitter Talks, Shiny Sparks!]]></title>
            <link>https://medium.com/analytics-vidhya/twitter-talks-shiny-sparks-3ee28f41dc2b?source=rss-9049a2aeeed7------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ee28f41dc2b</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[twitter]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[r]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Murali M K]]></dc:creator>
            <pubDate>Fri, 19 Oct 2018 07:14:15 GMT</pubDate>
            <atom:updated>2019-11-30T14:04:13.437Z</atom:updated>
            <content:encoded><![CDATA[<p>NLP based R Shiny application for comprehensive Twitter media listening</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iCO-wT40bRoFuAM6" /><figcaption>“Silhouette of bird perched on tree” by <a href="https://unsplash.com/@brenkee?utm_source=medium&amp;utm_medium=referral">Benjamin Balázs</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote>— “Hey dude, the Captain Marvel trailer has been released. What’s the buzz on social media?”<br> — “Murali, the Supreme court had scrapped Section 377, and I’m so glad! I would love to know how the public is receiving this news.”</blockquote><p>These kinds of conversations sparkled an idea — what if I input the latest hashtag/keyword, and I will get to know everything on what people are talking about it. I know there are several paid social media listening tools, but with the available open-source resources, I wanted to build one on my own.</p><h4>Let us check the R Shiny App —</h4><p>Go to the below link and explore the app <em>(The app is best viewed on desktops/laptops. Please wait for 3–5 seconds for some of the graphs to load).</em> Come back here to know more about the journey and learnings. This article focuses on some specific experiences in terms of technical challenges, shiny implementations, and insights.</p><p><a href="https://muralimohanakrishna.shinyapps.io/Twitter_Talks_Shiny_Sparks/">Twitter Analytics App</a></p><h3>1. Twitter Data — Extracting and Cleaning</h3><h4>Extracting Tweets</h4><p>twitteR is the usual go-to package to download tweets through R, but I faced a lot of difficulties while extracting more than ~2000 tweets for a given hashtag. I wanted to extract around 50K tweets and found this excellent package called rtweet by <a href="https://mkearney.github.io/blog/2017/06/01/intro-to-rtweet/">Michael W. Kearney</a>. You can extract up to 18,000 tweets every 15 minutes that exist in the last 7–10 days (Yes, this is the most painful limit Twitter has put in place). You can surpass the 18k limit and extract more tweets by iterating the extraction process using certain features like retryOnRateLimit and max_id arguments.</p><p>Note that in order to gain access to Twitter API’s, you need to create a twitter app and get the necessary keys and tokens. This <a href="https://rtweet.info/">link</a> will guide you through that process using rtweet .</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7b1349a77c4eacb00ec91955c4f8a2f/href">https://medium.com/media/a7b1349a77c4eacb00ec91955c4f8a2f/href</a></iframe><h4><strong>Selecting the Topics</strong></h4><p>I wanted to include a wide variety of topics ranging from movies, politics, and sports to see how my app unveils insights in each one of them (#Baahubali was my first thought :P). Unfortunately, because of the 7–10 day tweet limitations, I had to choose topics that were trending during 3rd week of Sep-2018. I tried to include different variety and came up with these: Data Science (of course it should be there), iPhone XS launch (not an Apple fan though), Captain Marvel trailer (big fan!), Robo 2.0 teaser, Section 377 scrapping (Indian Supreme Court scrapped the criminality of sexual activities which are ‘against the order of nature’) and Reliance-Rafale deal.</p><h4><strong>Cleaning the Untidy Beast</strong></h4><p>Tweets are one hell of messy data, and the below code will guide you in treating/removing them. Few specific cleaning steps include — removing @ (screen name mentions), hyperlinks, uni-code characters, RT (retweets), punctuation, and digits. After converting the tweets to lower cases and removing stop words (I have also included custom stop words based on the topic), we need to convert the text data into a corpus of documents, the basis for further analysis.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01ef71d07bdfd829b77eecdd5138ad7f/href">https://medium.com/media/01ef71d07bdfd829b77eecdd5138ad7f/href</a></iframe><h3>2. Token Frequencies</h3><p>Given the number of tweets, the term-document matrix can become huge, and you may encounter size allocation errors in R while performing operations on it. slam package comes to the rescue, which performs these operations smoothly on sparse matrices. I regret not knowing the power of <a href="https://www.tidytextmining.com/preface.html">tidytex</a>t , a beautiful package developed by Julia Silge and David Robinson to do text processing much more elegantly. From their own words,</p><blockquote>We found that using tidy data principles can make many text mining tasks easier, more effective, and consistent with tools already in wide use. Treating text as data frames of individual words allows us to manipulate, summarize, and visualize the characteristics of text easily and integrate natural language processing into effective workflows we were already using.</blockquote><p>unnest_tokens() function in tidytext enables to tokenize text by n-grams, sentences, paragraphs and even by some specific keywords.</p><h4>The standard word-cloud</h4><p><a href="https://cran.r-project.org/web/packages/wordcloud2/vignettes/wordcloud.html">wordcloud2</a> provides an HTML5 interface to traditional word-clouds along with some excellent features like custom-figure cloud and letter-cloud.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fuyJgVKF0I0YisrhMq6vRw.png" /></figure><h3>3. Sentiment Analysis</h3><h4>Sentiment Lexicons</h4><p>There are three widely used sentiment lexicons based on uni-grams.</p><ol><li><a href="http://saifmohammad.com/WebPages/NRC-Emotion-Lexicon.htm"><strong>nrc</strong></a> — The NRC Emotion Lexicon is a list of English words and their associations with eight basic emotions (anger, fear, anticipation, trust, surprise, sadness, joy, and disgust) and two sentiments (negative and positive). The annotations were manually done by crowdsourcing.</li><li><a href="http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6010"><strong>AFINN</strong></a> — AFINN is a list of English words rated for valence with an integer<br>between -5 (negative) and +5 (positive). The words have<br>been manually labeled by Finn Arup Nielsen in 2009–2011.</li><li><a href="https://www.cs.uic.edu/~liub/FBS/sentiment-analysis.html"><strong>bing</strong></a> — It categorizes words into positive and negative elements.</li></ol><p>I have used ‘nrc’ to get the emotions score across all the tweets and ‘AFINN’ to identify the +ve/-ve/neutral tweets along with the extreme ones</p><p>tidytext provides these lexicons in a data frame format so that it is very easy to get these scores across each word of each tweet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8nVfuA39_loHKdDjvw3v7Q.png" /></figure><h3>4. Network Analysis — Word Relationships and Topics</h3><p>I wanted to do topic modeling and found that LDA’s topic modeling algorithm is the most famous one, implemented using topicmodels package. <strong>The basic intuition is that each topic is a mixture of words (with associated word probability), and each document is a mixture of topics (with associated % to each topic).</strong> I have failed to get good topics for the tweets and learned that each document has a near equal distribution of all the topics (Let’s say I have run the algorithm with 2 topics, topic 1 % across all the documents varied from 45–55% and the same with topic 2). I have iterated with a different number of topics and got similar results. This might be because of two reasons —</p><ol><li>Since we are downloading tweets of a particular hashtag already, the tweets are very focussed and hardly ever discuss more than 1–2 topics.</li><li>Short texts (&lt;140 character tweets) are very sparse and noisy. And there is a good discussion <a href="https://www.researchgate.net/post/What_is_a_good_way_to_perform_topic_modeling_on_short_text">here</a> on short-text topic modeling along with some research papers. I have to first understand LDA algorithm and try out different techniques suggested. Please advise if you have worked on it before.</li></ol><h4>Bi-gram directional network</h4><p>Given that topic modeling is a roadblock for now, I have used bi-gram network and correlation networks to come up with the relationship between different words and thereby identify the topics around them. <strong>Bi-gram networks look at the frequency of consecutive word pairs along with their directionality.</strong> igraph and ggraph are used to visualize these networks. The width of link connecting the two words represents the frequency of that pair.</p><h4><strong>Correlation Network</strong></h4><p><strong>Correlation among words indicates how often they appear together in a document relative to how often they appear separately.</strong> The metric under use is <a href="https://en.wikipedia.org/wiki/Phi_coefficient">phi coefficient</a> — how much more likely it is that either both word X and Y appear, or neither do, than that one appears without the other. widyr package provides functions like pairwise_count() and pairwise_cor() to find the co-occurrence and correlation of word-pairs, respectively. Correlation graph is one of the best ways to look at word clusters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2NaGELfiOA3VcYdLByPixQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PUGjlYazntbRTQ3gqJmMOA.png" /></figure><h3>5. The most popular ones</h3><p>Finally, I wanted to show some top tweets in those topics based on favorites and retweets. Please check them out along with their hyperlinks, which are really interesting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hxMsRKKP4ob0wOS_YjdWqA.png" /></figure><h3>6. The Viz. Queen — R Shiny</h3><p>I am providing a few links to get started on R shiny, but the key is to practice and create dashboards with different layouts and input-output features. Please follow in the order provided-</p><ol><li><strong>S</strong><a href="https://rstudio.github.io/shinydashboard/index.html"><strong>hiny dashboards</strong></a> — This gives a good overview on how to create basic layouts and features</li><li><a href="https://shiny.rstudio.com/tutorial/"><strong>Shiny tutorials</strong></a> — To know more on shiny input-outputs, panels and reactive functions</li><li><a href="http://jkunst.com/highcharter/"><strong>Highcharter</strong></a> — Highcharter is an R wrapper for Highcharts javascript library and its modules. It is one of the most widely used interactive graphing package with R Shiny</li></ol><h4>Shiny Features in the App</h4><ol><li>Highcharter is used for bar plots and radial plot</li><li>renderWordcloud2 and wordcloud2Output are used for plotting word cloud</li><li>Custom CSS styling for title, text, columns and boxes formatting</li><li>Progress bar to indicate the progress on what all computations are happening, and how much is left.</li></ol><h3>7. Some Insights from the App</h3><ol><li><strong>Data Science</strong> — Frequent words around applications like digital marketing, blockchain, IoT, fintech, SEO/SMM, e-commerce. Lot of trust and anticipation emotions. Word clusters around NLP, NN, marketing, cybersecurity, cloud and big data, deep learning tensorflow and reinforcement. The top tweets are really knowledgeable.</li><li><strong>IPhoneXS</strong> — Words around giveaway, win, pre-order, apple events and sweeps. Huge anticipation followed by joy and trust. Clear clusters around chance-giveaways, audio-sound-earbuds, heavy duty-aluminium-case, I guess some people are having size issues with the most negative tweet saying — <strong><em>“ How the f**king f**k are you suppose to f**king fit the f**king iPhoneXSMax in your f**king pocket F**k”</em></strong></li><li><strong>Captain Marvel Trailer</strong> — Bi-grams around can’t wait, old lady :P, punching old, higher faster, nick fury, carol danvers. Emotions of anticipation, joy and surprise. Most favorited tweet saying — “<strong><em>Look Mom, I’m a superhero. #CaptainMarvel </em></strong><a href="https://t.co/iUv0g1wlxs"><strong><em>https://t.co/iUv0g1wlxs</em></strong></a><em>”</em></li><li><strong>Section 377</strong> — Words like lgbtq community, gay sex, historic verdict. Lot of trust and joy along with fear (I want to dig deeper into this ‘fear’ tweets). I loved this most favorited tweet saying — “<strong><em>O pakka #Section377 ne etheste inka e Caste-lu..Honor Killing-lu endhi ra Jungle Fellows! #PranayAmrutha 💔 …for God sake, learn to be a #HUMANFIRST !!!! — R.A.P.O</em></strong><em>” (Loose translation from Telugu: India has scrapped Section377 and yet people are committing honor killing in the name of caste. For god sake, learn to be a human first)</em></li><li><strong>Robo 2.0 Teaser</strong> — million views, rajinikanth akshay kumar, teaser crosses are the frequent words. Lot of trust, anticipation and joy for the upcoming movie.</li><li><strong>Reliance-Rafale Deal</strong> — Bi-grams around french govt, indian govt, president hollande, pm modi. Shocking 53% negative sentiment. Clear clusters around china-turkey-europeoffers-feedstock, negotiated-worth-dollars, restructured-select-stakeprerogative, betrayed-blood-soldiers. Lot of negativity around the deal with most favorite tweet saying — “<strong><em>The PM and Anil Ambani jointly carried out a One Hundred &amp;amp; Thirty Thousand Crore, SURGICAL STRIKE on the Indian Defence forces. Modi Ji you dishonoured the blood of our martyred soldiers. Shame on you. You betrayed India’s soul. #Rafale”</em></strong></li></ol><h3>8. Taking it to the next level</h3><p>I learned a lot during the process and have few thoughts of refining/adding few elements to make it better</p><ol><li>Integrate twitter data extraction process within R Shiny, so that the user can enter the hashtag of their interest. (Currently it takes~15–20 min. for the data to download and process. This is the major reason I haven’t integrated them)</li><li>N-gram sentiment analysis. Learn to deal with negation and sarcasm while doing sentiments</li><li>Short-text topic modeling. I still have to explore a lot in this area. Also, use the power of word embeddings in clustering and sentiments</li><li>Use twitter extracts to the fullest. The entire analysis has used only text and few fields like favorites, retweets; but we have a bunch of information media like hyperlinks, gifs, images, location information, etc.</li></ol><p>Thanks for reading till the end. Please clap if you like, and share the app and article. I would love to hear your thoughts/feedback in the comments section.</p><p><a href="https://www.linkedin.com/in/muralimohanakrishnadandu/"><strong>Connect on LinkedIn</strong></a> | <strong>Github link for the codes is below</strong></p><p><a href="https://github.com/murali-munna/Twitter_Talks_Shiny_Sparks">murali-munna/Twitter_Talks_Shiny_Sparks</a></p><p><strong>Interested in knowing few tips for beginners in Data Science?</strong></p><p><a href="https://towardsdatascience.com/practical-tips-for-beginners-in-data-science-debunking-few-myths-30537117a4e4">Practical Tips for Beginners in Professional Data Science. Debunking few Myths!</a></p><p><strong>Interested in Image Classification using Transfer Learning?</strong></p><p><a href="https://towardsdatascience.com/fast-ai-deep-learnings-part-i-eye-in-the-sky-417e97c3e6bb">Eye in the Sky — Image Classification using Transfer Learning and Data Augmentation</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ee28f41dc2b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/twitter-talks-shiny-sparks-3ee28f41dc2b">Twitter Talks, Shiny Sparks!</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Eye in the Sky — Image Classification using Transfer Learning and Data Augmentation]]></title>
            <link>https://medium.com/data-science/fast-ai-deep-learnings-part-i-eye-in-the-sky-417e97c3e6bb?source=rss-9049a2aeeed7------2</link>
            <guid isPermaLink="false">https://medium.com/p/417e97c3e6bb</guid>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Murali M K]]></dc:creator>
            <pubDate>Wed, 15 Aug 2018 10:21:57 GMT</pubDate>
            <atom:updated>2019-11-30T13:34:53.687Z</atom:updated>
            <content:encoded><![CDATA[<h4>Fast.AI Deep Learnings Part I</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kiJNl9fQOGfZcSqz" /><figcaption>“Side shot of a fighter jet speeing through the air.” by <a href="https://unsplash.com/@dann?utm_source=medium&amp;utm_medium=referral">Dan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Becoming a fighter pilot was my childhood dream, and watching planes until they clear my sight is still an excitement. When I was thinking about a data set to start applying my learnings on Computer Vision from <a href="http://course.fast.ai/">fast.ai</a>, that was my motivation to play with them.</p><p>This is the first part of my series <strong><em>Fast.AI Deep Learnings</em></strong>. For those who don’t know, <a href="http://course.fast.ai/">fast.ai</a> is an online course on Deep Learning taught by <a href="https://twitter.com/jeremyphoward?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Eauthor">Jeremey Howard</a>, former Kaggle President and #1 competitor. I felt his top-down approach as a perfect complementary after I finished Andrew NG’s <a href="https://www.coursera.org/specializations/deep-learning">Deep Learning Specialization</a> on Coursera.</p><p>I am going to give an end-to-end implementation of planes vs. helicopters classification, and let’s see how the CNN architecture differentiates wings vs. blades. The complete code for execution can be found <a href="https://github.com/murali-munna/deep-learning-fastai">here on github</a>.</p><h3>1. Data Preparation</h3><p>I thought of not using any existing datasets, so I downloaded images from google myself. I have used <em>Firefox’s Google Image Downloader,</em> which is a convenient extension tool to download images. I also found this <a href="https://github.com/hardikvasa/google-images-download">python package</a> useful to automate this process for multiple tags. With a total of 216 planes and 350 helicopters, let’s look at the sample pictures in the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*JFMClOm7f3a7kN_x2HYG6Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*8OPr1hFgHqF5IwpBAalwDg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/267/1*YavZ_7VCokqOiSgAwDo1Og.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/1*Dy-8FsFVDl0LfRv3JERRcw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*NObiYtz6y-IohI8FsSQJlw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*0Zg6HtWhlYkllFGbgBXuag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*dwpLd837xqzvdnZUOXKGyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*KIUExxkTfurUtnkK5wmsNg.png" /></figure><p>Our dataset looks diverse enough (at least the airplanes) with pictures ranging from regular passenger flights, propellers, fighters, toy planes, combat helicopters, and gigantic house movers. Let’s see how our NN tackles them.</p><h3>2. Quick Model with ResNet34</h3><p>We will be using ResNet34 pre-trained model, which won the 2015 ImageNet competition. Since ImageNet contains a diversified clicked pictures, this architecture will be suited well for this problem. You can go through <a href="http://teleported.in/posts/decoding-resnet-architecture/">this excellent article</a> to decode the ResNet architecture, and the underlying philosophy is to use a deeper network without experiencing degradation in convergence.</p><blockquote>“ You should not be using smaller networks because you are afraid of overfitting. Instead, you should use as big of a neural network as your computational budget allows, and use other regularization techniques to control overfitting ” — CS231n</blockquote><p>With 5 epochs, batch size of 8, and learning rate of 0.01, we are able to achieve an accuracy of around ~90%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/1*pkH0SEXwCp62iKTc3PGFQQ.png" /><figcaption>Accuracy after training for five epochs</figcaption></figure><h4><strong>2a. Analyzing Results</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*ORJXR-xc423-hZJopWXlKQ.png" /><figcaption>Most correctly classified planes</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*vIeHdQRzLmVsB4Fki4m9fA.png" /><figcaption>Most correctly classified helicopters</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*mUrW3ChJR03534xz9oo3Sw.png" /><figcaption>Most incorrectly classified planes</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*rpHg5sOcxEw9fmwO-xOWyQ.png" /><figcaption>Most incorrectly classified helicopters</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*zOEqkTneMFSsmDx1lOcWFw.png" /><figcaption>Most uncertain predictions</figcaption></figure><p>Although there are planes that are difficult to identify (the one on fire and the ‘Heathrow’ one), the incorrectly classified helicopters seem to be not that different from the correct ones.</p><h3>3. Learning Rate Finder</h3><p>The learning rate determines how quickly or how slowly you want to update the weights. Although for a small dataset (~500 images) like ours, it wouldn’t matter much, but learning rate significantly affects model performance/convergence.</p><p>We are going to use the technique developed in the paper, <a href="http://arxiv.org/abs/1506.01186">Cyclical Learning Rates for Training Neural Networks</a>, where we simply keep increasing the learning rate from a minimal value, until the loss stops decreasing. We are going to use LR of 1e-2 based on the plots below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*L711E8D5sZV1LZdqkOCxlg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*sCdmNEAi0fD_CVgu2m8piQ.png" /><figcaption>Left: Increasing learning rate every iteration. Right: Identifying the learning rate where there is still a decreasing loss</figcaption></figure><h3>4. Data Augmentation</h3><p>If we train the model for more epochs, it will start over-fitting (training loss becomes less, whereas validation loss doesn’t). The model will start learning features specific to these data points rather than generalizing. To overcome this, we are going to create more data using Data Augmentation. For this problem, we will be using horizontal flipping and zooming (up to 1.1x). Make sure you do relevant augmentation — For letters/digits, any flipping doesn’t make sense, whereas for satellite images, we can flip and rotate the images as we want.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*aJh0fDBgb4oT0X3Gm_FcrQ.png" /><figcaption>Augmenting through horizontal flipping and zooming</figcaption></figure><p>We can see that the accuracy has improved to 92.3% after passing this augmented data. <em>Note that we are still using the pre-trained weights and only training the final FC layers.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*06oFriBzxcVt5Y29k4EpVA.png" /><figcaption>Accuracy after 5 epochs with augmentation</figcaption></figure><h3>5. Fine Tuning along with Differential Learning Rate Annealing</h3><p><strong>Learning rate Annealing:</strong> Though we found that 1e-2 as the ideal learning rate, we have actually started with that and gradually decreased it as the training progresses. This is because, as we get closer to optimal weights, we should be taking smaller steps.</p><p><strong>Stochastic Gradient Descent with Restarts: </strong>Using the above technique for one epoch cycle, we would restart the learning rate again from 10e-2 and continue the process. The idea behind this is to encourage our model to jump out of this optimal space and find (if any) a stable and accurate optimal space. Combining these two, the learning rate progresses like this —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*V87Ykr8OFJ44TWSuiXwV-g.png" /><figcaption>SGDR: Each cycle corresponds to one epoch</figcaption></figure><p><strong>Unfreezing pre-trained layers:</strong> Now, since we have trained enough our final layers, we will unfreeze the pre-trained ResNet layers and fine-tune them. Since these layers have already been trained on imageNet photos and the initial layers will have more general-purpose features, we would be using differential learning rate so as to tune them carefully. So, initial layers will use 1e-4, middles ones 1e-3 and our FC layers 1e-2 as before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*pVsX9WL27vG6ca63hiy6lA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/1*0ni9_eDgCNSmS6RlmzzUGQ.png" /><figcaption>Final Accuracy after 3 cycles with 1 epoch, 2 epoch and 4 epoch each</figcaption></figure><p>We see that the accuracy didn’t change much but improved to 93%. We still see that the validation loss is 0.21 whereas training loss is at 0.12, and I feel there’s still room to improve the model, but we will stop here for now. <em>I think that there are more variety of planes but not enough examples to learn those features (that’s why I think we see a lot of planes being misclassified below).</em></p><p><strong>Test Time Augmentation: </strong>This is an excellent approach to use the power of augmentation while validating/testing. TTA makes predictions not just on the images in your validation set, but also makes predictions on several randomly augmented versions of them too. It then takes the average prediction from these images, and uses that. <strong>We achieved an accuracy of 94.4%,</strong> a pretty good jump considering this simple yet effective technique.</p><h3>6. Analyzing Final Results</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*f6fkok0QKpDef7aSteycQg.png" /></figure><p>Looking at the confusion matrix, there are 7 planes which are predicted as helicopters (these seem to be the incorrect ones after the initial model itself), and we did a good job at predicting helicopters. Maybe with more images of airplanes we might be reaching higher accuracy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*HNeQ7JVvwAtTjxW8gwOlAA.png" /><figcaption>Final most incorrect aeroplanes</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*_mBUqqLkaqVQFTobw_bX4g.png" /><figcaption>Final incorrect helicopter</figcaption></figure><p><em>Thank you so much for reading untill the end. We have used transfer learning, data augmentation, and differential learning rate annealing to classify planes vs. helicopters to a very decent accuracy of 94.4% with a small dataset (~500 images). Please clap and share if you like and also let me know in the comments if anything is unclear or can be improved upon.</em></p><p><em>Code: </em><a href="https://github.com/murali-munna/deep-learning-fastai"><em>https://github.com/murali-munna/deep-learning-fastai</em></a></p><p><em>To know practical tips for beginner in Data Science, check out this post.</em></p><p><a href="https://towardsdatascience.com/practical-tips-for-beginners-in-data-science-debunking-few-myths-30537117a4e4">Practical Tips for Beginners in Professional Data Science. Debunking few Myths!</a></p><p><em>Connect with me on </em><a href="https://www.linkedin.com/in/muralimohanakrishnadandu/"><em>LinkedIn</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=417e97c3e6bb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/fast-ai-deep-learnings-part-i-eye-in-the-sky-417e97c3e6bb">Eye in the Sky — Image Classification using Transfer Learning and Data Augmentation</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[Practical Tips for Beginners in Professional Data Science. Debunking few Myths!]]></title>
            <link>https://medium.com/data-science/practical-tips-for-beginners-in-data-science-debunking-few-myths-30537117a4e4?source=rss-9049a2aeeed7------2</link>
            <guid isPermaLink="false">https://medium.com/p/30537117a4e4</guid>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[professional-development]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Murali M K]]></dc:creator>
            <pubDate>Mon, 02 Jul 2018 18:38:01 GMT</pubDate>
            <atom:updated>2020-02-06T20:03:59.883Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AW-mod64cQ7FfTTk" /><figcaption>“A robot named Pepper holding an iPad” by <a href="https://unsplash.com/@agkdesign?utm_source=medium&amp;utm_medium=referral">Alex Knight</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>When I started my journey in 2015 to where I am right now, there has been a lot of learning through professional experience, MOOCs, and online communities. I think it’s time to start giving back to the Data Science world, and I begin my blog series with something I felt necessary to talk about.</p><p><em>This post, in particular, is aimed at people who are beginning their Data Science career (or switching to it) and are biased/not-known with some of the facts related to the professional experience.</em></p><h3>1. Things that hackathons don’t teach you — Defining the Problem</h3><p>Most people become fancied by applying machine learning algorithms to the already given raw (not-so-raw actually) dataset with a clear problem statement. They usually sound like this — <em>“Company XYZ wants to automate their loan approval process. Using the given training data, can you identify the important factors to classify and predict the loan approvals. Note that the metric you will be evaluated on is Accuracy”</em>. These problem statements unknowingly simplify certain things like defining the problem, attaining the final dataset, identifying the evaluation metric, etc. But in the real world, this is not the case.</p><blockquote>“Remember, more than 60% of your time is spend in identifying/defining the problem, brainstorming the approach and getting the relevant data.”</blockquote><p>To kick start on this problem-solving — find open-source data sets, come up with your hypothesis, ask yourself what problems can this data set solve, think about what other relevant data you might use to solve this. You might end up solving your problem using a t-test with some beautiful visualizations :)</p><h3>2. SQL — The most underrated tool</h3><blockquote>SQL is to Data Science what Gautam Gambhir was to Indian Cricket. You will struggle during the innings if you don’t get a good start, and yet, sometimes, you will be forgotten by the time of victory sixers.</blockquote><p>After all, SQL is used to fetch some data. But imagine, you did the entire modeling exercise on the customer level dataset to realize that the data has customer duplicates because of a few wrong ‘SQL joins’ during data wrangling. ‘Duplication’ is one major problem while data fetching, and this might be because of your SQL code or because of issues in the backend database. Thorough quality assessment is required after every step of SQL data-wrangling because <strong>“executing without syntax error doesn’t mean it executed the way you wanted it to be.”</strong></p><p>For beginners, most of the resources teach the basic SQL with concentration on getting the syntax part, and the notion becomes spread that SQL logic is so simple and often gets overlooked. I would suggest you take a relational database (set of 3–10 tables) on different topics (Airlines, E-commerce, retail, etc.) and ask some tough business questions. This will require the execution of several SQL blocks and will adequately test your skills.</p><h3>3. R or Python? Learn both.</h3><p>There are already numerous amount of blogs on this topic, and if you read some of them, Python would be the winner (by a small margin). I don’t want to go into the pros and cons of each and decide something, but, I would suggest you to learn both and get expertise in one.</p><p>Let’s say, Mr. RaceR was introduced to R. During his journey, he loved the intuitiveness of dplyr, he felt that ggplot2 is the next beautiful thing after his girlfriend and his one-liner fancy decision tree plot works like a charm. And suddenly, one day, he got an interview call from his dream company with an excellent opportunity. But the only heartbreaking thing he got to know was that people there find pandas cute, they generate reports over matplotlib and run Jupyter notebook based deep learning models on cloud GPUs. He felt his whole R life was a lie.<br>Although I dramatized the story, the moral is to learn and get comfortable in both up to the extent that switching becomes quite easy (It might be because of a job change, client requirements, run-time data issues, better package/modules availability, etc). After all, languages are just the tools to get things done. You never know that there is a third language waiting to break the storm.<br>FYI — I love R as I started with it :)</p><h3>4. Learn traditional Machine Learning before starting Deep Learning</h3><p>I suggest this because of two main reasons. One — You should enjoy exploring unseen data. Structured data would be the best way to start, and the process involves bi-variate analysis, testing a few hypotheses, missing value treatment, outlier identification, etc. Two — You will go through the iterative process of variable selection, feature engineering, parameter tuning, and finally checking for business implications of model variables. On the other hand, in deep learning, network architecture takes care of most of the feature engineering part, and hyper-parameter tuning becomes an essential part of the process. Also, explaining the model to the business stakeholders is an integral part of the project, and hence, the intuitiveness of the ML models in terms of variable importance (like logistic regression, decision trees) make them the most sought out option (for structured data) in many industries.</p><h3>5. Not every problem ends up in building models</h3><p>Yes, reread it.</p><blockquote>The art of Data Science doesn’t involve building the best model, but in solving the problem using data as an asset</blockquote><p>There are lot of other traditional methodologies and techniques which are widely used in the industry.</p><p><strong>Dashboarding and Reporting</strong> — These are an integral part of many businesses and involves creating automated data pipelines using SQL, brainstorming with stakeholders to understand KPIs, storytelling with a strong visual aesthetic narrative</p><p><strong>Design of Experiments</strong> — It is always essential to know how specific services/campaigns/promotions worked, and measuring their impact becomes crucial to make key decisions. Test-control analysis, A/B testing will be generally used here to quantify that impact</p><p><strong>Segment the data till you can</strong> — Certain problems can quickly be answered with properly designed EDA and segmentation</p><p>For beginners, I would suggest you to choose areas of interest and find relevant datasets (Movies, Sports, etc). Create Tableau/RShiny public dashboards keeping two things in mind. How well the information is flowing and how easily your chart is depicting that information. Also, read case studies where the emphasis is on designing and formulating solutions to certain problems.</p><h3>6. Don’t get overwhelmed by the resources available</h3><p>Yes, you will, at some point in time, get lost in the digital learning world of Data Science. This doesn’t mean you have to complete all of them to become an expert. To get rid of that bias and have a continuous learning experience, you should create your learning paths and set principles based on your learning style and motivation.</p><ol><li>First, know what kind of approach you want to take; top-down or bottom-up. I am a former kind of person who would like to know a sufficient amount of theoretical knowledge before jumping into applying them, but it strictly depends on individual</li><li>Prepare a learning track based on the objective and the above approach chosen</li><li>Do one thing at a time and COMPLETE IT. Let it be a course on Coursera, project on Kaggle or creating your tableau dashboard</li><li>Make your own notes of every learning</li><li>Keep an aim to read one blog a day. Note down two things that you can take home with you</li><li><strong>Finally, consistency is the key</strong></li></ol><p><em>Thank you so much for reading until the end. Please hit clap if you like, and if you have something to say, drop a comment below. It will help me refine my posts :)</em></p><p><em>This post is based on my professional experience until now. If you have any feedback or major additions you would like to point out for beginners, please feel free to comment.</em></p><p><em>Connect with me on LinkedIn: </em><a href="http://www.linkedin.com/in/muralimohanakrishnadandu"><em>www.linkedin.com/in/muralimohanakrishnadandu</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30537117a4e4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/practical-tips-for-beginners-in-data-science-debunking-few-myths-30537117a4e4">Practical Tips for Beginners in Professional Data Science. Debunking few Myths!</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>