<?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 Vikrant Jain on Medium]]></title>
        <description><![CDATA[Stories by Vikrant Jain on Medium]]></description>
        <link>https://medium.com/@inivikrant?source=rss-a527245f1326------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JcyCns1PCeAEUA395N_2pg.jpeg</url>
            <title>Stories by Vikrant Jain on Medium</title>
            <link>https://medium.com/@inivikrant?source=rss-a527245f1326------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 20:00:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@inivikrant/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[Logistic Regression a classification problem]]></title>
            <link>https://medium.com/@inivikrant/logistics-regression-a-classification-problem-7ff0b45b5b89?source=rss-a527245f1326------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ff0b45b5b89</guid>
            <category><![CDATA[logistics-regression]]></category>
            <category><![CDATA[decision-boundary]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[classification-problem]]></category>
            <category><![CDATA[sigmoid]]></category>
            <dc:creator><![CDATA[Vikrant Jain]]></dc:creator>
            <pubDate>Mon, 04 Jun 2018 04:06:01 GMT</pubDate>
            <atom:updated>2018-06-04T04:32:55.768Z</atom:updated>
            <content:encoded><![CDATA[<p>The name Logistic Regression itself confuses us that it is a regression problem, however it is not, it is actually a classification problem. Due to some historical reasons it was named as Logistic Regression.</p><p>In a classification problem target variable ‘Y’ which we are going to predict is discrete in nature.</p><p>This blog will answer below questions:</p><p>What is the difference between discrete and continuous?</p><p>What is the difference between two class (Binary classification) and multi classification problem?</p><p>What is Logistic Regression?</p><p><strong>Here are some examples of classification problem (Discrete):</strong></p><p>1. Whether the Email is Spam / Not Spam?</p><p>2. Whether the Online transaction is : Fraudulent (Yes/ No)</p><p>3. Whether the Tumor is Malignant/ Benign?</p><p>4. Whether it is going to rain tomorrow : (Yes / No)</p><p><strong>Below are some examples of regression problem (Continous):</strong></p><p>1. What amount of rainfall will be in the month of June?</p><p>2. Predicting House price in a particular area?</p><p>3. What will be the mean temperature for the month of May?</p><p>In all of these classification problem (Discrete). We can say that target variable ‘Y’ is taking two values ‘0’ or ‘1’.</p><p>Y €- {0, 1} 0: ‘Negative Class’ (e.g. benign tumor)</p><p>1: ‘Positive Class’ (e.g. malignant tumor)</p><p>For now in this blog we will be discussing about classification problem with just two classes (Binary classification) Y €- {0, 1}, there is also a multiclassification problem where the variable ‘Y’ takes on 4 values Y €- {0, 1, 2, 3}. However in this blog we will be talking about Binary classification.</p><p>Suppose we have a data on tumor -classified as ‘0’ -benign tumor, ‘1’-malignant tumor</p><p>Since this a classification problem we will have only two predictions either “0” or “1”.</p><p>Can we fit a linear regression on this data — yes we can fit see below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*kWtDb-CayxE8AiYqYgN8vw.png" /></figure><p>After fitting a linear regression line we can set a threshold as 0.5 and plot a decision boundary.And we can say points which <strong>lie</strong> towards right hand side of decision boundary belongs to positive class (i.e. 1) and point’s which <strong>lie</strong> towards left hand side of a decision boundary belong to negative class (i.e. 0)</p><p>What if we add outlier and fit the linear regression line again, in this case decision boundary will be shifted towards right. Since the decision boundary is shifted towards right our predictions will also go wrong, like some of the points in positive class (i.e. class 1) will be shifted towards left hand side of a decision boundary (marked in green color), which clearly says that those points belong to negative class (i.e. class 0)(Benign Tumor), which is wrong. <strong>Hence we cannot use linear regression for classification problem</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*Ytim3KTMYEmohwIJA1M4RA.png" /></figure><p>Since the decision boundary is shifted towards right and we are not able to make any difference between positive class and negative class, this is where logistics regression comes in the picture.Decision boundary helps to differentiate between probabilities into positive class and negative class.</p><p><strong>Logistics Regression:</strong> Logistic Regression uses sigmoid function to deal with the outliers.Logistic function is a sigmoid function which takes any real value between ‘0’ and ‘1’ and can be written as see below:</p><p>If we plot a graph it will be in a shape of ‘S’ curve.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*PnWuwJtcIXhynBtPnNmHSA.png" /></figure><p>Sigmoid function squashes the value between ‘0’ and ‘1’. For large negative values output is close to ‘0’ and for large positive values output is close to ‘1’. Since the range of output will always between ‘0’ and ‘1’, we can interpret the output as probability.</p><p>Let us consider ‘z’ as linear function in a univariate regression model.</p><p>Z = mx + b</p><p>So the logistics equation will be:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*Innn-qMPd11t14D_rpVKDA.png" /></figure><p>Where Z = mx + b</p><p>Now when logistic regression come across an outlier it will take care of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*pPH2Q3oJrrVfi-Ee9p1xHg.png" /></figure><p>Note: Depending on the outlier position it will shift it’s y-axis to the left or right.</p><p><strong>Linear Decision Boundary</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*bpjG2bjbuEXWHtGd0iEZwA.png" /></figure><p><strong>Non Linear Decision Boundary</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*sTOXNgvYO9_J7jJD3Awzzg.png" /></figure><p>For calculating the accuracy, confusion matrix for classification problems check out my below blogs:</p><p><a href="https://medium.com/@inivikrant/confusion-cost-matrix-helps-in-calculating-the-accuracy-cost-and-various-other-measurable-a725fb6b54e1">https://medium.com/@inivikrant/confusion-cost-matrix-helps-in-calculating-the-accuracy-cost-and-various-other-measurable-a725fb6b54e1</a></p><p><a href="https://medium.com/@inivikrant/what-is-roc-and-auc-45d18edc4558">https://medium.com/@inivikrant/what-is-roc-and-auc-45d18edc4558</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ff0b45b5b89" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is ROC and AUC?]]></title>
            <link>https://medium.com/@inivikrant/what-is-roc-and-auc-45d18edc4558?source=rss-a527245f1326------2</link>
            <guid isPermaLink="false">https://medium.com/p/45d18edc4558</guid>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[area-under-the-curve]]></category>
            <category><![CDATA[roc]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[auc]]></category>
            <dc:creator><![CDATA[Vikrant Jain]]></dc:creator>
            <pubDate>Sat, 26 May 2018 02:54:41 GMT</pubDate>
            <atom:updated>2018-05-26T02:54:41.811Z</atom:updated>
            <content:encoded><![CDATA[<p>ROC and AUC is used to detect the performance of classification models like:</p><p>1. Decision Tree</p><p>2. Logistic Regression</p><p>3. Support Vector Machines etc.</p><p>ROC (Receiver Operating Characteristics) — It was originated from signal detection theory. Now it is heavily used by Data Miners, Economists and in Machine Learning.</p><p>It basically shows the trade-off between the true positive rate (TPR) and false positive rate (FPR).</p><p><strong>Example: </strong>IF model has been built to predict a cancer</p><p>1. <strong>TPR:</strong> Somebody actually having a cancer is predicted as having cancer is called as True positive rate. (Actual class: Yes (cancer) and Predicted class: Yes (cancer))</p><p>2. <strong>FPR: </strong>Somebody actually <strong>not</strong> having cancer is predicted to be as having cancer is False positive rate.(Actual class: No (No cancer) and Predicted class: Yes (cancer))</p><p>So we compare the actual Vs predicted and find the TPR and FPR and plot a graph for all the data points (below). In this case the curve which we get is called ROC.</p><p>Y-axis: TPR (True positive rate)</p><p>X-axis: FPR (False positive rate)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/359/1*OmzYwT7Q36GiU8eym5Ndag.png" /></figure><p>Ideally the ROC curve should always be above 45 degree line (Line marked in green color). ROC curve cannot be below 45 degree line, that is the minimum prediction we expect from our model. Otherwise the model will be of no use if it is not predicting at least 50 % good predictions.</p><p>ROC curve should always be: 0.5 &lt; ROC &lt; 1 (between 0.5 and 1).</p><p>Closer it is towards 1, better is the model. More area it has under it the better is the model associated with that ROC. So there are two ROC curves in the above graph. (One marked in yellow color and other marked in red color). Note: AUC for Model M1 is in yellow color and for Model M2 is in red color.</p><p>The Area under the ROC curve is known as the AUC (Area under the curve). That gives us the comparison, so higher the AUC better is the model. So the area marked by red color is big compare to area marked in yellow color. So Model M2 is giving us good performance compare to Model M1, as the AUC for Model M2 is higher than AUC for Model M1.</p><p>For confusion and cost matrix refer the below link : <a href="https://medium.com/@inivikrant/confusion-cost-matrix-helps-in-calculating-the-accuracy-cost-and-various-other-measurable-a725fb6b54e1">https://medium.com/@inivikrant/confusion-cost-matrix-helps-in-calculating-the-accuracy-cost-and-various-other-measurable-a725fb6b54e1</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45d18edc4558" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Confusion & Cost Matrix helps in calculating the accuracy, cost and various other measurable…]]></title>
            <link>https://medium.com/@inivikrant/confusion-cost-matrix-helps-in-calculating-the-accuracy-cost-and-various-other-measurable-a725fb6b54e1?source=rss-a527245f1326------2</link>
            <guid isPermaLink="false">https://medium.com/p/a725fb6b54e1</guid>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[confusion-matrix]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[classification-problem]]></category>
            <category><![CDATA[cost-matrix]]></category>
            <dc:creator><![CDATA[Vikrant Jain]]></dc:creator>
            <pubDate>Mon, 21 May 2018 12:49:09 GMT</pubDate>
            <atom:updated>2018-05-29T16:31:43.806Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Confusion &amp; Cost Matrix helps in calculating the accuracy, cost and various other measurable factors in classification problem</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*uQ7KR3yQjBQ6cpAzXtLDIA.png" /></figure><p><strong>a.</strong> <strong>True +ve: </strong>If the person is actually having cancer (Actual class = Yes) and we predict correctly as <strong>Yes</strong> he is actually having a cancer (Predicted Class = Yes)</p><p><strong>b.</strong> <strong>False -ve: </strong>If the person is actually having a cancer(Actual class = Yes) and we predict wrong as <strong>No</strong>, he is actually having a cancer (Predicted class = No)</p><p><strong>c.</strong> <strong>False +ve:</strong> if the person is not having a cancer (Actual class = No) and we predict as <strong>Yes</strong>,he is actually not having cancer but we predict as he is having cancer, which is wrong (Predicted class = Yes)</p><p><strong>d.</strong> <strong>True -ve: </strong>If the person is not having a cancer (Actual class = No) and we predict correctly as<strong> No, </strong>that means we predict correctly as the person is not having cancer (Predicted Class = No)</p><p>Confusion Metrics is used for evaluating the performance of classification problem</p><p>We can calculate the Accuracy as follows from confusion matrix:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*M64AxD5DEEOVtg-B0xaWSA.png" /></figure><p>We always need percentage of ‘a’ and ‘d’ to be maximum and percentage of ‘b’ and ‘c’ needs to be minimum so that the model is accurate or we can say accuracy is high</p><p>We can also call Accuracy as = Total Number of Correct predictions / Total Number of observations</p><p>Total Number of Correct predictions = a + d</p><p>Total Number of observations = a + b + c + d</p><p>Accuracy is always calculated in terms of percentage (0% to 100%) and in terms of fraction (0 to 1). Closer to 1 in terms of fraction is said to be better model.</p><p>However there are some Limitations of Accuracy:</p><p><strong>Limitations of Accuracy</strong></p><p>Let us consider a 2-class problem (0 and 1)</p><p>Suppose we are having below scenario:</p><p>Number of Class 0 examples = 9990</p><p>Number of Class 1 examples = 10</p><p>If the model predicts everything to be class 0, then</p><p>Accuracy is 9990 + 0/10000 = 99.9 %</p><p>Accuracy in this case will be misleading because model does not detect any class 1 example.</p><p>In this case we get accuracy as 99.9% but we cannot evaluate the performance of a model on the basis of accuracy because we were not able to predict class 1 examples.</p><p>If we see carefully the proportion of Class 0 examples is high which is 9990 and the proportion of class 1 examples is very low which is 10 for the 2-class problem.</p><p>Hence in the above case accuracy will not be a correct measure to evaluate the performance of model.</p><p>In this case we need to check ROC etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*sztfeCXjx0uWETynhyFWVg.png" /></figure><p>Cost matrix is similar to the confusion matrix except the fact that we are calculating the cost of wrong prediction or right prediction.</p><p>Example: Let us take an example of model which is used to predict someone having cancer or not having cancer (see below)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*4Td5KHlx5kbc57618kQwKQ.png" /></figure><p>In Case (1) : Someone having a cancer is predicted to be as not having cancer and in Case(2) someone not having cancer is predicted to be having cancer</p><p><strong>So what do you think what will be the cost of wrong predictions?</strong></p><p><strong>Obviously in both the cases cost will be involved</strong></p><p>Case(1) will be more costlier compare to Case (2): Because somebody who is having cancer is predicted to be as not having cancer, will not be given medication on cancer, hence probability is more that he/she will die.</p><p>Whereas in Case (2) somebody not having cancer is predicted to be having cancer, he/she will be given cancer treatment/medication but over the period of time he will be discharged from hospital once we come to know that he is not having cancer.</p><p>So in both the cases cost is involved, however Case (1) will be more costlier compare to Case (2), because there is high probability that Case(1) patient might die.</p><p>So not all wrong predictions will have the same cost. It has to be dealt with some weight.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*6mp82ofceanrUayPlxGWuQ.png" /></figure><p>There are two models namely Model M1 and M2 both of which are having correct predictions and wrong predictions.</p><p>If we compare both the models and if we check their accuracy. Accuracy for Model M2 is higher compare to Model M1, however the cost for Model M2 is higher compare to Model M1.</p><p>So it depends on what kind of problem statement we are facing.</p><p>If we are focusing on accuracy then we will go with the Model M2 (In this case we need to compromise on cost) , however if we are focusing on cost then we will go with the Model M1 (In this case we need to compromise on accuracy).</p><p><strong>Other Cost Sensitive Measures:</strong></p><p><strong>Precision(p) = a/a+c</strong></p><p><strong>Recall(r) = a/a+b</strong></p><p><strong>F-measure(F) = 2a/2a +b+c</strong></p><p>More meausers:</p><p>True positive rate (TPR) (Sensitivity)</p><p><strong>TPR = a/a+b (Sensitivity)</strong></p><p>True Negative rate (TNR)(Specificity)</p><p><strong>TNR = d/c+d (Specificity)</strong></p><p>False Positive rate (FPR)</p><p><strong>FPR = c/c+d</strong></p><p>False Negative rate(FNR)</p><p><strong>FNR = b/a+b</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a725fb6b54e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>