<?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 RADIO SAYS Arpit pathak on Medium]]></title>
        <description><![CDATA[Stories by RADIO SAYS Arpit pathak on Medium]]></description>
        <link>https://medium.com/@arpitpathak114?source=rss-e88079b64752------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*u2mzpK9FcWJYIotp</url>
            <title>Stories by RADIO SAYS Arpit pathak on Medium</title>
            <link>https://medium.com/@arpitpathak114?source=rss-e88079b64752------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 10:32:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arpitpathak114/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[Naive Baye’s Algorithm]]></title>
            <link>https://medium.com/ml-with-arpit-pathak/naive-bayes-algorithm-fe7d1a94bd9a?source=rss-e88079b64752------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe7d1a94bd9a</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[naive-bayes]]></category>
            <category><![CDATA[naive-bayes-classifier]]></category>
            <category><![CDATA[internity-foundation]]></category>
            <dc:creator><![CDATA[RADIO SAYS Arpit pathak]]></dc:creator>
            <pubDate>Sat, 20 Jun 2020 11:37:07 GMT</pubDate>
            <atom:updated>2020-06-20T11:37:07.561Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Hello readers , this blog explains about a machine learning algorithm called Naive Byes . We will deep dive into the basic concepts of Naive byes and understand how it works . This algorithm of machine learning considers some of the basic principles of probability for making predictions .</strong></p><h3>Basic Terminologies</h3><p>Before going for the Naive Byes Algorithm , let us first understand some of the terminologies related to probability . For this , let us consider an example of a pack of cards which has 52 cards .</p><h4><strong>1) Independent Events</strong></h4><p>Let us consider we have two events —</p><ol><li><em>Drawing a Queen card from the pack of 52 cards</em> .</li><li><em>Draw a King card from the pack of 52 cards .</em></li></ol><p>Now , let us try to find out the probability of these two events —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*2iyPHBj1UWXtc8Pcct5xmg.png" /></figure><p>These two events do not rely on one other so they are not correlated and hence are called independent events .</p><h4>2) Dependent Events</h4><p>Now let us consider 2 more events as follows —</p><ol><li><em>Drawing a Queen card from the pack of 52 cards .</em></li><li><em>Drawing another Queen card from the remaining pack of 51 cards .</em></li></ol><p>Now , let us try to find the probability of these two events —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*py3ByxXtzB9GwILx2pG0Ag.png" /></figure><p>We can see that in above two cases , the second event is dependent on the first event . So , the second event is known as dependent event .</p><h4>3) Conditional Probability</h4><p>Now , if we consider the above Dependent Event 2 then we can present it in the form —</p><p>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; P (event2 | event1) = 3/51 &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;</p><p>This says that the probability of Event 2 given that Event 1 has already occured is 3/51 . This is known as the conditional probability . Let us see the formula for conditional probability —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*KpHdW-doHXTzS8qR4gVzeQ.png" /><figcaption>Conditional Probability</figcaption></figure><h4>4) Baye’s Theorem</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*UibL32JOM3VI9s7An2ms1Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*8bRsUPvwWQySinKENjbG8Q.png" /></figure><p>This is the Theorem that is used in the Naive Baye’s Algorithm for training and predictions .</p><h3>Naive Baye’s Algorithm</h3><blockquote>Naive Baye’s is a supervised machine learning algorithm that works on the principle of Baye’s Theorem and is used for classification based learning and predictions . The most important assumption for Naive Baye’s is that any feature in the dataset is completely unrelated to any other feature in that dataset .</blockquote><p>Let us try to understand the working of Naive Baye’s theorem from an example mathematically .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*-jUTyYAP1hGOyIEdkoIMvA.png" /></figure><p>Let us consider a dataset in which we have 2 independent features Xa and Xb and one dependent feature Y . This Y is the output of out model and it has a binary output of Yes or No only . The dataset has ‘p’ records in all .</p><p>The probability of “Yes” or “No” in the Y is called “Prior” .</p><p>P (Yes) = (no. of Yes) / p</p><p>P (No) = (no. of No) / p</p><p>The Bayes Theorem for this dataset can be said as —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*7fgDLgNAzqL09Sn2kcMn7g.png" /></figure><p>This is the Baye’s Theorem to be used in this dataset for training it over the data and doing predictions .</p><p>Now , since there are two outputs for Y i.e “Yes” and “No” , hence the Naive Baye’s algorithm finds the probability for both types of output as follows —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*6NjdR2YyisQlKV2z1a4b6w.png" /></figure><p>Now , to find the Output , the absolute Probability of “Yes” and “No” is calculated as follows —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*EdaKZNwoMo7uUbQwukz67A.png" /></figure><p>Now , if the values of Pa(Yes) is Higher , then the output is Yes otherwise “No” .This is how the Naive Baye’s works in prediction .</p><blockquote>That is all about this blog . Thank you for reading !!!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe7d1a94bd9a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml-with-arpit-pathak/naive-bayes-algorithm-fe7d1a94bd9a">Naive Baye’s Algorithm</a> was originally published in <a href="https://medium.com/ml-with-arpit-pathak">ML_with_Arpit_Pathak</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Random Forest]]></title>
            <link>https://medium.com/ml-with-arpit-pathak/random-forest-51852222ef68?source=rss-e88079b64752------2</link>
            <guid isPermaLink="false">https://medium.com/p/51852222ef68</guid>
            <category><![CDATA[random-forest-algorithm]]></category>
            <category><![CDATA[internity-foundation]]></category>
            <category><![CDATA[random-forest-classifiers]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[RADIO SAYS Arpit pathak]]></dc:creator>
            <pubDate>Sat, 20 Jun 2020 05:53:49 GMT</pubDate>
            <atom:updated>2020-06-27T10:15:53.637Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Hello readers , in this blog we will discuss about one of the most preferred algorithm in Machine Learning for better results over non-linear data , Random Forest Algorithm . We will try to understand how this algorithm works and what implementations of this algorithm are conducted on continuous and classification data .</strong></p><h3><strong>Random Forest</strong></h3><blockquote>Random Forest is a supervised machine learning algorithm that works on the principle of ensemble learning and uses a combination of decision trees for making predictions . The training of the random forest model is done through the process of bagging and feature randomness for creating each decision tree so that each tree is almost negligible correlated to the other one .</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/259/0*Aqye9ol2AWZwcnXB" /><figcaption>Image source : <a href="https://lh3.googleusercontent.com/proxy/vFDTnVowgFhkjPbFdBW6su2xElATL6D40mlBnD59BQtVDdsSXR7hfRwLHXvi69tgAgc-2gCaZKs4fN0cdxgGzW9cIj2lSOOnkjqH">here</a></figcaption></figure><p>The idea of Random Forest can be easily explained through its name only . We know that in a forest , there are multiple trees and each tree is different from the other and have different quality and outputs . But the inputs to each trees are same i.e sunlight , water , soil minerals etc . These inputs are required in a different quantity and quality in each tree . So , the inputs to all the trees are same but in a random manner and each tree utilizes these inputs to give a different output . This is the main idea behind the Random Forest algorithm also .</p><p>In order to understand the working of random forest , you have to understand some of the basic terminologies —</p><ol><li><strong><em>Ensemble Method</em></strong> : Ensemble method is the process in which we use multiple models to train over our data and combine the outputs/predictions of these models to get the final prediction or output. This type of methods provides better predictions as compared to single model .</li><li><strong><em>Bagging(Bootstrap Aggregating) Concept :</em></strong> Bagging refers to making multiple samples of the training data by selecting random data from the original training set with replacement . This concept is used in ensemble method to create training samples for each model we use . Bootstrapping says that the new sample created from the original sample can contain duplicate data . This method is used to reduce the variance in the ensemble sub models that are Classification and Regression Trees (CART) like Decision Trees .</li></ol><h4>WORKING OF RANDOM FOREST</h4><p>The Random Forest works by ensembling a number of decision trees for prediction . When the initial data is given to the Random Forest , n number of samples of data are created based on the concept of Bootstrap aggregating . The number of samples is equal to the number of decision trees used . Each of these samples is given to a decision tree that predicts an output values and then these prediction values of all the decision trees are combined to get the final output or prediction .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jt4tNahTDQVdxQoew9KtnA.png" /><figcaption>Working of Random Forest</figcaption></figure><p><strong>Combining outputs of Continuous values</strong>: If the output predictions are a continuous values like salary prediction , then the mean or median of the values of the predictions of different decision trees are given as the final output .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*4arqqe0pdq4vZYUuerIZKA.png" /></figure><p><strong>Combining outputs in Categorical values </strong>: If the ouput predictions are a categorical value , then the majority vote among all the predictions of decision trees is given as the final output .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*9EwQeAO4QFqNDZDh5zSFKA.png" /></figure><h4>This is all about the working of the random forest . Now , let us deep dive into the parameter we can change to obtain better accuracy from our Random Forest model —</h4><h4>Hyper Parameters in Random Forest</h4><p>Hyper Parameters are the values that can be changed in order to control the learning process of the model . The tweaking of these parameters is done make out model more accurate . Let us see some of the hyper parameters that we can tweak in Random Forest —</p><ol><li>n_estimators : how many decision trees to use .</li><li>max_features : maximum features needed to split a node in each decision tree .</li><li>max_depth : maximum levels of each decision tree .</li><li>min_samples_split : minimum data values needed in each node to split it .</li><li>min_samples_leaf : minimum values to be there in a leaf node of decision tree .</li><li>bootstrap : method of sampling . Can be with or without replacing .</li></ol><h4>Advantages of Random Forest</h4><ul><li>Less affected by outliers or robust to outliers in data .</li><li>Can be used for both classification and regression problems .</li><li>Automatic handling of missing values .</li><li>Solves the problem of high variance .</li></ul><h4>Disadvantages of Random Forest</h4><ul><li>Complex computing .</li><li>Requires more time to get trained .</li></ul><blockquote>This is all about this blog . Hope it was an informative one . Thank you for reading…</blockquote><p>//Machine Learning Internship at Internity Foundation</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51852222ef68" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml-with-arpit-pathak/random-forest-51852222ef68">Random Forest</a> was originally published in <a href="https://medium.com/ml-with-arpit-pathak">ML_with_Arpit_Pathak</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decision Tree and Its Mathematical Concept]]></title>
            <link>https://medium.com/ml-with-arpit-pathak/decision-tree-and-its-mathematical-concept-53f80adc646d?source=rss-e88079b64752------2</link>
            <guid isPermaLink="false">https://medium.com/p/53f80adc646d</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[decision-tree]]></category>
            <dc:creator><![CDATA[RADIO SAYS Arpit pathak]]></dc:creator>
            <pubDate>Wed, 17 Jun 2020 04:58:07 GMT</pubDate>
            <atom:updated>2021-02-24T11:34:05.124Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello readers , so here is the next very interesting type of concept and algorithm in machine earning called the Decision Tree . This blog covers the introduction to Decision Tree and its mathematical concept of how it is implemented .</p><h3>What is a Decision Tree</h3><blockquote>A Decision Tree is a representation of all the possible solutions to arrive at a decision based on some conditions in a graphical way or in the form of a hierarchical tree .</blockquote><p>Let us take an example by assuming that we have to decide whether to go out and play with friends , go out and do cycling , be at home and play chess with you sibling or be at home and play an online game . Let us see how the decision can be taken .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dQ6dT9ZNcFlna6TcykOMeQ.png" /><figcaption>Decision Tree Example</figcaption></figure><p>So , in the above example image , we took a decision by converting the whole problem into a hierarchical tree of step wise decisions or segment to come out with a final solution . This is the tree based decision making called as decision tree .</p><h3>Some Basic Terminologies</h3><ol><li><strong>Entropy</strong>: It is defined as the randomness in the data or the unpredictability of the data. The goal of the decision tree algorithm is to decrease the entropy of the data to zero or close to zero by classifying it on the basis of different features and conditions.</li><li><strong>Root Node</strong>: The root node or the of the decision tree is the topmost node to which the whole dataset is given. Then the data is classified from root node to the sub nodes or child nodes on the bases of some feature or condition . For example : in the above image of decision tree , the weather type is the root node .</li><li><strong>Parent Node and Child Nodes</strong> : Every node that classifies the data on the basis of some condition or the feature is called the parent node and the sub-nodes of this parent node are known as the child nodes . For example : in the above image of decision tree , the “Weather type” is parent node and “Go outside” and “Stay at home” are its child nodes . Same applies to the “Go outside” as parent node and its sub-nodes “Play with friends” and “Do cycling” as its child nodes .</li><li><strong>Level Of Classification : </strong>The level of classification tells the number of classifications that are performed on the data . When the data is given to the root node , it is the Level 0 of classification .</li><li><strong>Information Gain : </strong>If we take a theoretical approach to this term , then information gain is the amount of entropy that has decreased at every classification level or we can say that the decrease in the randomness and increase in the predictability of the data . The information gain is calculated at each level of classification by comparing the entropy of the data before and after the classification .</li><li>Leaf or Terminal Node : The leaf node is the last node in the decision tree after which no further classification can be performed or need not to be performed . In other words , the leaf node is the node in which the least entropy of the data is achieved and the data in the leaf node is homogeneous in nature .</li></ol><h3>Decision Tree Concept</h3><blockquote>A Decision Tree concept is a regression based algorithm which uses the regression technique of the dependency of a categorical variable on the other categorical independent variables and then performs the classification by adding label to each decision i.e the unique category name .</blockquote><blockquote>A decision tree takes the whole data and keeps partitioning this data into subsets depending on certain conditions until each subset becomes homogeneous i.e all the values in the subset are similar to each other .</blockquote><p>Let us consider the following data of type of vehicle —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*KdpIWOrg-I8KYLrK_pGP3g.png" /></figure><p>In this data , the decision is to be made to predict the vehicle name according to the properties like number of wheels , height of vehicle and presence of engine . The decision tree will take each of the property decision and classify the vehicles based on them until each classification is homogeneous as follows —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-fCKTrp4dsMO2rl7aXmHJg.png" /></figure><p>At the Level 0 , the prediction of vehicle type is not possible because the the type of vehicles are very random and hence the entropy or randomness of the data at Level 0 is very high .</p><p>At Level 1 , the vehicles are classified on the basis of the number of wheels they have and hence we can classify the vehicles into wheeler , 3 wheeler and 4 wheeler . Since , the randomness of the data has decreased , the entropy of this level has decreased w.r.t Level 0 . But there are still random values in each of the 3 categories of wheels . So , we move to classify again on another basis .</p><p>At Level 2 , the vehicles are again classified on the basis of the either the vehicle has a engine or not . Here , the homogeneity or the similarity of data in each category is achieved in the 2 wheeler and 3 wheeler and the entropy in these two categories become zero . So , no further distribution is required . However , in the 4 wheeler distribution of engines , the entropy has not come to zero and therefore we need to again segment this data .</p><p>At Level 3 , finally the whole data has become homogeneous and the overall entropy of the data is zero . Now the name of the vehicle can be easily and accurately predicted .</p><h3>Working of Decision Tree and Mathematical Concept</h3><p>Now you might be thinking that how does the decision tree know that which partitioning feature to apply at which level ??</p><p>In order to understand this ,at first the decision tree calculates the uncertainity or randomness in the dataset at a certain level by using a concept metric called <strong><em>Gini Impurity</em></strong> . Then it takes each feature , classify the data and compares the change in Gini impurity in the next classified level with the previous level by a method called <strong><em>Information gain</em></strong> . Whichever feature or condition give the highest information gain is applied to the decision tree at that particular level .</p><ul><li>Formula for calculating the gini impurity is as follows —</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*Fnp9lnMigvm3gnn3YLH1Ug.png" /></figure><p>Here , “C” is the number of classes of the data at a particular node and “p” stands for probability . So , the gini impurity is the “summation of square of the probability of each class or category in the dataset” decreased by 1 .</p><ul><li>Formula for calculating the Information gain is as follows —</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/407/1*bJOfwFM9ac8d0NfeHjiR_A.png" /></figure><p>Here , Entropy(T) represents the Entropy of the data at the current level “T” and Entropy(T,X) represents the Entropy of the data after applying the condition “X” on the level “T” .</p><p>The Decision Tree concept works on the Classification and Regression Trees (CART) algorithm that uses this Gini Impurity metric as the mathematical tool for training the dataset by making a Decision tree .</p><blockquote>That’s all about this blog . Hope it was an informative one . Thank you for reading…!!!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53f80adc646d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml-with-arpit-pathak/decision-tree-and-its-mathematical-concept-53f80adc646d">Decision Tree and Its Mathematical Concept</a> was originally published in <a href="https://medium.com/ml-with-arpit-pathak">ML_with_Arpit_Pathak</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[K-Nearest Neighbors Algorithm]]></title>
            <link>https://medium.com/ml-with-arpit-pathak/k-nearest-neighbors-algorithm-a9559b960fe5?source=rss-e88079b64752------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9559b960fe5</guid>
            <category><![CDATA[internity-foundation]]></category>
            <category><![CDATA[knn-algorithm]]></category>
            <category><![CDATA[machine-intelligence]]></category>
            <dc:creator><![CDATA[RADIO SAYS Arpit pathak]]></dc:creator>
            <pubDate>Mon, 15 Jun 2020 18:58:38 GMT</pubDate>
            <atom:updated>2020-06-15T18:58:38.778Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello readers , this blog explains about the most widely used classification algorithm in Machine Learning called K-nearest Neighbors . We will try to understand about what is the main concept of this algorithm along with its mathematical working .</p><h3>Introduction</h3><blockquote>K-Nearest Neighbors ( KNN ) algorithm is one of the simplest Supervised Machine Learning algorithm that can be used in both Classification and Regression problems but most widely preferred for Classification problems .</blockquote><p>This algorithm is used in cases where the Linear and Logistic Regression cannot be implemented i.e when the data is non-linear separable . Non-linear data is a type of data in which the dependency of dependent variable (y) on the independent variable (x) is not linear . In other words , we cannot draw a best fit straight linear regression line for non-linear separable data .</p><p>In addition to this , KNN is a type of algorithm that uses the <em>Lazy Learning </em>approach in order to train the model . This means that there are no weight and bias ( w and b in y=b + wx) calculated in this algorithm . The model get trained by analyzing a pattern in the data .</p><p><strong>Lazy Learning Approach</strong></p><blockquote>Lazy Learning is a type of approach in which none of the functions or equation is used to derive the relationships in the data (For example : y = b+ wx in regression algorithms ) . In this approach , the whole data is memorized in order to do predictions .</blockquote><p>So , KNN uses Lazy Learning by memorizing whole data and learn from it by finding patterns in order to predict the future data . Now let us understand the working of KNN by explaining the meaning of “K-Nearest Neighbors” term with the help of an example —</p><h3>Working of KNN</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*ThmKpVAAQUr7uKxrdjx23w.png" /></figure><p>Let us consider this graph showing the data plot of the evaluation of students who passed or failed in an exam based on their time dedicated to Studies and Playing ( time pass activities ) . The “green” points show that the student passed and “red” point show that the student failed .</p><p>We can see that the students who give more time to studies have more chance of passing the exams and those who spare their time and didn’t study much get failed . But , there are some cases where a student didn’t study much and passed . Also , in some cases , the student studied well but failed . So , this is a non-linear problem because we cannot derive a smart relationship between the factors of result and output of result .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*aPXbjTVp-ZRr4aeu_elJxA.png" /></figure><p>Now , let a new observation comes (blue point) which we have to predict that the student will pass or will fail . So , how the KNN will predict the output for this new observation ??</p><p>The answer is , by analyzing the output of “K” number of the previous points who are close to the new point . Let us see how —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*dKxoKa5CDic6DCOVLTbzkw.png" /></figure><p>The KNN algorithm first finds out the nearest “K” number of neighbors (here K = 5) . Then it gets the outputs of these neighbors . Whichever output has the highest frequency is allotted as the output for the new point . In the figure , out of 5 nearest neighbors , 4 have an output of Pass , hence the new point will be predicted as “Pass” or we can say that the model predicts that the new student will pass the examination .</p><p>The example above shows the working of the KNN model or KNN algorithm in the Classification problems . Let us see how the KNN works for the continuous data —</p><h3>KNN working on Continuous Data</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*f9XUNGnF4N6LKL2w3uqjsA.png" /></figure><p>Whenever a new prediction is to be done on the continuous data , the KNN algorithm finds out the average output of the K-nearest neighbor points and assign that average as the output for the new point or the output as the prediction .</p><p>Now , the question come that how the KNN algorithm finds out the nearest neighbors to perform predictions ?? Let us see —</p><h3>Mathematical Implementation of KNN</h3><p>The KNN algorithm works on certain steps to do the predictions . These are —</p><ol><li>Find out the distance of all the points from the new point .</li><li>Sort the neighbors in ascending order based on their distance from the new point .</li><li>Determine the output of first “K” points who are nearest to the new point .</li><li>Continuous Data : Find the average of the outputs and give this average as output prediction . / Categorical Data : Find the category with highest frequency and give that category as output prediction for the new point .</li></ol><p>In order to find out the distance between the new point and each previous point , there can be two ways —</p><ul><li><strong><em>Euclidean Distance</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*sS8zQSBstXyMM81XYBz_Nw.png" /></figure><ul><li><strong><em>Manhattan Distance</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*L0_pAkenlUdpx5cxMMQhNg.png" /></figure><p>So , the KNN uses any of these 2 ways in order to get the distance between the two points .</p><h3>Getting right value of K ( Elbow Method )</h3><p>Now , you might be thinking that how the model decides that what will be the number of neighbors to be analyzed to correctly predict the output o a point . So , here is the answer that the value of K is provided by us ( programmer ) to the model to get trained .</p><p>In order to understand the best K value to have the best accuracy of model , we run the model over different values of K and find out the error for each model train on the previous data . Then this error is plotted on the graph ( K value Vs Error ) and the K value after which the error almost becomes constant is selected for the model . This graph is known as <em>Elbow Graph </em>and the method of selecting the optimal value of K from this graph is called<em> Elbow Method .</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*0m_3PDREy_NiHV-3lmKXww.png" /></figure><blockquote>That is all about the KNN algorithm . Hope it was an informative one for you . Thank you for reading…!!!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9559b960fe5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml-with-arpit-pathak/k-nearest-neighbors-algorithm-a9559b960fe5">K-Nearest Neighbors Algorithm</a> was originally published in <a href="https://medium.com/ml-with-arpit-pathak">ML_with_Arpit_Pathak</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Logistic Regression and its Mathematical Implementation]]></title>
            <link>https://medium.com/ml-with-arpit-pathak/introduction-to-logistic-regression-and-its-mathematical-implementation-67120e8bbc14?source=rss-e88079b64752------2</link>
            <guid isPermaLink="false">https://medium.com/p/67120e8bbc14</guid>
            <category><![CDATA[logistic-regression]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[internity-foundation]]></category>
            <dc:creator><![CDATA[RADIO SAYS Arpit pathak]]></dc:creator>
            <pubDate>Wed, 10 Jun 2020 06:35:09 GMT</pubDate>
            <atom:updated>2020-06-10T10:31:36.977Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello readers , this blog covers one of the most important algorithm of machine learning called Logistic Regression , the need or requirement and its mathematical implementation . The mathematical implementation also covers how the linear regression is converted into logistic regression .</p><h3>Logistic Regression</h3><blockquote>Logistic Regression is an algorithm used in machine learning that works on the principle of binary classification by using the concept of regression analyses . This algorithm is used in machine learning to predict the happening of certain class or event based on its probability .</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*IlF7m3t17HQVIifPjaxIDg.png" /></figure><p>Let us consider an example of a result of students where they are classified into two classes ; Pass(P) or Fail(F) ; based on the marks they got in the exams as shown in the diagram .</p><p>Now , if we consider Pass as 1 and Fail as 0 and plot a graph of this data , let us see what we get .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*rKc_np3XAMfB73Y4h2hI4w.png" /></figure><p>The graph of our data will look like this as shown in the figure .</p><p>Now , let us try to use the Linear regression to create the best fit line on this graph using the equation — ( y = b + mx )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*B0ucB1YqpZ4fhE79KHzSog.png" /></figure><p>The best fit line “A” is the line we got from out above data . Now let us assume that two more new points (green color points) get added to our data . Now , if we will calculate the best fit line , it will change to line “B” . Let us consider the problem here .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*YCW2aM9gIAeMqXeD8MJGhg.png" /></figure><p>Now , if we consider case A and analyze the graph then —</p><p>Pass ≥ 50 &gt; Fail or we can say..</p><p>Pass = Result ≥ 0.45</p><p>But when case B occurs and we predict the 55 marks student , then the prediction line would consider it to be Fail which proves our prediction of the model wrong . Hence , we can say that our best fit linear regression line is not robust to the future data points in giving the predictions .</p><p>One more problem is that if the marks of the student are 100 , then the prediction line will give the output more than 1 and if the marks are somewhat 15 , then this prediction line will give a value less than 0 i.e negative . So how can we classify that output as our pass is 1 and fail is 0 ???</p><p>Here comes the role of the Logistic Regression Analysis which tweaks the regression line in such a way so that the output always remains between 0 and 1 as follows —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*zJzkU6rlpQZPbHb_BzG7xQ.png" /></figure><p>This line represents the sigmoid function that converts the linear regression best fit line into this kind of line that fits all the data points within the 0 and 1 .</p><p>The output of this line of prediction only gives the value between 0 and 1 which , in reality is the probability of an input to be considered in a class .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*295Nav_zlP5pljXr7bzfLA.png" /></figure><p>Now , considering that a student got 45 marks in the exam , the result predicted would be 0.5 which is greater than 0.45 and hence the student would be given the result of “Pass” .</p><p>So , this is what the logistic regression do to make predictions . It finds out the probability of an event to fall in both class and then categorize the event based on the highest probability of either class it gets . Let us now try to have a mathematical understanding of this algorithm .</p><h3>Mathematical Implementation of Logistic Regression</h3><p>Let us now understand the mathematical implementation of the classification in the regression through Logistic Regression .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*1r7m8Ru877jz6sgb6wGN4A.png" /></figure><p>Let us consider the following graphical representation of a number of data points in any space . Let us assume the “green” points as “+1” and the “red” points as “-1” . These values are the “y” or output values for these points .</p><p>Now according to linear regression , we have to create a best fit line which linearly separates all these points . The equation of this best fit line will be “y = mx + b” where “m” is the slope of the line and “b” is the y-intercept of line . Since our line passes through the origin (0,0) , hence b = 0 . So now our equation becomes “y = mx” .</p><p>Now , since the points are in some space , then to linearly separate them , we draw a plane instead of line whose equation is as given in the diagram above . The linear regression say that the best fit plane should be plotted in such a way so that the sum of distance of all the points from the plane should be minimum . Let us see how this distance can be calculated .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*ji1eO2QKK7Sa7w01CHKJDw.png" /></figure><p>So , according to the linear algebra , if the distance of any point from the plane is to be calculated then the formula is as given on the left side . In our case , b = 0 and ||w|| = 1 (let unit vector) , then our equation becomes as given .</p><p>Now , if the point lies above the plane , then the distance is always +ve and if the point lies below the plane then the distance is -ve .</p><p>Now , from the above diagram , if we consider the point “A” as green point i.e y = +1 and the point “B” as red point i.e y = -1 ; then by multiplying the distance value with the y value can easily classify the two points as follows —</p><h4>Green point A</h4><p>y = +1 , distance = +ve <strong><em>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</em></strong> ( y* distance ) = +ve value</p><h4>Red Point B</h4><p>y = -1 , distance = -ve <strong><em>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;</em></strong> ( y* distance ) = +ve value</p><p>So , this above equation will show that the points are correctly classified . Now let us see the diagram below of some wrong classified points .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*65FFE1ybdvqEMJ8x2a_bPw.png" /></figure><p>Here , if we will calculate the y*distance for point A :</p><p>y = -1 , distance = +ve</p><p>y*distance = -ve value</p><p>and if we do the same for point B :</p><p>y = +1 , distance = -ve</p><p>y*distance = -ve value .</p><p>Hence , this formula easily tells that which points are correctly classfied by the plane and which are not . So , the cost function can be written as —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*4WGze_Ez_8hZQ5ZRIU4CYg.png" /></figure><p>where “i = 1 to n” is the number of data points , “y” value is their actual output and the “wx” is their distance from the plane . The formula (y * wx) gives the validation predicted value(wx) is correct or not . In order to have a better fit plane , the summation of all these should be maximum i.e max(J) .</p><p>Now , to convert this all Linear regression cost function to the binary classification i.e to convert the “J” values into binary category between “0” and “1” , we use the Sigmoid Funtion which is called as follows —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/1*hbX2eA0txNkEmNnxTFKDgQ.png" /></figure><p>This can also be explained with the metric of classification called Confusion Matrix .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*Tab5gRXQDvQrzu9NUT9Ikw.png" /></figure><p>Here ,</p><p>TP (True Positive) : The prediction (1 = +ve = wx) is correct(True) according to real value (1 = +1 = y) .</p><p>TN (True Negative) : The prediction (0 = -ve = wx) is correct(True) according to real value(0 = -1 = y) .</p><p>FP(False Positive) : The prediction (0 = -ve = wx) is wrong(False) according to real value (1 = +1 = y)</p><p>FN(False Negative) : The prediction (1 = +ve = wx) is wrong(False) according to real value (1 = -1 = y) .</p><p>The best model of Logistic Regression should have maximum correctly classified (TP + TN) values and minimum wrongly classified (FP + FN) values among all the outputs . The accuracy can be measured as follows —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*R3rQSLIJH2nZPSqhRkTjJw.png" /></figure><blockquote>That is all about this blog on the mathematical implementation of Logistic Regression . Hope it was an informative one . Thank you for reading .</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67120e8bbc14" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml-with-arpit-pathak/introduction-to-logistic-regression-and-its-mathematical-implementation-67120e8bbc14">Introduction to Logistic Regression and its Mathematical Implementation</a> was originally published in <a href="https://medium.com/ml-with-arpit-pathak">ML_with_Arpit_Pathak</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Support Vector Regression]]></title>
            <link>https://medium.com/ml-with-arpit-pathak/support-vector-regression-8de47f3bf4c7?source=rss-e88079b64752------2</link>
            <guid isPermaLink="false">https://medium.com/p/8de47f3bf4c7</guid>
            <category><![CDATA[vr]]></category>
            <category><![CDATA[internity]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[svm]]></category>
            <dc:creator><![CDATA[RADIO SAYS Arpit pathak]]></dc:creator>
            <pubDate>Mon, 08 Jun 2020 06:08:50 GMT</pubDate>
            <atom:updated>2020-06-18T04:46:03.098Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello readers , this blog explains one more algorithm in Machine Learning , SVR . Here we will first understand the superset algorithm principle of Support Vector Machine and then move to Support Vector Regression that works on the same principle .</p><h3>Support Vector Machine ( SVM )</h3><blockquote>SVM is a type of Supervised Machine Learning algorithm that works by analyzing the data and representing the outputs as points in a space that are clearly mapped by dividing them into two separate categories . This algorithm is used either in classification or regression analysis . In classification , it is called <strong>Support Vector Classifier (SVC)</strong> and in regression , it is called <strong>Support Vector Regression (SVR)</strong> .</blockquote><p>There are some terms associated to this algorithm . These terms can easily explain the working of this algorithm . Let us see what these terms are —</p><ol><li><strong><em>Hyperplane</em></strong></li></ol><blockquote>A hyperplane is a geometrical subspace in any dimensional combination where the dimension of the Hyperplane is one less than the original dimensions of the space in which it lies . For example , in a @-dimensional pace , the hyperplane is a 1-dimensional line .</blockquote><blockquote>In machine learning , a hyperplane is a decision boundary that strictly divides two categories from each other .</blockquote><p>Let us try to understand it with a simple diagram —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*zxuQAXnmWzArfROcNVX2UQ.png" /><figcaption>Hyperplane</figcaption></figure><p>SVM always creates a hyperplane between two categories in order to separate them strictly from each other .</p><p>2. <strong>Support Vectors</strong></p><blockquote>As the name suggests , Support vectors are the supporting data points in any space of classification that decide the orientation and position of the hyperplane . These are the most important part of the working of the SVM algorithm as they help in configuring the hyperplane over the categories .</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*CR52Aq_Ck4kX3Px0EKIQEw.png" /></figure><p>In this diagram , the support vectors are drawn by creating the parallel line to the hyperplane from the closest points of the two categories . These two point are basically known as support vectors and the parallel line to the hyperplane are known as support vector lines .</p><p>3. <strong>Marginal Distance</strong></p><blockquote>Marginal distance is the total perpendicular distance between the two support vector lines on either side of the hyperplane .</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*pLgoolbaf3PUMipo9L8t0w.png" /></figure><p>In the figure , you can see that the marginal distance is the distance between the support vectors line . In other words , we can say that the marginal distance is the maximum perpendicular distance between the closest data point of the 2 categories from each other .</p><h4>The SVM algorithm works by creating a hyperplane is such a way so that the support vectors have a maximum marginal distance between them . Let us see the below image to understand this concept —</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hPAMb6wqJcUl1RqpIFz-Rw.png" /><figcaption>Working of SVM</figcaption></figure><h3>SVM Kernal Trick</h3><p>All the above example images that we saw are based on the data that is easily separable i.e a linear separating line can be drawn between them . This type of data is known as <em>Linearly Separable</em> data . However , most of the real world cases deal with the data that are not easily separable . These data are known as <em>Non-Linear separable</em> data . This means that we cannot create a linear line to separate this kind of data . Let us take an example from a simple diagram of non- linear separable data —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*wNG-m-rhnPUJWtaiMJLibQ.png" /></figure><p>This figure gives an example of non-linear separable data . If we try to draw a linear line for this data , then we will get an accuracy of 50% or less in our model . In order to solve this kind of data problem , the SVM kernal has a trick by which it adds one more dimension to the data so that the hyperplane can be created over the data in that space . Let us see how this happens —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bTdP0vyIb5tXRkM2OW7YPQ.png" /><figcaption>Kernal Trick of SVM</figcaption></figure><blockquote>In the above examples , if we consider green points as positive and blue points as negative then we can get the perfect intuition of working of SVM as follows —</blockquote><blockquote>The SVM algorithm tries to create a hyperplane that has the highest marginal distance between the support vectors and all the data points lie outside this marginal boudary in sucha way that the negative points are on the negative side and the positive points are on the positive side .</blockquote><p>Now , let us jump to the topic of this blog i.e SVR —</p><h3>Support Vector Regression (SVR)</h3><blockquote>SVR is a sub-algorithm of SVM that is dedicated to the regression based algorithm . It works on the same principle of creating a hyperplane just like the SVM . However , the aim of creating a hyperplane in this algorithm is in such a way that most of the data point lie on the hyperplane and rest lie inside the support vectors viz. decision boundaries .</blockquote><p>Le us understand this concept through a simple diagram of regression analysis —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*nVxPDjxRvKtPlKEFGCTDyA.png" /></figure><p>As you can see in the diagram , there are some data points over which a hyperplane is created in such a way that most of the points lie on it and all the remaining points lie inside the support vector lines . This marginal distance is known as the valid margin and the support vectors are known as the decision boundaries .</p><h3>Mathematical Implementation Of SVR</h3><p>Let us consider from the above example where the equation of the hyperplane is —</p><p>— — — — — — — — — — — <strong>y = wx + b</strong> — — — — — — — — — — — —</p><p>Let each of the decision boundaries are at “p” distance from the hyperplane . So , the vector distance of each hyperplane is “-p” and “+p” from the hyperplane . So , the equation of both the line can be said as —</p><p><strong>— — — — — — — — ( p = wx + b ) &amp; ( -p = wx + b ) — — — — — — —</strong></p><p>Hence , the hyperplane should always be in such a way that —</p><p><strong>— — — — — — — — — —( p &gt; y -wx + b &gt; -p ) — — — — — — — — — —</strong></p><p>This hyperplane must have the least error rate i.e the deviation of points from the hyperplane should be minimum .</p><blockquote>That is all about this blog . Hope it was an informative one . Thank you for reading…!!!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8de47f3bf4c7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml-with-arpit-pathak/support-vector-regression-8de47f3bf4c7">Support Vector Regression</a> was originally published in <a href="https://medium.com/ml-with-arpit-pathak">ML_with_Arpit_Pathak</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decision Tree Regression and its Mathematical Implementation]]></title>
            <link>https://medium.com/ml-with-arpit-pathak/decision-tree-regression-and-its-mathematical-implementation-a2ffedec5aca?source=rss-e88079b64752------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2ffedec5aca</guid>
            <category><![CDATA[internity]]></category>
            <category><![CDATA[decision-tree]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[internity-foundation]]></category>
            <dc:creator><![CDATA[RADIO SAYS Arpit pathak]]></dc:creator>
            <pubDate>Thu, 04 Jun 2020 06:41:19 GMT</pubDate>
            <atom:updated>2020-07-07T20:10:17.797Z</atom:updated>
            <content:encoded><![CDATA[<h3>Decision Tree Regression and its Mathematical Concept</h3><p><strong>Hello readers , so here we are to understand how the decision tree algorithm woks in the regression based problems and what mathematical implementation is done in order to do prediction on continuous values . But before going through this blog , refer to the below link to understand what is a decision tree and how it works .</strong></p><p><a href="https://medium.com/ml-with-arpit-pathak/decision-tree-and-its-mathematical-concept-53f80adc646d">Decision Tree and Its Mathematical Concept</a></p><h3>Decision Tree Regression</h3><blockquote>Decision Tree regression is a concept that implements the Decision Tree Algorithm over continuous data in order to do future predictions . This type of regression analysis is done on the data that is non-linear separable i.e a straight regression line cannot be implemented in order to do predictions .</blockquote><p>The internal concept of Decision Tree Regression is exactly similar to the Classification concept i.e the model keeps on grouping the data on the basis of particular features through a hierarchy of a tree structure . Now, since the regression problem doesn’t holds the categorical values , the decision tree works by grouping the data into continuous groups up to a particular limit .</p><p>For example , let us take an example of a dataset of the Salary of Employees in the company based on their experience and bonus percentage . Now, let us see how decision tree works in this problem of getting the salaries .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VhMErrnrkLGw3CHWRhWAOg.png" /></figure><p>In the above diagram , at the level zero , the feature of division is taken as experience . Since , the feature is a continuous value (experience can be 0,0.2….3.5,3.6….6.1,6.9…) therefore the tree automatically divides the data into three parts or three ranges . At the level 1 , the division feature is Bonus % which is a continuous value too . So the decision tree divides it into 2 ranges and gets trained .</p><p>Now , whenever the new data will come up to predict the salary of the employee , the average of all the values in the leaf node is taken as the final output or prediction . This is the working of Decision tree regression .</p><h3>Mathematical Concept</h3><p>Now , you might be thinking that how the decision tree knows which feature to use as a division feature at a level . Just like gini impurity or information gain is used in the classification problems , the Decision Tree Regression uses the mathematical concept called <strong>Reduction In the Variance</strong> .</p><blockquote><strong><em>Reduction in Variance = Variance(T,X) -Variance(T)</em></strong></blockquote><p>Here Variance(T) refers to the variance of the values in parent node and Variance(T,X) refers to the variance of the values in the child nodes .</p><p>For a feature to be selected to be the division feature at a particular level , the Reduction in Variance should be highest .</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><blockquote>That is all about this blog. Hope it was an informative one for you !!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2ffedec5aca" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml-with-arpit-pathak/decision-tree-regression-and-its-mathematical-implementation-a2ffedec5aca">Decision Tree Regression and its Mathematical Implementation</a> was originally published in <a href="https://medium.com/ml-with-arpit-pathak">ML_with_Arpit_Pathak</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linear Regression : Concept and Working]]></title>
            <link>https://medium.com/ml-with-arpit-pathak/linear-regression-concept-and-working-d4a5116b3e81?source=rss-e88079b64752------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4a5116b3e81</guid>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[internity-foundation]]></category>
            <dc:creator><![CDATA[RADIO SAYS Arpit pathak]]></dc:creator>
            <pubDate>Tue, 02 Jun 2020 19:53:36 GMT</pubDate>
            <atom:updated>2020-06-02T21:49:43.849Z</atom:updated>
            <content:encoded><![CDATA[<h3>Linear Regression : Concept and Working</h3><p>Hello readers , so here the core journey into the machine learning world is going to start . In this blog , we will try to understand the core concept of machine learning , the regression analysis and the working of Linear Regression algorithm in Machine learning .</p><h3>Core Concept of ML</h3><p>We all have a basic idea that a machine learning model is trained on some previous data and its outputs to predict over some future inputs of similar type of data . But how do the machine learning model get trained on the data ? How do it realize that the given data have that output which we have provided it to train ? Here comes the core behind all these questions .</p><p>The core concept of machine learning is to find out the <strong><em>bias</em></strong> and the <strong><em>weight . </em></strong>What the machine learning model do is that it takes the input values in which the data and its output is given , and find out the correlation between the input and the output values . The data over which we train the machine learning model contains the independent variables (X) and one output variable(y) . The machine learning model finds out how the X is correlated to y or how much the X affects the y . This is known as the <strong><em>weight</em></strong> i.e. , the correlation of X with the y . However , it is not at all possible that X will be 100% correlated with y . This is known as the <strong><em>bias </em></strong>i.e. , the value of the y when the weight or the correlation of X with y is zero .</p><p>Next thing is about the accuracy of the machine learning model . There is no real life-real data based model of machine learning in the whole world that can claim to have 100% accuracy . There are always flaws in the model , it can be precise but cannot be fully accurate . These flaws or errors in the model are known as the <strong><em>residuals</em></strong> or <strong><em>loss</em></strong> . The goal to a machine learning programmer is to attain a model that has minimum loss and maximum accuracy .</p><h3><strong>Regression Analysis</strong></h3><blockquote>Regression analysis is a process to find out the relationship between the independent variable(s) and the dependent variable. It also helps to figure out the overall impact of the independent variable on the dependent variable</blockquote><p><em>Let us take a simple example of a company with some employees . In that company , let the salaries of the employees are decided on the basis of their experience . So, in this case , the “experience” is an independent variable and the “salary” is a dependent variable . Hence , if we want to predict the salary of an employee in the future , we first have to find out the correlation weight and the bias of the experience on the salary . We have to find out how much impact the change in experience have on the salary of the employee .</em></p><p>There are many techniques used for regression analysis but all of them depend on the three basic metrics —</p><ol><li>Number of Independent variables (one or more than one )</li><li>Shape of regression line (linear or curved)</li><li>Type of dependent variable (continuous or categorical)</li></ol><p>Let us now see the first approach to train the machine learning model by using the linear regression .</p><h3>Linear Regression</h3><blockquote>Linear regression is a type of approach that works by establishing a relationship between the independent variable(s) and the dependent variable by finding the best fit regression line .</blockquote><h4>Core Formula</h4><p>The core formula that works in linear regression is —</p><blockquote>— — — — — : y = b + wx : — — — — —</blockquote><p>Here , ‘y’ is the dependent variable and ‘x’ is the dependent variable . This is a simple equation of a line that we have studied in statistics . If we plot a graph of this kind of equation then the graph comes up to be —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*eDJGSB1Pt2weubOK2baiqw.png" /></figure><p>This figure explains the equation of y=b+wx . Here , w represents the coefficient , imact or the relation of changing values of x on y and b represents the value of y when there is no impact of the x on y .</p><p><em>The need of b can be explained by the above example of salaries(y) of employees on the basis of their experience(X) . If there is a freshers in the company with zero experience (X=0) , then if there will be the equation y=wx , then the salary given to that employee will be zero . But this is not at all reality , a fresher employee is also given a salary and hence that salary becomes the bias (b) in the equation .</em></p><p>Now , when we have understood the base equation used , let us break in to the core concept of linear regression .</p><h4>Core Concept</h4><p>The core concept of linear regression comes up with the type of dependent variable and the shape of the line we get in it . In linear regression , the dependent variable is always a continuous value and the shape of the regression line is always a straight line . Now let us see how the regression line is calculated .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*t98tbjHz5v57xioD.jpg" /><figcaption>Linear Regression (source :<a href="https://i.ytimg.com/vi/zPG4NjIkCjc/maxresdefault.jpg">here</a>)</figcaption></figure><p>In the above figure , we can see the points are plotted on the graph and a regression line is drawn . A regression line connects all the data points on a graph plot . But in the above figure , not every point falls on the regression line . The distance of each point from the regression line is known as the residual or loss or error .</p><p>The plotting of the regression line is a hit and trial method . First we create a regression line and try to connect as many points as possible . Then we calculate the loss or the error in the plotting by calculating sum of the absolute distance of each point from the regression line . This process continues till the least error is obtained and the perfect regression line is plotted .</p><p>To calculate the error in the regression line , we have three methods —</p><ol><li><strong>Mean Absolute Error ( MAE )</strong> : The MAE method calculates the absolute difference of each value of y in the data with the mean of all those values, sum them up and divide them with the total number of values to find out the average or mean absolute error in the data .</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*AQw1CoLnVt0UtwUeBMtgQQ.png" /></figure><p>2 . <strong>Mean Squared Error (MSE) : </strong>The MSE method calculates the square of difference of each value of y in the data from the mean of the data , sum them up and then divides them bythe total number of values to get the mean or the average error in the data .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*g7mZAWmlcPGDUT99aU2i0A.png" /></figure><p>3. <strong>Root Mean Squared Error (RMSE) : </strong>The RMSE method is similar to the MSE method except the final step in which root of MSE is calculated .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*A1cr17zC915lKWlXf235Hg.png" /></figure><p>In most of the cases , MSE works better than the MAE in giving better predictions .</p><h4>Types of Linear Regression</h4><p>Based on the number of independent variables (X) , linear regression can be classified into 2 types —</p><ul><li><strong>Simple Linear Regression</strong> : Consists of only one independent variable (X).</li></ul><blockquote>y = b + wx</blockquote><ul><li><strong>Multiple Linear Regression : </strong>Consists of more than one independent variables .</li></ul><blockquote>y = b + w1*x1 + w2*x2 + w3*x3 + …</blockquote><p>GITHUB LINK TO THE PRACTICAL IMPLEMENTATION EXAMPLE :</p><p><a href="https://github.com/InternityFoundation/MachineLearning_Arpit114/tree/master/Task%20%207">CLICK HERE</a></p><p><em>So this is all about the theoretical concept of linear regression .Hope it was an informative one for you . Thank you for reading…!!!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4a5116b3e81" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml-with-arpit-pathak/linear-regression-concept-and-working-d4a5116b3e81">Linear Regression : Concept and Working</a> was originally published in <a href="https://medium.com/ml-with-arpit-pathak">ML_with_Arpit_Pathak</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Visualization using Matplotlib and Seaborn in Python]]></title>
            <link>https://medium.com/ml-with-arpit-pathak/data-visualization-using-matplotlib-and-seaborn-in-python-62fd64a57936?source=rss-e88079b64752------2</link>
            <guid isPermaLink="false">https://medium.com/p/62fd64a57936</guid>
            <category><![CDATA[seaborn]]></category>
            <category><![CDATA[internity-foundation]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[matplotlib]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[RADIO SAYS Arpit pathak]]></dc:creator>
            <pubDate>Tue, 02 Jun 2020 06:35:49 GMT</pubDate>
            <atom:updated>2020-06-02T06:44:00.687Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Hello readers , this blog explains about the basics of visualization of the data , type of graphs and the practical implementation of visualization by using python libraries like <em>matplotlib</em> and <em>seaborn</em> .</strong></p><h3>Data Visualization</h3><blockquote><strong>Data visualization refers to the presentation of the data in the form of graphs to get better insights of the data and analyze the data in an smarter way .</strong></blockquote><p>It is well known and proven that the visual presentation of anything makes it possible to grab much more of it than reading it or listening it . Similarly , in the case of data , when we visualize and study it , we can have much better insights of it . Visualization of data makes it easier to understand that “what is it saying” or “what is the purpose of the data”. In order to study the data by visualization , w use graphs .</p><h3>Graphs</h3><blockquote>A graph is a visualization tool for representing the data in a visual way that represents this data in the form of information by presenting it in the form of a series of co-ordinates on a multi-dimensional axis .</blockquote><p>Let us see some basic graphs that can be used to visualize the data —</p><ol><li><strong>Line Graph</strong></li></ol><blockquote>Line graph . also known as the line chart is the representation of a series of points connected with each other . This type of graphs are used to visualize the changes in the value of something over time or any other type of constraint .</blockquote><p>For example —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*2AtIJTt9CYDWv2TgrIYQdA.png" /><figcaption><strong>Line graph(source: </strong><a href="https://www.rethinkmathteacher.com/wp-content/uploads/2018/05/stock-market-project-line-graph.png"><strong>here</strong></a><strong>)</strong></figcaption></figure><p><em>The figure here shows the change in the stock price of a company during seven days . The line is drawn by connecting the co-ordinates (day , price) with each other to from a line graph .</em></p><p>2. <strong>Bar Graph</strong></p><blockquote>A bar graph is the presentation of any type of categorical data in the form of rectangular bars where the height of each bar depends on the frequency/total count of that particular category in the data .</blockquote><p>For example —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*upMojKxjqHoJ6VXr.jpg" /><figcaption>Bar graph (source: <a href="https://qethird.weebly.com/uploads/8/2/3/5/82358664/bar-graph_orig.jpg">here</a>)</figcaption></figure><p><em>The figure here shows the bar plot of a the kinds pets owned by the people at a certain place . We can see that cats are the mostly owned pets and rabbits are the least owned pets .</em></p><p>3.<strong> Histogram</strong></p><blockquote>A histogram is the presentation of the frequency of data that falls under a certain range of category . This type of graph takes the continuous valued data , groups it into a number of ranges(bins) and then represents the frequency of the data that falls in that particular bin .</blockquote><p>For example —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2Yef4CovwNVwr0-b.png" /><figcaption>Histogram(source : <a href="https://online.stat.psu.edu/stat500/sites/stat500/files/inline-images/500%20l1%20histogram%20.png">here</a>)</figcaption></figure><p><em>The figure here is a histogram of the continuous data of weights which are divided into 9 bins (131–133 , 133–135,135–137,…and so on till 149) and the number of weights that fall in a particular bin is represented by the height id that bin .</em></p><p>4.<strong> Scatter Graph</strong></p><blockquote>A scatter plot is the presentation of the data points on multidimensional axis . It is a simple graph that represents each and every token of data as a co-ordinate point on the graph .</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*Kwg1W79RH-Rixk1l.png" /><figcaption>Scatter graph (source: <a href="https://www.w3schools.com/python/img_scatterplot.png">here</a>)</figcaption></figure><p>The figure here shows the scatter graph representing the data points as a co-ordinate on a 2-dimensional space (x-axis,y-axis) .</p><p>5. <strong>Heatmap</strong></p><blockquote>A heatmap is the representation of the frequency/density of the data visually by the use of some colour codings in 2-demensional space . The density of the data is presented in the form of intensity of the colur in the area on the graph .</blockquote><p>For example —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/0*kMDyW2KFw2bEbRua.png" /><figcaption>Heatmap (source :<a href="https://seaborn.pydata.org/_images/seaborn-heatmap-7.png">here</a>)</figcaption></figure><p><em>The figure here shows a heatmap of certain data plotted against the months and the years . We can see that the intensity of colour in the moth of July in 1960 is maximum and hence the frequency of data in that period is most .</em></p><p>6. <strong>Boxplot</strong></p><p>A boxplot is the representation of the summary of data in which the distribution of the data over its whole frequency of values can be determined. It is the most standard way to analyze the outliers (odd) values in the data . The box plot displays the data as a distribution in the form of five occurances i.e ‘minimum’ , ‘first quartile’(Q1) , ‘median’ , ‘third quartile’(Q3) and ‘maximum’ . The area between Q1-Q3 is known as the Inter-Quartile range (IQR) that contains 50% of the overall data .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Btwj35u3m5UL6dGV.png" /><figcaption>Boxplot (source: <a href="https://miro.medium.com/max/18000/1*2c21SkzJMf3frPXPAR_gZA.png">here</a>)</figcaption></figure><blockquote>Let us now see how we can plot these graphs using Matplotlib and Seborn in Python…</blockquote><h3>Matplotlib</h3><blockquote>Matplotlib is a python library that is used to represent or visualize the graphs on 2-dimensional axis (Note : we can also plot 3-D graphs using matplot3d ) . This library can be used to create static and interactive graphs in python . This is the most basic and simple library used to visualize the data in python . This library has its numerical extension with another library in python called ‘numpy’ .</blockquote><p>Now we will use matplotlib to create graphs over the data we have on the Jupyter notebook of Anaconda that comes pre-installed with matplotlib .</p><p>First Import the matplotlib plotting library to plot the data —</p><blockquote><strong><em>import matplotlib.pyplot as plt</em></strong></blockquote><p>Let us now see some graphs created using Matplotlib —</p><ul><li>Line Graph</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*zS4L2-joRCT27tINRcZ6gg.png" /></figure><ul><li>Bar Graph</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*Bz6JyV8sW0Je3ouaSFYBsg.png" /></figure><ul><li>Histogram</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*AKWK54Z7FSTAbwhHsC03ag.png" /></figure><ul><li>Scatter Graph</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*acSfVsRLIEq7onaqRhleAA.png" /></figure><h3>Seaborn</h3><blockquote>Seaborn is a graphic library built on the top of matplotlib . It offers some more better tools and ways in which we can visualize our data in order to have a better insight of it . It offers color mapping and faceting of the data .</blockquote><p>First import the seaborn library —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*xL4ExWnQPBOy_sJapDjC2g.png" /></figure><ul><li>Heatmap</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*uUQ_K4q8TR-zX4Lvtnz3Qg.png" /></figure><ul><li>BoxPlot</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*wcIpHPGGPPXNzdCa-4YqUA.png" /></figure><blockquote>That’s all about graphs in this blog . Hope it was an informative one . Thank you for reading…!!!</blockquote><p>Github link for your reference :<a href="https://github.com/InternityFoundation/MachineLearning_Arpit114/tree/master/Task%205%20Data%20Visualisation"> here</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62fd64a57936" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml-with-arpit-pathak/data-visualization-using-matplotlib-and-seaborn-in-python-62fd64a57936">Data Visualization using Matplotlib and Seaborn in Python</a> was originally published in <a href="https://medium.com/ml-with-arpit-pathak">ML_with_Arpit_Pathak</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Preprocessing : COVID-19 Dataset Practical Implementation]]></title>
            <link>https://medium.com/ml-with-arpit-pathak/data-preprocessing-covid-19-dataset-practical-implementation-71f038fed69b?source=rss-e88079b64752------2</link>
            <guid isPermaLink="false">https://medium.com/p/71f038fed69b</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[internity-foundation]]></category>
            <category><![CDATA[internity]]></category>
            <category><![CDATA[technolgy]]></category>
            <dc:creator><![CDATA[RADIO SAYS Arpit pathak]]></dc:creator>
            <pubDate>Sun, 31 May 2020 13:49:40 GMT</pubDate>
            <atom:updated>2020-06-01T06:59:50.447Z</atom:updated>
            <content:encoded><![CDATA[<h3>Data Preprocessing : COVID-19 Dataset Practical Implementation</h3><p>Hello readers , this blog is a practical implementation of data preprocessing on a dataset using python . If you haven’t gone through the previous blog about Data Preprocessing the go through it first .</p><p><a href="https://medium.com/@arpitpathak114/data-preprocessing-with-numpy-and-pandas-5598ef69491e">Data Preprocessing with Numpy and Pandas</a></p><p><em>There are 7 key steps to perform Data Preprocessing on any type of dataset which i am going to explain with an example of COVID-19 dataset as follows —</em></p><h3>1. Acquire the Dataset</h3><p>The first step to Data Preprocessing is to get the dataset about which you want to create the dataset . Here i want to create a machine learning model to predict the risk of getting suffered from the COVID-19 for a person . So , i need to collect the factors over which i can train my model to predict the risk .</p><p>COVID-19 can be predicted in a person by analyzing the symptoms , travel history to hotspot places , age and gender .</p><p>For this i have collected a dataset which contains the previous information about the people on whom the survey was carried out by asking them some questions about their age , gender , symptoms and travel history to infected places and then they were tested for being suffered or not . Here , my first step is completed .</p><h3>2. Import all crucial Libraries</h3><p>Now , the main practical task begins . We start our python IDE for carrying out the Data preprocessing task . For this , i am using Jupyter Notebook of Anaconda . Let us first import all the required libraries —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YWeqIfGj02Ao7DAt9k8aJA.png" /></figure><blockquote><strong><em>import numpy as np<br>import pandas as pd<br>from sklearn.preprocessing import LabelEncoder<br>from sklearn.preprocessing import StandardScaler<br>from sklearn.model_selection import train_test_split</em></strong></blockquote><h3>3. Import the Dataset</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QM02yIsfWq2EuC_LFfpekw.png" /></figure><blockquote><strong><em>df = pd.read_csv( “COVID19.csv” )</em></strong></blockquote><h3>4. Identify and Handle Missing Values</h3><p>Let us identify if our dataset contains any missing values or not . See the information of each column of dataset for any missing number of values . If the number of rows of dataset is not equal to the non-null count of a column , there are missing values in that columns .</p><blockquote><strong><em>df.info()</em></strong></blockquote><blockquote><strong>or</strong></blockquote><blockquote><strong><em>df.isnull().sum()</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-U-wqmgMY3RXRnGDZiZrMw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*3lvFIIVjhjYHP10gTR_O1Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*3lvFIIVjhjYHP10gTR_O1Q.png" /></figure><p>Ways to handle the null values are as follows —</p><h4>+ Remove Null Values</h4><blockquote><strong>df.isnull().sum()</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Jdff7COQG4sJvM8b8IdUg.png" /></figure><h4>+ Replace Null Values</h4><p>Removing the records having null values is a loss of information from the data . Therefore , the best way is to replace the null values with the central tendency(mean / median / mode) of the column in which they are present .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dg8xUuhTXPJfyRSgIXPxpw.png" /></figure><h3>5. Encoding the Data</h3><p>Encoding the data refers to converting the data into a form that is understandable by the machine which includes converting categorical data into numerical data . Other encoding we can do is the grouping of the continuous values of a variable into certain bins of ranges and then convert them into categories to numerical data . Let us see how we can achieve it —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IeKwyTDkoTzuk7qAXOo-Vw.png" /></figure><p>In the above figure , we can see —</p><p>(a) gender : It is a binary categorical dataset with values “Male” and “Female” . We can covert this column into numerical data using Label Encoder as follows —</p><blockquote><strong><em>le = LabelEncoder()<br>df[“gender”] = le.fit_transform( df[“gender”] )</em></strong></blockquote><blockquote># ‘Female’ : 0 , ‘Male’ : 1 ….Alphabetically label encoded .</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*PRaHyzFmAQxrQMjZOTGYaA.png" /></figure><p>(b) Corona result : This is our output column having 3 values viz. “No risk” , “Less Risk” , “High Risk” . We convert this column into numerical valued by using LabelEncoder .</p><blockquote><strong><em>le = LabelEncoder()<br>df[“Corona result”] = le.fit_transform( df[“Corona result”] )</em></strong></blockquote><blockquote>‘High Risk’ : 0 , ‘Less Risk’ : 1 , ‘No Risk’ : 2</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NDxU_9bbHxtbm0I4wcBumg.png" /></figure><p>(c) age and body temperature : These 2 are the continuous values . So , we first group them into the bins or categorical data and then we will use one-hot encoding over them . Let us see how —</p><blockquote><strong><em>bins= [0,10,20,30,40,50,60,70,80,100]</em></strong><em> </em>#initialising bins for age column<br><strong><em>labels = [‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’,’i’]</em> </strong>#initialising labels for bins<br>#creating a column that groups all age values into or initialised bins<br><strong><em>Age = pd.cut(df[‘age’], bins=bins, labels=labels, right=False) </em></strong><br>#creating a column in dataset for our binned column of Age<br><strong><em>df[“Age”]=Age</em></strong><br>#removing previous column of age<br><strong><em>df=df.drop([‘age’],axis=1)</em></strong></blockquote><blockquote>#doing the same for body temperature<br><strong><em>bins= [96,98.6,102,110]<br>labels = [‘normal’,’fever’,’high fever’]<br>Temperature = pd.cut(df[‘body temperature’], bins=bins, labels=labels, right=False)<br>df[“Temperature”]=Temperature<br>df=df.drop([‘body temperature’],axis=1)</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8MeILiujALDKIEaSu2GpMw.png" /></figure><p>Now , using one hot encoding through pandas dummies for converting them to numerical values —</p><blockquote># Applying one-hot encoding using pandas dummies .</blockquote><blockquote><strong><em>df=pd.concat([df,pd.get_dummies(df[‘Age’],drop_first=True)],axis=1)<br>df = df.drop ([‘Age’],axis=1)</em></strong></blockquote><blockquote><strong><em>df=pd.concat([df,pd.get_dummies(df[‘Temperature’],drop_first=True)],axis=1)<br>df = df.drop ([‘Temperature’],axis=1)<br>df.head()</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8h6s9jM7jhPV6Ra8xfkYmA.png" /></figure><p>Now , all the wrangling or cleaning of data is completed so that we can move to next step .</p><h3>6. Splitting the Dataset into Train and Test Data</h3><p>Now , the time comes to split the dataset into training data and the testing data . But first we need to split the dataset into X (independent inputs) and y (dependent outputs ) .</p><blockquote>In our dataset of columns —</blockquote><blockquote>[‘Sno’, ‘gender’, ‘Dry Cough’, ‘sour throat’, ‘weakness’,<br> ‘breathing problem’, ‘drowsiness’, ‘pain in chest’,<br> ‘travel history to infected countries’, ‘diabetes’, ‘heart disease’,<br> ‘lung disease’, ‘stroke or reduced immunity’, ‘symptoms progressed’,<br> ‘high blood pressue’, ‘kidney disease’, ‘change in appetide’,<br> ‘Loss of sense of smell’, ‘Corona result’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’,<br> ‘h’, ‘i’, ‘fever’, ‘high fever’]</blockquote><blockquote><strong>X = [‘gender’, ‘Dry Cough’, ‘sour throat’, ‘weakness’,<br> ‘breathing problem’, ‘drowsiness’, ‘pain in chest’,<br> ‘travel history to infected countries’, ‘diabetes’, ‘heart disease’,<br> ‘lung disease’, ‘stroke or reduced immunity’, ‘symptoms progressed’,<br> ‘high blood pressue’, ‘kidney disease’, ‘change in appetide’,<br> ‘Loss of sense of smell’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’,<br> ‘h’, ‘i’, ‘fever’, ‘high fever’]</strong></blockquote><blockquote><strong>y = [‘Corona result’]</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i_3j-zAjHeA71WyW32KfuQ.png" /></figure><blockquote><strong><em>X = df.drop([‘Corona result’ , ‘Sno’] , axis = 1)<br>y = df[‘Corona result’]</em></strong></blockquote><p>Now , the data needs to be divided into train and test data —</p><blockquote><strong><em>X_train , X_test , y_train , y_test = train_test_split(X , y , random_state = 2 , test_size = 0.20)</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LFzn8yTNwoEnEiGvLJnX2w.png" /></figure><h3>7. Scaling of Training Data</h3><p>Here comes the last step of data preprocessing where we finally do the scaling of the input data so that the model takes every input without being bias towards one of them .</p><blockquote><strong><em>ss = StandardScaler()<br>train = ss.fit_transform(X_train)</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o8IP2rgD4rDSHADIjuNHIw.png" /></figure><p><strong><em>For reference , got to link to my</em></strong></p><p><strong><em>Github Repository — —</em></strong><a href="https://github.com/InternityFoundation/MachineLearning_Arpit114/tree/master/Task%204%20Data%20Preprocessing"><strong><em> click here</em></strong></a></p><blockquote>So , this was all about practical implementation of the Data Preprocessing on the Covid-19 dataset . Hope it was an informative blog for you . Thank you..!!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71f038fed69b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml-with-arpit-pathak/data-preprocessing-covid-19-dataset-practical-implementation-71f038fed69b">Data Preprocessing : COVID-19 Dataset Practical Implementation</a> was originally published in <a href="https://medium.com/ml-with-arpit-pathak">ML_with_Arpit_Pathak</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>