<?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 Saurabh Charde on Medium]]></title>
        <description><![CDATA[Stories by Saurabh Charde on Medium]]></description>
        <link>https://medium.com/@csaurabh17?source=rss-a540faa5f108------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*sGP6ytRBap7Sw16zixx2ag.jpeg</url>
            <title>Stories by Saurabh Charde on Medium</title>
            <link>https://medium.com/@csaurabh17?source=rss-a540faa5f108------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 23:03:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@csaurabh17/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[Build & Launch a WhatsApp Assistant for your Business in a Day (With Real World Example)]]></title>
            <link>https://medium.com/@csaurabh17/build-launch-a-whatsapp-assistant-for-your-business-in-a-day-with-real-world-example-3675740e6974?source=rss-a540faa5f108------2</link>
            <guid isPermaLink="false">https://medium.com/p/3675740e6974</guid>
            <category><![CDATA[sales]]></category>
            <category><![CDATA[business]]></category>
            <category><![CDATA[whatsapp-business]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Saurabh Charde]]></dc:creator>
            <pubDate>Wed, 06 Nov 2024 19:10:07 GMT</pubDate>
            <atom:updated>2024-11-06T19:10:07.260Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4DczYlz0Xmoxye5ZAQeSiQ.jpeg" /><figcaption>Example of an Whatsapp assistant in action from my recent Flight Booking</figcaption></figure><p>Recently, I traveled to Bangalore for work (yes, hybrid work is still a thing!). As I booked my flight, I received the usual WhatsApp message with my ticket and flight details. I loved how convenient it was to get all the info right there in the app I use most. This got me thinking — why not build a WhatsApp assistant that improves customer experience in a real-world setting?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*5rVmqWtJ90vI8erhMa871w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nvMpdlKf3tDNC-5Eye7AzA.jpeg" /><figcaption>GForm which user would fill (left) &amp; the whatsapp message received after form submission(right)</figcaption></figure><p>Let’s dive in! We’ll create a WhatsApp Assistant for an event, where users will automatically receive a WhatsApp message confirming their registration after submitting an event registration form. To make it even cooler, we’ll use Unsplash to fetch a random event-related image and send it with the message. Ready? Let’s build it together in one day!</p><h3>What You’ll Achieve</h3><p>Imagine your users filling out a Google form for event registration. When they hit “submit,” they’ll get a personalized WhatsApp message with event details and a beautiful image that matches the event theme. Pretty slick, right?</p><h3>How to Get There: Step-by-Step</h3><p>Here’s a quick roadmap to building your assistant:</p><ol><li>Create a Facebook Business Account (for WhatsApp messaging access).</li><li>Set up a WhatsApp Message Template.</li><li>Create an Unsplash Account (to fetch images via API).</li><li>Choose a Server to Host Your App (I used <a href="http://railway.app/">Railway</a>).</li><li>Create a Google Form &amp; Add an App Script (to send form data to your server).</li><li>Set Up Server-Side Logic to Send the WhatsApp Message.</li></ol><p>You can find detailed instructions in the links below. Once the setup is done, we’ll move on to the fun part — coding!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c858510c6d789667b4df06244e91a1be/href">https://medium.com/media/c858510c6d789667b4df06244e91a1be/href</a></iframe><h3>Let’s Break it Down:</h3><p>For the setup, follow these guides to complete the first four steps. Once you’re ready, it’s time to get coding. Here’s the code I used for this project, and feel free to tweak it to suit your own ideas.</p><blockquote><strong>WhatsApp Message template</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y2t0UOlSOZ9d94jw5wg4nQ.png" /></figure><blockquote><strong>Google App script code</strong></blockquote><pre>function sendResponsesToServer(e) {<br>  const url = &#39;https://myserver.railway.app/api/v1/send-message&#39;;<br>  <br>  const responses = e.values;<br>  const payload = {<br>    name: responses[1],<br>    company: responses[2],<br>    phone: responses[3],<br>    event: responses[4],<br>    date: responses[5],<br>  };<br><br>  const options = {<br>    method: &#39;post&#39;,<br>    contentType: &#39;application/json&#39;,<br>    payload: JSON.stringify(payload)<br>  };<br>  <br>  UrlFetchApp.fetch(url, options);<br>}</pre><blockquote><strong>Message Service code</strong></blockquote><pre>@Service<br>@Slf4j<br>public class MessageService {<br><br>    @Value(&quot;${facebook.whatsapp.endpoint}&quot;)<br>    private String ENDPOINT;<br><br>    @Value(&quot;${auth.token}&quot;)<br>    private String AUTH_TOKEN;<br><br>    @Autowired<br>    private RestTemplate restTemplate;<br><br>    @Autowired<br>    private UnsplashService unsplashService;<br><br>    public void sendMessage(FormResponseDto responseDto) {<br><br>        try {<br>            <br>            //fetch a random image based on the event selected by user<br>            String imgUrl = unsplashService.getRandomImageUrl(responseDto.getEvent());<br><br>            //populate the whatsapp template with data (image + form data)<br>            EventFormTemplateMessage eventFormTemplateMessage = new EventFormTemplateMessage();<br>            String jsonBody = eventFormTemplateMessage.create(imgUrl, responseDto);<br><br>            log.info(&quot;Request {}&quot;, jsonBody);<br><br>            HttpHeaders headers = new HttpHeaders();<br>            headers.setContentType(MediaType.APPLICATION_JSON);<br>            headers.setBearerAuth(AUTH_TOKEN);<br>            HttpEntity&lt;String&gt; entity = new HttpEntity&lt;&gt;(jsonBody, headers);<br>            <br>            //send the request to fb endpoint to trigger WhatsApp message <br>            restTemplate.exchange(ENDPOINT, HttpMethod.POST, entity, String.class);<br>        }<br>        catch(Exception e){<br>            log.info(&quot;Exception: {}&quot;,e.getMessage());<br>        }<br>    }<br>}</pre><p>The above code handles sending a WhatsApp message with the image and event details to users. It’s part of the server-side logic that connects to the Facebook Business API and Unsplash to create that extra “wow” factor with images.</p><p><a href="https://github.com/saurabhcharde/GFormToWhatsapp">This</a> is the GitHub repo with the server-side logic. You can clone it and modify it as per your use case.</p><h3>Wrapping Up</h3><p>By now, you’ve successfully built your very own WhatsApp Assistant! This template can be adapted for any use case — think order confirmations, service updates, or event reminders.</p><p>If you run into any issues or have questions, feel free to reach out to me at csaurabh17@gmail.com. If you’re curious about an interesting use case of WhatsApp assistants in health and fitness, check out the B2B product I’ve been working on <a href="https://github.com/saurabhcharde/aahaar360.github.io/blob/main/Landing_Page_Desktop_final.jpg">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*MFbwAVjlrbmpceo6bIZq5w.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3675740e6974" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Facial Expression Recognition on FIFA videos using Deep Learning: World Cup Edition]]></title>
            <link>https://medium.com/ai-enigma/facial-expression-recognition-on-fifa-videos-using-deep-learning-world-cup-edition-2aa61715d325?source=rss-a540faa5f108------2</link>
            <guid isPermaLink="false">https://medium.com/p/2aa61715d325</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[fifa]]></category>
            <dc:creator><![CDATA[Saurabh Charde]]></dc:creator>
            <pubDate>Thu, 30 May 2019 10:30:41 GMT</pubDate>
            <atom:updated>2019-05-30T10:38:21.186Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Few Hearts were broken few still live. No matter who wins, the game will still make me thrill.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*7plHCvC13Iny6T1QEqlH1w.gif" /></figure><h3><strong>Introduction</strong></h3><p>Fifa world cup 2018 has become one of the highest goal scoring world cups in history. No matter which country is playing, the moment those 11 players step on the field, people get connected to them emotionally. While watching them we share their joy, fear, and excitement through the expression conveyed by them. So in this article, we are going to make use of Deep Learning &amp; Image Processing to detect some of those cool expressions we have witnessed during this FIFA world cup 2018.</p><p>Don’t worry if you aren’t familiar with any of the terms mentioned above, I have tried my best to keep this article simple, yet informative. So just keep reading!!</p><h3><strong>What’s in this article?</strong></h3><p>Let me walk you through the structure of this article.</p><p>1. In the beginning, we are going to apply face detection to detect the faces of players in FIFA videos.</p><p>2. Use Deep Learning (specifically Convolution Neural Networks) to train our model on a facial expression dataset.</p><p>3. Finally, we are going to test it on FIFA videos by first detecting the faces and then giving it to the Deep Learning model to detect the expression portrayed by the player.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*oURfHMP1--ttXnDx0heusg.png" /></figure><p>This is going to be pretty exciting cause its none other than Christiano Ronaldo who is going to be the primary test model for the rest of this article. Hope you all are ready. So let’s get started!!</p><h3><strong>Face Detection</strong></h3><p>In order to recognize the facial expressions we first need to detect the faces in an image. Face detection involves locating the face of a person in a given image. It is used in applications like Facebook to automatically tag your photos, in face filter apps to improve your photos, and in augmented reality, applications to put any cool shades on your face.</p><p>There are many ways available to detect faces in an image but we are going to use the popular <em>Haar Cascade Classifiers</em> which are machine learning models trained to detect a specific object in an image (like face, eye, lips, etc).</p><h3><strong>Haar Classifier (overview)</strong></h3><p>If we look at the structure of a human face then there are some features which are common in each of them. For e.g. The region of the eye is darker than the cheeks, the nose top is brighter than the region on either side of it, the region of lips is brighter than the region just below the lips, etc.</p><p>A Haar Classifier works on similar principals. It has a set of features which it tries to detect in an image. If the image contains those features, then it means the image contains a face in it, and if the features are not found then there is no face present in the image.</p><h3><strong>Haar Classifier(working)</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*nXNRv1C7JziCD-u6xMR1lw.jpeg" /><figcaption>Credits: <a href="http://www.sra.vjti.info/">http://www.sra.vjti.info</a></figcaption></figure><p>A haar classifier is trained on a large number of images containing faces (positive examples) and non-faces (negative examples). There are several types of features it tries to look in an image (like line, edge, center-surround features). A sliding window passes through the entire image and the features are applied to the area under the window. The classifier subtracts the sum of pixels under the white region of the window from the black region window. If this value obtained is above a threshold then the feature is said to be detected.</p><p>In order to select the most relevant features among the set of features an optimization algorithm called AdaBoost is used while training. Adaboost selects only those features which lead to increased accuracy in the detection of faces in the image. These features are further divided into levels (cascaded) in order to reduce the time required for detection. For e.g., if the feature at level 0 is not detected then the image is discarded without looking for features at upper levels (hence reducing the time).</p><h3><strong>Using Haar Classifier for face detection</strong></h3><p>We are going to use OpenCV which is a popular open source library of well know functions required for image processing (like image resizing, background subtraction, edge detection, object detection, etc). OpenCV contains a pre-trained Haar cascade classifier for face detection which is stored as an XML file (haarcascade_frontalface_default.xml). Basically, this file contains information about the different features to be tested on an image with their threshold values.</p><p>The code for detecting faces in an image using haar cascade classifier is as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a2b3e8e8829844f73c0158e6331b3ef/href">https://medium.com/media/4a2b3e8e8829844f73c0158e6331b3ef/href</a></iframe><p>Here faces is a list containing the location of the face inside the image.</p><p>So finally we have reached to end of the first section. In this section, we successfully learned the basics of face detection &amp; a very popular way of detecting faces using Haar classifiers. Now we are done with recognizing faces and let’s move on to the next section which is going to be quite interesting because we are going to build our own Deep learning model for detecting expressions in our images.</p><p>So ready to dive in Deep, cause I am!!!</p><h3><strong>Deep Learning</strong></h3><p>Deep Learning involves using a large number of layers of a neural network in order to learn complex features from the given data. There are different types of neural network models used for various purposes like the prediction of weather, image classification, speech recognition, natural language understanding, etc.</p><p>In our case, we will be using Convolution Neural Networks (CNN) which are found to perform well on tasks involving image data.</p><h3><strong>Data Set</strong></h3><p>In order to make our deep learning model to detect expressions, we need to first train it using a facial expression dataset. The dataset used for this purpose is the fer2013 dataset which was hosted on Kaggle as a part of Facial Expression Recognition Challenge. The data consists of 48x48 pixel grayscale images of faces. The faces have been automatically registered so that the face is more or less centered and occupies about the same amount of space in each image. The dataset consists of facial expression belonging to these seven categories (0=Angry, 1=Disgust, 2=Fear, 3=Happy, 4=Sad, 5=Surprise, 6=Neutral). The training set consists of a total of 28,709 images and the test set consisted of 3,589 images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*dbfVxmEX7F06tmUuuO9FuQ.png" /><figcaption>Fig: Example images from the dataset</figcaption></figure><h3><strong>Convolutional Neural Networks</strong></h3><p>Have you ever imagined how you identify your Dad from a whole bunch of people around you? It’s because your brain has stored his certain body features like his hair, height, body shape, nose, eyes, etc. which helps you to distinguish him from other people. The part of the brain which helps in doing this visual processing is called the visual cortex of the brain.</p><p>The visual cortex receives visual information coming from your eyes i.e the things you see (here your dad) and further processes and tries to understand the thing you are looking at.</p><p>Now a convolution neural network works somewhat similar to the visual cortex of the brain. It receives an input image [an array] and it tries to detect features from the image in order to identify what the image is all about.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*3Oychlnlm8yUYrpqE1i8Nw.png" /></figure><p>The convolution layers are a set of kernels (or feature detectors) which are used to extract features from the image. Example of features in our case can be whether the teeth of the person is visible or not, whether his lips are raised or not, etc. Now, these are only a few examples of features but in reality, CNN can detect a large number of features that may help to detect the emotion of a person.</p><p>This is just an intuitive explanation of how CNN works. But there is a lot more that goes in the background. I have not covered the maths part of CNN as it will make things complicated and is beyond the scope of this article.</p><p>The code for building the CNN model is shown below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6e91bd8f3685fecd89a578086e5b8632/href">https://medium.com/media/6e91bd8f3685fecd89a578086e5b8632/href</a></iframe><h3><strong>Results</strong></h3><p>Once the model is trained on the dataset provided, now its time to test it on some real stuff. I have chosen a video featuring Ronaldo which will be used for testing the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*wI8rLeFR3uqeNv5cuffVzg.gif" /><figcaption>Results obtained from the trained model</figcaption></figure><h3><strong>Conclusion</strong></h3><p>Hope you have understood how a modern emotion recognition engine works and now you can build one for your own. The techniques explained in this article for face recognition and emotion detection are used in many places today. So understanding how these stuff work will enable you to explore &amp; understand more interesting things build using them like the automatic tagging system(one that Facebook uses), object detection, style transfer, etc.</p><p>If you like the article please spare time to give a clap and if possible do share it with your friends and colleagues. I have attached the link to my GitHub repo containing code to reproduce the model if you want. Do have a look at it and hope you find it useful.</p><p><a href="https://github.com/saurabhcharde/Emotion-Recognition">saurabhcharde/Emotion-Recognition</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2aa61715d325" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ai-enigma/facial-expression-recognition-on-fifa-videos-using-deep-learning-world-cup-edition-2aa61715d325">Facial Expression Recognition on FIFA videos using Deep Learning: World Cup Edition</a> was originally published in <a href="https://medium.com/ai-enigma">AI Enigma</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Am I Talking to the Real You?]]></title>
            <link>https://medium.com/ai-enigma/am-i-talking-to-the-real-you-61e231e61bea?source=rss-a540faa5f108------2</link>
            <guid isPermaLink="false">https://medium.com/p/61e231e61bea</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[google]]></category>
            <dc:creator><![CDATA[Saurabh Charde]]></dc:creator>
            <pubDate>Tue, 26 Jun 2018 16:17:21 GMT</pubDate>
            <atom:updated>2019-05-30T10:42:18.717Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*b1wFFJy-stqWfeIeaSDRSg.jpeg" /><figcaption>Image Source : Scrabbl.com</figcaption></figure><p>There has been a while since the release of Google Duplex at Google I/O 2018. But I still find people misinterpreting the way how Duplex works. But I don’t blame the people because I too was shocked when I saw this thing in action at Google I/O. Hence I decided to make a quick article explaining the real story behind Google Duplex and clearing some of the common misconceptions about it. I have put a short illusive story to explain my point in a more intuitive way.</p><blockquote><em>Last week I was assigned the task of inviting my family members for a function. Considering that I didn’t have a messaging group of my family members, I needed to call them individually. Now that is a pretty tedious, boring, repetitive and a time consuming task. But no big deal, my phone did it for me so that I could watch my favorite FIFA team winning.</em></blockquote><p>Now the question arises is that “How did my phone invite my family members without even messaging them and without me talking to any of them? Did my phone just talked to them and invited them all by itself? How did it fool those guys to believe that it was a human talking to them? ”.</p><p>Let’s break the suspense and come to the meat of this article &amp; know how all this happened.</p><p>Recently Google’s most anticipated event of the year <em>Google I/O </em>came to an end. This year Google revealed some exiting updates coming to its group of products. It included the <em>Smart Compose</em> feature in Gmail which suggests words to complete your sentence, Google Images will now help you find similar products to your images and finally some augmented reality coming to Google maps this year. Even though these updates may sound amazing, it would be fair to say that they all were dominated by a single and the most talked about product of Google I/O 2018 <em>The Google Duplex</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*KF3gGlTkmxQYLbPloSmIVQ.jpeg" /><figcaption>Google duplex reserving a table by conversing with a Human.</figcaption></figure><p>Duplex is a technology to enable computers to have a natural conversation over phone. It is a conversational AI which sounds like a human and can complete sophisticated tasks without sounding like a computerized voice. The goal was to enable people to have a natural conversation with computers, as they would with each other. In the past years, many autonomous bots were introduced like <em>Siri</em>, <em>Alexa</em>, and <em>Cortana</em> which provided a way for humans to communicate with computers using natural voice. But often it’s quite frustrating to hear these computerized voices that often don’t understand natural language. Duplex is a big leap in this field as it is designed completely to sound like a human and carry out natural conversations with them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VcucoaGWEcaeGftk5ktTDA.png" /><figcaption>The complete Google Duplex Pipeline</figcaption></figure><p>Coming to its working, the duplex systems involves the following steps:</p><p>1.User tells Google assistant to Book an Appointment with a Client.</p><p>2. Google Assistant then tells Duplex to make a call to the respected Client.</p><p>3. Google Duplex calls the Client, talks to him, asks for an appointment and books it.</p><p>4. Google Duplex then returns the call information back to Assistant.</p><p>5. Finally Google Assistant displays the result to the user.</p><p>It’s interesting to note that the Client never came to know that he was talking to a Computer and not to a human. This means that it’s for the first time a machine is able to fool a human by completely mimicking a human voice.</p><p>It led to a big debate among people that ,</p><blockquote>“Has Google Duplex successfully passed the Turing Test?”</blockquote><blockquote><strong>Turing Test</strong> — “When a machine start to mimic humans and develop enough intelligence that it is impossible to differentiate between a machine and a human.”</blockquote><p>But the reality is that, “No, Google Duplex didn’t pass the Turing Test Completely”.</p><p>Because although Duplex was able to make natural conversations with humans, it works best when it’s performing a very specific task (i.e. scheduling an appointment or reservation at a very specified time) and less suited to make a general conversation out of the task assigned to it. Google Duplex was trained using Deep Learning for very specific situations and hence cannot be called a general machine which can carry out any type of conversations.</p><p>Even though the shortcomings Google Duplex has a wide range of applications for many businesses.</p><p>Some Applications include:</p><p>· Duplex can call a Doctor and book an appointment for you.</p><p>· In case of noisy/crowded locations, duplex can talk to other person on your behalf.</p><p>· Hearing-impaired users, or users who don’t speak the local language can use duplex to make calls on their place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*ONBYM78bRcOtxP_H_Gim1w.jpeg" /><figcaption>Yaniv Leviathan, Google Duplex lead, and Matan Kalman, engineering manager on the project, enjoying a meal booked through a call from Duplex.</figcaption></figure><p>Google Duplex can be seen as an effort to increase and improve Human-Computer interaction. It’s only the start for systems like Duplex and they are bound to improve in the future. These advancements will enable humans to increase their productivity by better interacting with computers. But with increase in human sounding computers, there are many possibilities of misusing them.</p><p>Eventually when a computer masters human voice, the biggest concern will be that people will start using computers to talk on their behalf. This may confuse other people and as a result give rise to a new question in their minds that,</p><blockquote>“Whether I am talking to the real you?”.</blockquote><p>References : Google AI Blog</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61e231e61bea" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ai-enigma/am-i-talking-to-the-real-you-61e231e61bea">Am I Talking to the Real You?</a> was originally published in <a href="https://medium.com/ai-enigma">AI Enigma</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Predicting Pokemon Battle Winner using Machine Learning]]></title>
            <link>https://medium.com/ai-enigma/predicting-pokemon-battle-winner-using-machine-learning-d1ed055ac50?source=rss-a540faa5f108------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1ed055ac50</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[pokemon]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[random-forest]]></category>
            <dc:creator><![CDATA[Saurabh Charde]]></dc:creator>
            <pubDate>Sat, 23 Jun 2018 21:26:25 GMT</pubDate>
            <atom:updated>2020-07-25T07:28:44.573Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j7dwLFVWjLVRPQFTjMsmgg.jpeg" /><figcaption>Image Source : The Verge</figcaption></figure><p>In this article we are going to use Machine Learning to predict the winner of a Pokemon battle. This is going to be exciting because we are going to predict the results of the battles we have never seen before. If you want to follow along then the links to the <a href="https://github.com/saurabhcharde/Pokemon_Battle_Winner_Prediction_using_ML">Jupyter notebook</a> containing code is linked here. Finally feel free to show it to your friends and become a Pokemon wizard by predicting Pokemon battle results like a pro!</p><h3>Introduction</h3><p>We are all familiar with the popular Pokemon series that made an amazing part of our childhood. Recently the Pokemon Go game brought back the same craze for Pokemon within us. Now the problem in our hand is that given some features about each Pokemon such as its attack, defense or its speed value,etc we need to predict the winner of a random Pokemon battle which has never occurred before. Sounds Interesting!!</p><p>But before beginning lets get familiar with the background.</p><h3>Machine Learning</h3><p>The difficulty in predicting the winners lies in fact that, we only know about a handful of Pokemon but in fact there are currently around 800 species of Pokemon present in the Pokemon world. That’s a lot of Pokemon. Now in order to predict the winner of a battle we need to study about all those 800 Pokemon, watch their moves, their special attacks, their matches, etc. In short there is a lot of things (data) to take in account and hence will require us days to acquire sufficient knowledge to correctly predict the winners of a battle. (Convinced?)</p><p>This is where Machine Learning becomes useful. When you have a lot of data and you need to make some prediction (Predicting today&#39;s weather, Predicting disease based on symptoms,etc.) from it we use Machine Learning (Pretty simple!).</p><h3>A Look at the Dataset</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*_slAQjDA8MfU1pl8y901Ig.png" /><figcaption>First 5 rows of the dataset</figcaption></figure><p>A dataset is the collection of large amount of data on a specific topic(here Pokemon). This dataset provides us with information like the Hit Points, attack, Special Defense and weather the Pokemon is legendary(1) or not(0). The figure shows the data of the first 5 Pokemon , but there are a total of 800 Pokemon (means 800 rows) in the dataset.</p><p>Now having seen the dataset, get ready to apply some Machine Learning on it.</p><h3>How to apply Machine Learning</h3><p>Building a complete ML model involves 3 steps:</p><p>1. Build the classifier</p><p>2. Train the classifier</p><p>3. Test the classifier</p><h3><strong>Build the Classifier</strong></h3><p><em>Note: A classifier is used to classify or separate the data into classes. For eg. Given an image classify it as a Dog or a Cat.</em></p><p>In order to learn from data we need to use some ML models(classifiers) which generally are algorithms which find patterns in the given data to help them in making predictions(Confusing? just keep reading).</p><p>For this task we will be using a Random Forest Classifier which is a better implementation of a Decision Tree Classifier.</p><h3>Knowing about them</h3><h4>Decision Trees</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p2-574NEeJjZC203atY7ng.png" /><figcaption>A simple Decision Tree for classifying an animal</figcaption></figure><p>Suppose we have a task of predicting the animal based on the features like type , height ,weight, or speed of the animal. This task can be easily modeled using a decision tree as shown in fig. So at each point of the decision tree we ask a question and depending on the answer we further divide the tree into sub trees. This process is repeated until we predict an animal. So given a dataset, a Decision Tree Classifier will ask the right questions(increasing the Information Gain) at each point so as to divide the tree in a way to increase confidence for each prediction (increasing purity of result).</p><blockquote>Time Complexity = O(depth)</blockquote><h3>Random Forests</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*id1L4sa1XQz9Lm58A7ahRg.png" /><figcaption>A simple Random Forest visualization</figcaption></figure><p>As forests are collection of trees, hence Random Forest Classifier uses multiple Decision Trees and finally combines the results from each decision tree to predict its final result. We can think of it as combining the things learnt by multiple trees into a single one. This method is found to give better results than using a single Decision tree.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*FMr_19WElRn-L_NZ55LzwA.png" /><figcaption>Forest with 100 decision tress</figcaption></figure><p>Finally we build a random forest classifier as follows. The n_estimators gives the Number of decision trees(here 100) used to make the forest.</p><h3>Train the classifier</h3><p>Reiterating the task, two Pokemon with their set of features(speed,attack,etc) which one is going to win.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*er11RzkGaY8Sx8owsgZOEg.png" /><figcaption>Training &amp; Predicting accuracy of classifier</figcaption></figure><p>We train(or fit) the classifier on the dataset of Pokemon(i.e x_train) and minimize the loss between the predicted and the actual values(y_train) on the training set. Training here means finding the relations between different features in dataset to make predictions.</p><p>We then calculate the accuracy of our classifier which is found to be 95% (means say our classifier will predict right results for 95 matches out of 100) which is a pretty good accuracy to start with.</p><p>By now, we have completed all the required steps from building a classifier to training it and now we are ready to test it on some real stuff.</p><h3>Test the Classifier</h3><p>At last the time has came .Lets just give some random Pokemon matches to the classifier and let it predict for us who is going to win. We have stored all these random matches in another dataset called the test_data.</p><p>It looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/1*LJ5dC54vVz_qkIvZjAj5pA.png" /><figcaption>Test dataset with sample matches</figcaption></figure><p>The two columns correspond to the Pokemon that are going to compete. We are feeding these two Pokemon into the classifier and it will return the most likely winner for that battle. Remember the classifier is not just randomly predicting the winner. In fact it is analyzing several parameters carefully to reach at the right decision.(That’s the power of ML)</p><p>So ready to see the winners.</p><p>Now who do you think should win among <strong>Onix</strong> and <strong>Pidgey</strong>?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*q5ZyXGDqdLlIw2QW8M1ndA.png" /><figcaption>Image Source : Google Images</figcaption></figure><p>Let’s use our Machine Learning Model to predict it for us.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/232/1*pHb0F2Jaeea6gx2_BdjlOw.png" /></figure><p>That was quite obvious. Now lets give it some tricky ones.</p><p><strong>Mr. Mime</strong> vs <strong>Psyduck</strong> what do you think?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*JrOAzx5n7OZ45PEViH5PAQ.png" /><figcaption>Image Source : Google Images</figcaption></figure><p>As a matter of fact these matches has never occured in the pokemon series before, and we are predicting there results(Feels good!).</p><p>So who is going to win ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*43nqTj_P8IZPgpK-9-FPDQ.png" /></figure><p>If you carefully study it , then Mr. Mime has a better chance of winning it.</p><h3>Last words</h3><p>We have seen a pretty basic problem which can be solved using ML. The concepts covered in this article forms the basis of most ML approaches. I have tried to explain the concepts in the most simplest way so that everyone can get a fair understanding of how ML works and can be used in real world.</p><p>Finally I would like to hear your suggestions on this article so that I can bring more quality content in future.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1ed055ac50" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ai-enigma/predicting-pokemon-battle-winner-using-machine-learning-d1ed055ac50">Predicting Pokemon Battle Winner using Machine Learning</a> was originally published in <a href="https://medium.com/ai-enigma">AI Enigma</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>