<?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 Geet Pithadia on Medium]]></title>
        <description><![CDATA[Stories by Geet Pithadia on Medium]]></description>
        <link>https://medium.com/@gpithadia?source=rss-626122be6523------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*_vzCG3s2HTlwQtmAsD3RZw.jpeg</url>
            <title>Stories by Geet Pithadia on Medium</title>
            <link>https://medium.com/@gpithadia?source=rss-626122be6523------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 21:30:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gpithadia/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[Convolutional Neural Network]]></title>
            <link>https://medium.com/data-science/convolutional-neural-network-1368ee2998d3?source=rss-626122be6523------2</link>
            <guid isPermaLink="false">https://medium.com/p/1368ee2998d3</guid>
            <category><![CDATA[convolutional-neural-net]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[computer-vi]]></category>
            <category><![CDATA[neural-networks]]></category>
            <dc:creator><![CDATA[Geet Pithadia]]></dc:creator>
            <pubDate>Sun, 03 May 2020 01:44:22 GMT</pubDate>
            <atom:updated>2020-05-03T01:44:22.858Z</atom:updated>
            <content:encoded><![CDATA[<h4>Understanding the intuition behind the layers</h4><p>In 1950 Alan Turing presented a paper called <strong><em>The Turing Test,</em></strong> where<strong><em> </em></strong>he laid the ground rules for a machine to be called intelligent. Despite having breakthroughs in the field of Artificial Intelligence, even today machines are incapable of being regarded as intelligent. Neural Network is a domain of Artificial Intelligence which aims at mimicking the brain structure of the human body. One of the basic types of Neural Network called Artificial Neural Network(ANN) is efficient in finding the hidden patterns in the provided data and give out the result.</p><blockquote>NOTE: This article assumes the reader to have a basic understanding of Neural Networks</blockquote><blockquote>A question still persists that even though machines can process and understand the data given to them but do they have the capability to see things like humans?</blockquote><p><strong>YES! </strong>Providing vision to the machine seems an absurd thing to say but one such Neural Network called <strong><em>Convolutional Neural Network </em></strong>imparts the partial sense of vision to the Machines.</p><p>Since an image is just a collection of numerical pixel values, can’t ANN’s process it? The answer to this is <strong>NO! </strong>Though ANN classifies well on the numerical data, it lacks the consideration of spatial relationships while processing the image. Let me simplify it. While processing the list of images, if ANN finds that a cat occurs in the top right corner of one image then it will assume that it will always appear there. Hence no matter where your cat is in the image, if it cannot find it in the top right corner then it will give out a negative result.</p><p>On the other side, Convolutional Neural Network, also known as <strong><em>ConvNet </em></strong>performs exceptionally well in finding an object anywhere in the image. Also, don’t worry if your cat is grumpy, it will still identify it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*z7hd8FZeI_eodazwIapvAw.png" /><figcaption>Photo by: Adesh Deshpande via <a href="https://github.com/adeshpande3/adeshpande3.github.io/blob/master/assets/Cover.png">GitHub</a> (MIT)</figcaption></figure><p>The above image represents the basic architecture of the ConvNet which contains terms such as Pooling, FC Layer, Convolution that may seem overwhelming at first glance. This article aims at demystifying such terms and getting intuition behind using it.</p><p><strong><em>Getting started, let’s understand what are we feeding to the network!</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IcZbKCSt6DvBfm387N182w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@andreimike?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Andrei Mike</a> on <a href="https://unsplash.com/t/nature?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>The image that we see looks mesmerizing to us. But that’s not how the machine looks at it. It sees it as a collection of numerical pixel values representing the intensity values of color channels. The dimension of this image is 5999 x 4000 x 3; where 3 depicts the number of color channels i.e. RGB. Other color channels can be HSV, GrayScale, and many more.</p><h4>How do machines extract features from pixel values?</h4><p>In mathematics, a concept called Convolution takes two functions into account and produces a third function expressing how the shape of one function is affected by the other. Imagine applying a filter to your photo. What happens here is, it takes your photo and applies the function of the filter which may be to highlight the shadows. Filter activates certain features of your image and produces an output image.</p><p><strong><em>So the question arises, what are these filters? </em></strong>Filters are nothing but 3D matrices having specific values that get excited when they see a desired pattern in the neighborhood. They are considerably smaller than the input image which slides over the width and height of the image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*Ff6mG3aPdWFkjb6hZPy3Xw.gif" /><figcaption>Convolution operation on 5 x 5 image with 3 x 3 filter. Photo by: Rob Robinson on <a href="https://mlnotebook.github.io/img/CNN/convSobel.gif">MLNoteBook</a></figcaption></figure><p>When the filter slides over the image it focuses on a certain neighborhood of the image. It performs an arithmetic operation of the filter and the portion of the image and stores the result in a single cell. In technical terminology, cells are regarded as <strong>Neurons</strong>. Multiple such neurons, when combined, form a 2D matrix called <strong>Activation Map/ Feature Map, </strong>or rather I would say the collection of the likings of the filter from the image<strong>. </strong>The neighborhood which is pointed by a single neuron is called a <strong>Local Receptive Field.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*rlkTTRUNCnfXGD0RGNF5Eg.jpeg" /><figcaption>Arithmetic Operation and Local Receptive Fields. Photo by Rob Robinson on <a href="https://mlnotebook.github.io/post/CNN1/">MLNoteBook</a></figcaption></figure><p>Now, this feature map is a result of feature extraction done by one filter. In the case of the Convolution layer, multiple features are used which in turn produces multiple feature maps. The feature maps are stacked together to be passed on as input to the next layer.</p><blockquote>Higher the number of filters, higher is the number of feature maps and deeper is the extraction of the features.</blockquote><h4>What happens to the size of the output image?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*BMngs93_rm2_BpJFH2mS0Q.gif" /><figcaption>Convolution operation. Photo by: <a href="https://github.com/vdumoulin">vdumoulin</a> on <a href="https://github.com/vdumoulin/conv_arithmetic/blob/master/gif/no_padding_strides.gif">GitHub</a> (MIT)</figcaption></figure><p>The size of the output image is bound to reduce after the convolution operation. The parameters which control the size of the output volume are stride, filter size, and padding.</p><ol><li><strong>Stride</strong>: Stride is the number of pixels that we move while sliding the filter. When the stride is 2, we move the filter by 2 pixels. Higher the stride, lower the dimension of the output volume. Usually, we set the stride to either 1 or 2.</li><li><strong>Filter Size</strong>: While we increase the filter size, we indirectly increase the amount of information to be stored in a single neuron. In that case, the number of resulting moves made by filter over the image would reduce. This would eventually result in the reduction of the spatial size of output volume.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*yU-zyweXUf-xB3ZNMm0miA.jpeg" /><figcaption>Padding of 1</figcaption></figure><p>3. <strong>Padding</strong>: As the name suggests it adds an insignificant cover around the original image to keep the size of the output image intact. Calculation of the number of layers to be added is done using the formula <strong><em>P=(((O-1)*S)+F-W)/2 </em></strong>where O is the size of the output image, W is the size of an input image, F is the filter size, P is the number of layers pixels to be added as padding, and S is the stride. For example, if the size of the input image is 5x 5, the filter size is 3 x 3, the stride is 1 and we want the same size of the output image as the input image, the valid padding would be 1.</p><p>Now that we have done the heavy lifting on the image, its time to think of the next step in the process.</p><p>We aspire to make our neural network to be flexible i.e. no matter what the data is, it should be efficient enough to identify from the data. Since the feature maps we have can be represented using some linear function, the uncertainty factor seems to be missing. We need functions to introduce uncertainty, or rather I should say non-linearity, into our neural network.</p><p>There are many functions capable of performing this task but, these two functions are widely used.</p><p><strong>Sigmoid</strong>: It introduces non-linearity using the function g(z)=1/1+e⁻ᶻ which transforms the numbers to range between 0–1. One of the major problems with the Sigmoid function is the <strong><em>Vanishing Gradient Problem</em></strong>. Don’t worry if you are unfamiliar with the term. This <a href="https://towardsdatascience.com/the-vanishing-gradient-problem-69bf08b15484">post </a>by <a href="https://medium.com/u/9ddaaec52a09">Chi-Feng Wang</a> explains the phenomenon of the Vanishing gradient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*Muom3fodryX3-ZEuM36TTQ.jpeg" /><figcaption>A plot of Sigmoid function</figcaption></figure><p><strong>ReLU: </strong>ReLU stands for the Rectified Linear Unit. It thresholds the input at 0 using the function <strong><em>g(w)=max(0,w). </em></strong>Performance of the ReLU is better than Sigmoid function also, it partly tackles with the vanishing gradient problem. Though one problem that ReLU suffers from is the <a href="https://www.quora.com/What-is-the-dying-ReLU-problem-in-neural-networks?share=1"><strong><em>dying ReLU</em></strong></a><strong><em> </em></strong>problem which is resolved by its variant called <a href="https://medium.com/@himanshuxd/activation-functions-sigmoid-relu-leaky-relu-and-softmax-basics-for-neural-networks-and-deep-8d9c70eed91e"><strong>Leaky ReLU</strong></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*L-wptLErOeXBAJm5JhKstg.jpeg" /><figcaption>A plot of ReLU function</figcaption></figure><p>Now that we have made our network strong enough to adapt to changes, we can focus on the other problem of computation time. If you remember, the dimension of our image was 5999 x 4000 x 3 which counts to 71,988,000 pixel values for a single image and we have many such. Though machines are exceptionally fast, it will take quite some time to process these humongous number of pixel values.</p><p>One basic instinct would be to select a dominant value among the group. This is achieved by the machines using an operation called <strong>Pooling.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*x58wTMbUhoYHiRWtoNMjEA.jpeg" /><figcaption>Downsampling of an image. Photo from <a href="https://cs231n.github.io/">Github</a> (MIT)</figcaption></figure><p>We define a pooling window, let’s say 2 x 2. Similar to filters this window slides over the image and selects a dominant value from the window. Definition of the <strong>dominant </strong>changes with the approach.</p><p>One of the approaches is <strong>Max Pooling</strong> which is widely popular where the maximum value from the image within the window is selected. This reduces the size to 25%. Other pooling approaches include <strong>Average Pooling</strong>, <strong>L2 norm of the rectangular neighborhood </strong>which differs in the approach of selecting the dominant value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*iv7fsvgvJ5eBv--iabxqkA.png" /><figcaption>Max Pooling. Photo from <a href="https://cs231n.github.io/">Github</a> (MIT)</figcaption></figure><p>Hence, the main motive for having the <strong><em>Pooling layer</em></strong> is for dimensionality reduction. Although, there have been talks about removing the pooling layers and substituting it with the Convolution Layer instead. <a href="https://arxiv.org/abs/1412.6806">Striving for Simplicity: The All Convolutional Net</a> proposes one such architecture where they suggest using larger stride once a while to reduce the dimensionality of the initial representation.</p><p>The key difference between the ANN and CNN is the ability of CNN to process the spatial relationships in the image and apart from that, the computation power is the same for both. Since we have provided a platform to process the spatial relationships using Convolution, Activation, and Pooling, we can now leverage the power of ANN.</p><p><strong><em>Fully Connected Layers</em></strong> are the representation of the regular neural network or Multi LayerPerceptron (MLP).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/1*3jGDcf5iWSoZVswgfO1VAw.jpeg" /><figcaption>Multilayer Perceptrons</figcaption></figure><p>The main idea behind using these layers is to learn through the non-linear combinations of the high-level features extracted by the convolution and pooling layers. While training the network, the weights between the neurons act as a parameter that is tweaked while training. As this layer accepts the input in the 1D vector form, we need to <strong><em>flatten</em></strong> the output from the previous layers to feed to the FC layer.</p><p>The output of this layer, in case of classification of multiple classes, are real values for each class. To gain some insight from these values, the <strong><em>Softmax function</em></strong> is used. More about the Softmax function can be found <a href="https://victorzhou.com/blog/softmax/">here</a>. It converts these real values into class probabilities. The class with the highest probability is then extracted as the predicted class.</p><p>While these are not the only layers used in building the CNN, they are the basic building blocks of it. Depending on the nature of the problem, multiple other types of layers such as DropOut Layer and Normalization Layer can be added.</p><p>There are numerous architectures of CNN that have proven to perform exceptionally well on the classification of images. Few of them are:</p><ol><li>AlexNet</li><li>VGGNet</li><li>ResNet</li><li>Inception</li><li>DenseNet</li></ol><p><a href="https://towardsdatascience.com/architecture-comparison-of-alexnet-vggnet-resnet-inception-densenet-beb8b116866d">Architecture comparison of AlexNet, VGGNet, ResNet, Inception, DenseNet</a></p><p>While these architectures are ready to use, I urge you to play around with the architecture and build one of your own.</p><p><strong><em>Thanks for reading! Hope this article helps in getting a basic intuition about the Convolutional Neural Network. You can reach out to me on my </em></strong><a href="/service/mailto:gpithadia@gmail.com"><strong><em>Email</em></strong></a><strong><em>, </em></strong><a href="https://www.linkedin.com/in/geetpithadia3/"><strong><em>LinkedIn</em></strong></a><strong><em> in case of any feedback or suggestions. I would love to hear them!</em></strong></p><p><strong><em>Next article will be focused on an end to end example for CNN!</em></strong></p><p><strong><em>Happy Learning!</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1368ee2998d3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/convolutional-neural-network-1368ee2998d3">Convolutional Neural Network</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[Predictive Analysis of an IPL Match]]></title>
            <link>https://medium.com/data-science/predicting-ipl-match-winner-fc9e89f583ce?source=rss-626122be6523------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc9e89f583ce</guid>
            <category><![CDATA[classification-problem]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[ipl-prediction]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Geet Pithadia]]></dc:creator>
            <pubDate>Fri, 06 Mar 2020 06:31:55 GMT</pubDate>
            <atom:updated>2020-03-09T04:30:03.167Z</atom:updated>
            <content:encoded><![CDATA[<h4>Prediction using SVM Binary Classifier</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dVF1ZVfM-PLaLSd34eEr8w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@theinfluencermarketingfactory?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Alessandro Bogliari</a> on <a href="https://unsplash.com/s/photos/cricket?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Since the dawn of the IPL in 2008, it has attracted viewers all around the globe. High level of uncertainty and last moment nail biters has urged fans to watch the matches. Within a short period, IPL has become the highest revenue generating league of cricket. Data Analytics has been a part of sports entertainment for a long time. In a cricket match, we might have seen the scoreline showing the probability of the team winning based on the current match situation. This, my friend, is <strong>D</strong>ata <strong>A</strong>nalytics in action!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Faptgiddydaddylonglegs&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Faptgiddydaddylonglegs&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FAptGiddyDaddylonglegs-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="1280" height="720" frameborder="0" scrolling="no"><a href="https://medium.com/media/d68287efbffb6495c9535744e757297e/href">https://medium.com/media/d68287efbffb6495c9535744e757297e/href</a></iframe><p>Being a cricket fan, visualizing the statistics of cricket is mesmerizing. While I was jumping blogs on Medium and kernels (Let’s say code playbook) on Kaggle, I was fascinated by the analysis done. Hence, I decided to get my first hands-on experience by building a classifier to predict the winning team.</p><p>In Machine Learning, the problems are categorized into 2 groups mainly: Regression Problem and Classification problem. The Regression problem deals with the kind of problems having continuous values as output while in the Classification problem the outputs are categorical values. Since the output of winner prediction is a categorical value, the problem which we are trying to solve is a Classification problem.</p><p>So where to start, and what to do?</p><ol><li>Understand the dataset.</li><li>Clean the data.</li><li>Analyze the candidate columns to be Features.</li><li>Process the features as required by the model/algorithm.</li><li>Train the model/algorithm on training data.</li><li>Test the model/algorithm on testing data.</li><li>Tune the model/algorithm for higher accuracy.</li></ol><p>Let’s get started!</p><h4>A B C’s</h4><p>Well, for smooth learning I recommend having a glance at Python libraries that I used like <a href="https://pandas.pydata.org/">Pandas</a>, <a href="https://numpy.org/">Numpy</a>, and <a href="https://scikit-learn.org/stable/">Scikit-learn</a>.</p><h4>Step 1 — Understanding the dataset!</h4><p>While dealing with data, <a href="http://kaggle.com/">Kaggle: Your Home for Data Science</a> is the to-go platform. I used the dataset <a href="https://www.kaggle.com/nowke9/ipldata">https://www.kaggle.com/nowke9/ipldata</a>. The dataset has 2 files: matches.csv having every match detail from 2008 to 2019 and deliveries.csv having ball by ball detail for every match.</p><h4>Step 2 — Getting the data into the playground and cleaning it!</h4><p>I am using <em>.read_csv()</em> to read the CSV file. The path in the <em>.read_csv()</em> function can be relative or absolute. Here, I am using <a href="https://adventuresinmachinelearning.com/introduction-to-google-colaboratory/">Google Colaboratory</a> as my playground and hence the file is stored there.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a60b2674d2a26b2badc947b586b8c10/href">https://medium.com/media/6a60b2674d2a26b2badc947b586b8c10/href</a></iframe><blockquote>Nothing is perfect. Life is messy. Relationships are complex. Outcomes are uncertain. People are irrational. — Hugh Mackay</blockquote><p>As rightly said by Hugh Mackay “Nothing is perfect” in the above quote and in this case, it relates to our data. The data that we have, contains null values in several columns.</p><pre>column null_values<br>city      7 <br>winner    4 <br>player_of_match 4 <br>umpire1   2 <br>umpire2   2 <br>umpire3  637 <br>dtype: int64</pre><p>There are several ways to handle the null values and among them, I will be using Imputation on column <em>city</em>. Imputation is a way to fill the missing values statistically. For more reference, you might find <a href="https://www.kaggle.com/alexisbcook/missing-values">https://www.kaggle.com/alexisbcook/missing-values</a> helpful. Since filling the values in the column <em>winner</em> is illogical, we can drop those records.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c74da8fc530fccd3afad00da4d0b9fb4/href">https://medium.com/media/c74da8fc530fccd3afad00da4d0b9fb4/href</a></iframe><p>Combination of <em>.select()</em> and <em>.where()</em> from <em>numpy</em> replaces the values in the columns <em>city</em> based on the column <em>venue</em> if the values in <em>city</em> are <em>null.</em></p><h4>Step 3 — Further preprocessing the data</h4><p>While playing around with the data, I found an interesting redundancy. Team <em>Rising Pune SuperGiants</em> were duplicated in columns <em>team_1</em>, <em>team_2</em>, <em>winner</em>, and <em>toss_winner.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*q0GZDGZszsoorl2HPDuP-g.png" /></figure><p>Replacing these values with one value is the obvious thing to do next. Python libraries make data manipulation an easy task to perform. Pandas allow us to load the data into <em>DataFrame </em>and perform manipulations on it easily and efficiently.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d99e82e63f7b8665635c4b1036b05b74/href">https://medium.com/media/d99e82e63f7b8665635c4b1036b05b74/href</a></iframe><p><strong>Phew</strong>!! The data is clean now. We can finally start on analyzing the <em>features </em>(columns).</p><h4>Step 4 — Feature Engineering</h4><blockquote><em>Note: The columns taken into consideration are: </em>team_1<em>, </em>team_2<em>, </em>toss_winner<em>, </em>toss_decision<em>, </em>venue<em>, </em>city<em> and </em>winner.</blockquote><p>For the columns to be able to assist the model in the prediction, the values should make some sense to the computers. Since they (still) don’t have the ability to understand and draw inference from the text, we need to encode the strings to numeric categorical values. While we may choose to do the process manually, the <em>Scikit-learn</em> library gives us an option to use <a href="https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.LabelEncoder.html"><em>LabelEncoder</em></a><em>.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/db0045292cf39a228bf0934f2c5889d2/href">https://medium.com/media/db0045292cf39a228bf0934f2c5889d2/href</a></iframe><p>Before we hop on to building models, an important observation has to be acknowledged. Columns like <em>toss_winner</em>, <em>toss_decision</em>, and <em>winner</em> might make sense to us, but what about the machines?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*i9BAMRy8Hf-bsFWbQMpNUQ.jpeg" /><figcaption>What did he just day? Photo by: <a href="https://www.flickr.com/photos/photo-g-nick/">Guylaine Brunet</a> on <a href="https://www.flickr.com/photos/photo-g-nick/2088769073/in/photolist-4bzugT-ifGsm-ffkJs7-28zqmg-TxBMf3-GwH1c-697j3u-qTS9Sv-Tw1RdC-6AHKj9-X9yi4c-KKLYiY-2gtTCzG-J4Pye5-2fbsyWW-2gLUGw1-2irZBck-ScHj9E-2i2Np5v-2ezHLjW-EaQpzn-8pvrwv-9CdpE-85jCgF-7izQpG-4XqeDx-4XuuMm-784o9R-4XqeyX-dNjXFB-2i2LtkP-2gi9VVg-Lqrzr-Dwc8P-D37cDE-M2R1Ty-7bujef-MVTuJq-2hZ8nMr-PT3SCR-2gAFp4L-3n5Ar6-2ivWXDk-U4ErZw-2hhZCpT-Juniov-2i2Psax-2hSnuDH-4okwNM-HgsKtR">Flickr</a></figcaption></figure><p>Let me elaborate. The values in <em>toss_winner</em> and <em>winner</em> include team names, but what is the relation of these variables with <em>team_1</em> or <em>team_2</em>? The only thing common between them is that they would share the same value, but that is not enough to be logical. Also, <em>toss_decision</em> might be <em>bat</em> or <em>field</em>, but what team are they referring to? To tackle this problem, we will add new columns <em>team1_win</em>, <em>team1_toss_win</em>, and <em>team1_bat</em> for columns <em>winner</em>, <em>toss_winner</em>, and <em>toss_decision</em> such that they reflect the relationship with column <em>team_1.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b75657f53b545b32f5127b1d8b539a21/href">https://medium.com/media/b75657f53b545b32f5127b1d8b539a21/href</a></iframe><p>The value in the column <em>team1_win</em> will be 1 if team1 wins else 0, for column <em>team1_toss_decision</em> it will be 1 if team1 wins the toss and finally <em>team1_bat</em> will be 1 if team1 is batting first.</p><h4>Step 5 — Feature Selection</h4><p>We manually selected a bunch of features based on the domain knowledge we had. But we have no statistical proof of the selected features being important for our dataset. <em>Scikit-learn</em> provides an excellent module named <a href="https://scikit-learn.org/stable/modules/feature_selection.html"><strong><em>feature_selection</em></strong></a><em> </em>which gives us a couple of ways to do the feature selection. First, we will check the columns if any of them represent the same values as other columns. For this, we need to create a correlation matrix to find out the relationships between the column. If the absolute value of the correlation between the columns is high enough, we can say that they represent similar values.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d0e694a217eb92543ebfaa7d04ac5137/href">https://medium.com/media/d0e694a217eb92543ebfaa7d04ac5137/href</a></iframe><p>Correlation matrix for our data would look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*K-xaERhN2RPYbbPHT6QLZA.png" /></figure><p>Here, we see that <em>team1_bat</em> represents the same information as <em>team1_toss_win</em>. Strange, right? It’s just how the dataset was built, if team1 wins the toss then they will always bat and if team2 wins the toss then they will always field. So we removed the column <em>team1_bat</em> from our list of features.</p><h4>Step 6 — Building, Training &amp; Testing the Model</h4><p>For a Classification problem, multiple algorithms can train the classifier according to the data we have and using the pattern, predict the outcomes of certain input conditions. We will try <a href="https://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html">DecisionTreeClassifier</a>, <a href="https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html">RandomForestClassifier</a>, <a href="https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html">LogisticRegression</a>, and <a href="https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html">SVM</a> and choose the algorithm best suited for our data distribution.</p><p>Once we build the model, we need to validate that model using values that are never exposed to the model. Hence we split our data using <a href="https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html">train_test_split</a>, a class provided by Scikit-learn into 2 parts having a distribution of 80–20. The model is trained on 80% of data and validated against the other 20% of the data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e72b96ffcb913b3af8b11d8b4693444e/href">https://medium.com/media/e72b96ffcb913b3af8b11d8b4693444e/href</a></iframe><p>We can now train various models and compare the performances.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bba9dc1d9948f3f6ec387faa66260646/href">https://medium.com/media/bba9dc1d9948f3f6ec387faa66260646/href</a></iframe><p>This resulted in:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*g6ys1-dSZ3Uwa-i2OjFenw.png" /></figure><p>It is evident from the results that <strong><em>SVM</em></strong> gives us a higher accuracy of <strong>66.23% </strong>than other algorithms for this data distribution.</p><p>Even though the accuracy is not high enough to be useful, it gives a basic idea about the strategies and methodologies used in designing a solution to the Machine Learning problem.</p><h4>What’s Next?</h4><p>There are many other factors affecting the outcome of a match like <em>weather</em>, the <em>form of a player</em>, <em>home ground advantage</em>, etc which are not included here. Try adding these features and playing around with it. A further modification to the code can be done by using the concept of<a href="https://towardsdatascience.com/train-test-split-and-cross-validation-in-python-80b61beca4b6"> K-Fold cross-validation</a> that is an alternative to <em>train_test_split</em>. Check out an amazing article in the link for <a href="https://towardsdatascience.com/train-test-split-and-cross-validation-in-python-80b61beca4b6">K-Fold</a>.</p><h4>Lastly!</h4><p>Since you have made it till here, we did a decent job in predicting the probability of an IPL team to win by converting it to a Binary classification problem and using Python libraries while learning about them. If you have any questions, suggestions or feedback, feel free to reach out to me on <a href="/service/mailto: gpithadia@gmail.com">Email</a> or <a href="https://www.linkedin.com/in/geetpithadia3/">LinkedIn</a>. You can find this code on my <a href="https://github.com/geetpithadia3/ipl_winner_prediction">GitHub</a> and you are more than welcome to contribute.</p><p>Happy Predicting!</p><p><em>Thanks to </em><a href="https://medium.com/u/c6af1eb2c940"><em>Dhrumil Patel</em></a><em>, </em><a href="https://www.linkedin.com/in/syed-zubair-939b57119/"><em>Syed Zubair</em></a><em>, </em><a href="https://www.linkedin.com/in/sahilsangani2/"><em>Sahil Sangani</em></a><em>, and </em><a href="https://www.linkedin.com/in/yash-s-5b6b60102/"><em>Yash Shah</em></a><em> for the help!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc9e89f583ce" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/predicting-ipl-match-winner-fc9e89f583ce">Predictive Analysis of an IPL Match</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>