<?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 Vaibhav Jain on Medium]]></title>
        <description><![CDATA[Stories by Vaibhav Jain on Medium]]></description>
        <link>https://medium.com/@vaibhavj50?source=rss-2e0133ec0f1d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*GcuKBhx1iy3RF6gY_wVJoQ.jpeg</url>
            <title>Stories by Vaibhav Jain on Medium</title>
            <link>https://medium.com/@vaibhavj50?source=rss-2e0133ec0f1d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 06:52:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vaibhavj50/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[Still confused with Confusion Matrix?? let’s break the Confusion…..]]></title>
            <link>https://medium.com/@vaibhavj50/still-confused-with-confusion-matrix-lets-break-the-confusion-d1c39f28c00d?source=rss-2e0133ec0f1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1c39f28c00d</guid>
            <category><![CDATA[supervised-learning]]></category>
            <category><![CDATA[confusion-matrix]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[almabetter]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Vaibhav Jain]]></dc:creator>
            <pubDate>Tue, 14 Sep 2021 19:43:59 GMT</pubDate>
            <atom:updated>2021-09-14T19:43:59.077Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UeEjcWyU-Vr0sT8Y.jpg" /><figcaption>Source — Shutterstock</figcaption></figure><p>With a few lines of code, anyone can create a machine learning (ML) model, but creating a good machine learning model is a different story.</p><p>What do I mean when I say that a machine learning model is GOOD?</p><p>It differs, but in general, you’ll assess your machine learning model using certain specified criteria. When it comes to evaluating classification models, you’ll almost certainly employ a confusion matrix and associated metrics. Model evaluation, model monitoring, and model management all benefit from confusion matrices!</p><p>We’ll go through what a confusion matrix is, some key concepts and measurements, and all in this article.</p><p>So, without further do, let’s get started!</p><p><strong>What is a Confusion Matrix, and how does Confusion Matrix work?</strong><br>A confusion matrix, also known as an error matrix, is the summarised table used to evaluate a classification model performance. The number of rights and unsuccessful predictions is totaled and broken down by class using count values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/0*AxV2uPoaSIfSBLH6.png" /><figcaption>Source-Stackover flow</figcaption></figure><p><strong>True Positive (TP)</strong>: Outcome in which the model predicts the positive class properly.<br><strong>True Negative (TN): </strong>Outcome in which the model predicts the negative class properly.<br><strong>False Positive (FP): </strong>Also known as a type 1 error, this is an outcome in which the model predicts a positive class when it is actually negative.<br><strong>False Negative (FN):</strong> Also known as a type 2 error, this is a result in which the model predicts the negative class when it is actually positive.</p><p><strong>Metrics for Confusion Matrix</strong><br>We can dig into some of the important metrics that you can calculate from a confusion matrix now that you understand the fundamental layout of a confusion matrix as well as the accompanying key terms.</p><p><strong>Accuracy</strong><br>This is just the percentage of predictions that the model properly categorized. Accuracy is one of the metrics used to measure the performance of classification models in machine learning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*4ycpV_RadfzpxGWB.png" /></figure><p><strong>Precision</strong><br>Precision is the fraction of relevant instances among the recovered instances, also known as positive predictive value. In other words, it provides an answer to query, “What percentage of the positive identifications were correct?”</p><p>Or simply, the ratio of correct positive predictions to total positive predictions is known as precision.<br>How many of the expected positives are actually positive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*UKWjQzG3rEozLkhx.png" /></figure><p><strong>Recall</strong><br>The fraction of the total quantity of relevant instances that were actually retrieved is known as recall, also known as sensitivity, hit rate, or true positive rate (TPR). It provides an answer to the query, “What percentage of actual positives were accurately identified?”</p><p>The number of positives your model can recall from the data is known as recall.<br>Simply, how many positive records are correctly predicted out of all positive records.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*LZf7I42cObKn18Dg.png" /></figure><p><strong>F1 Points</strong></p><p>The F1 score is the harmonic mean of precision and recall, and it is a measure of a test’s correctness. It has a maximum score of 1 (perfect precision and memory) and a lowest score of 0 (no precision or recall). Overall, it is a measure of your model’s precision and resilience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/298/0*OVCQyYjnFs0E-s1B.png" /></figure><p><strong>Which metric to choose between precision or recall?</strong><br>The model’s performance is assessed using both precision and recall. Which one to pick is determined by the problem we’re trying to solve.</p><p><strong>Example for Recall</strong></p><p>For Covid Prediction, if the model predicts non-covid records, it’s a dangerous bet. All of our covid patient records should be appropriately forecasted.<br>In this case, recall metrics take precedence above precision. The rate of recall should be 100%. All patient data that are positive should be anticipated appropriately. The value of False Negative should be zero.<br>When evaluating the model’s performance for this dataset, recall measures are given higher weight.<br>It’s not so dangerous if non-covid data are forecasted as covid data.</p><p>There are 100 records in the covid data set, 94 of which are covid patients and 6 non-covid patients. However, the model properly predicts 90 out of 94 covid records. Four covid reports were incorrectly anticipated [ 4 — FN]</p><p><strong>Recall</strong> = 90/(90+4) = 0.95 or <strong>95%</strong></p><p><strong>Precision — Spam Call Filtering as an Example</strong></p><p>If the model forecasts decent calls as spam in the dataset, it’s a dangerous bet. We don’t want any of our legitimate communications to be mistaken for spam. As a result, when evaluating this model, the precision metric is given higher weight. The number of False Positives should be zero.<br>If there are 100 records in the spam filtering dataset, 94 of them are expected to be spam emails. Only 90 out of 94 recordings are correctly predicted. Four perfectly legitimate emails have been labeled as spam. It’s a dangerous move. It has an accuracy rate of 95%. It should be a hundred percent. There should be no such thing as “Spam” when it comes to calls. For this model, the false-positive rate should be zero.</p><p><strong>Conclusion</strong><br>The output of a classification can be either a class or a probability. The confusion matrix is used to solve classification issues given class output. We studied how to calculate metrics for classification issues with class outputs in this blog.</p><p>image source — (<a href="https://image.shutterstock.com/shutterstock/photos/1428255122/display_1500/stock-vector-chaotic-or-chaos-and-order-comic-brain-electric-lamp-idea-doodle-faq-business-loading-concept-1428255122.jpg">https://image.shutterstock.com/shutterstock/photos/1428255122/display_1500/stock-vector-chaotic-or-chaos-and-order-comic-brain-electric-lamp-idea-doodle-faq-business-loading-concept-1428255122.jpg</a>)</p><p>Source-Stackover flow</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1c39f28c00d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linear Regression -Machine Learning]]></title>
            <link>https://medium.com/@vaibhavj50/linear-regression-machine-learning-7cc1e5ffd3c7?source=rss-2e0133ec0f1d------2</link>
            <guid isPermaLink="false">https://medium.com/p/7cc1e5ffd3c7</guid>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[almabetter]]></category>
            <category><![CDATA[supervised-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Vaibhav Jain]]></dc:creator>
            <pubDate>Thu, 09 Sep 2021 16:38:07 GMT</pubDate>
            <atom:updated>2021-09-09T16:38:07.962Z</atom:updated>
            <content:encoded><![CDATA[<p>Machine Learning, which is a subset of Artificial Intelligence (AI), has become increasingly important in our everyday life. Machine learning algorithms are frequently used by data science engineers and developers in a variety of disciplines to make their tasks and lives easier. For example, certain machine learning algorithms allow Google Maps to find the quickest route to our destinations, Tesla to build self-driving cars, Amazon to generate nearly 35% of its annual revenue, AccuWeather to get weather forecasts for 3.5 million locations weeks in advance, Facebook to automatically detect faces and suggest tags, and so on.</p><h3>What is a Regression Problem?</h3><p>It is the technique of predicting a result using an algorithm based on previously entered values and the results generated from them.</p><p>Assume there is an input variable ‘x’ and an output variable ‘y,’ with y being a function of x (y=fx).</p><p>Supervised learning reads the value of the entered variable “x” and the generated variable “y” in order to utilize the results to predict a highly accurate output data of “y” from the entered value of “x” later. When the resulting variable has a real or continuous value, it is referred to as a regression problem. It aims to find the best fit line from data collected from a number of places.</p><p>Which of these, for example, is a regression problem?</p><p>Can you guess ????</p><p>How much will it cost me to drive 100 miles?<br>What is a person’s nationality?<br>What does a person’s age mean?<br>Which planet is the closest to the Sun?<br>Regression challenges include predicting the amount of gas to be spent and a person’s age. Nationality can be predicted categorically, while the closest planet to the Sun can be predicted discretely.</p><h3>What is Linear Regression?</h3><p>Let’s pretend we have a dataset with data on the association between “number of hours studied” and “marks attained.” A number of pupils have been monitored, and their study hours and grades have been recorded. This will be the basis for our training. Our goal is to create a model that can predict grades based on the number of hours studied. A regression line is created using the training data that will yield the least amount of error. After that, this linear equation is applied to new data. That example, if we provide our model the amount of hours a student has spent studying as an input, it should be able to accurately predict their grade.</p><h3>How does Linear Regression work?</h3><p>Let’s take a look at a situation where linear regression could be useful: weight loss. Let’s say there’s a link between how many calories you eat and how much you weigh; regression analysis can assist you to figure out what that link is. In order to make predictions about your data, regression analysis will offer you a relationship that may be represented as a graph. For example, if you’ve been gaining weight in recent years, it can forecast how much you’ll weigh in ten years if you keep eating the same amount of calories and burning them at the same rate.</p><p>Let’s look at an example of when linear regression could be beneficial: weight loss. Let’s imagine there’s a link between the number of calories you consume and the amount of weight you gain; regression analysis can help you figure out what that link is. Regression analysis will provide you with a relationship that may be represented as a graph in order to generate predictions about your data. It can predict how much you’ll weigh in ten years if you maintain eating the same amount of calories and burning them at the same rate, for example, if you’ve been gaining weight in previous years.</p><h3>How do we determine the best fit line?</h3><p>The best fit line is defined as the one with the least amount of error between the anticipated and observed values. The mistakes are also known as residuals, and the regression line is also known as the regression line. The residuals are depicted in the diagram below. The vertical lines from the observed data value to the regression line may be seen.</p><h3>When to use Linear Regression?</h3><p>Linear Regression’s strength lies in its simplicity, which allows it to be applied to a wide range of problems. To begin, the data from the observations must be gathered and plotted along a line. If the gap between the projected value and the actual value is nearly equal, we can solve the problem with linear regression.</p><h3>Assumptions in linear regression</h3><p>If you’re going to use linear regression to solve your problem, there are a few things to keep in mind:</p><p>1. The dependent and independent variables should have a nearly linear relationship.<br>2. Because the data is homoscedastic, the variation between the outcomes should be kept to a minimum.<br>3. The outcomes of one observation should not be impacted by the outcomes of the preceding one.<br>4. The residuals should be spread normally. The probability density function of the residual values is normally distributed at each independent value, according to this assumption.</p><p>You can see if your data fulfills these requirements by visualizing it and then looking deeper into its structure.</p><h3>Few properties of Regression Line</h3><p>A regression line has the following characteristics:</p><p>The mean of the independent variable (x) and the mean of the dependent variable (y) are both used in regression (y).<br>The sum of “Square of Residuals” is minimized by using a regression line. As a result, Linear Regression is referred to as “Ordinary Least Square (OLS)”. Later on, we’ll go into Ordinary Least Square in greater depth.<br>B1 explains a one-unit change in x with a one-unit change in Y. In other words, increasing the value of ‘X’ causes a change in the value of Y.</p><h3>Model Performance</h3><p>If the gap between the projected and actual data values is small after the model is developed, it is called a good model and can be used to make future predictions. The quantity we deem “not much” is totally dependent on the work at hand and the degree to which data fluctuation may be tolerated. Here are some metrics that we can use to calculate model error:</p><p>R — Square (R2)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/0*mt1lM6ISJa9GH7c7.jpg" /></figure><p>Total Sum of Squares (TSS): The total sum of squares (TSS) is a typical manner of presenting the findings of such a study. The sum of squares is a metric for determining how a set of data changes around a central number (like the mean). The Total Sum of Squares indicates the amount of variance in the dependent variable.</p><p>TSS = Σ (Y — Mean[Y])2</p><p><strong>Residual Sum of Squares (RSS):</strong>(RSS) informs you how much of the variation in the dependent variable your model didn’t explain. The difference between the actual Y and the projected Y is the sum of the squared discrepancies.</p><p>RSS = Σ (Y — f[Y])2</p><p>The degree of variability in the response that is explained by running the regression is measured by (TSS — RSS).</p><h4>Properties of R2</h4><p>1.R2 is always between 0 and 1.<br>2. A R2 of 0 indicates that the dependent and independent variables have no association.<br>3. A R2 of 1 indicates that the dependent variable can be accurately predicted from the independent variable.<br>4. An R2 value between 0 and 1 indicates how predictable the dependent variable is. An R2 of 0.20 indicates that 20% of the variance in Y can be predicted from X; an R2 of 0.40 indicates that 40% of the variance can be predicted; and so on.</p><p><strong>Root Mean Square Error (RMSE)</strong></p><p>The root mean square error or (RMSE) is the residual standard deviation . The following is the formula for computing RMSE:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/0*4_3s41ikkfnhwo4y.jpg" /></figure><p>Where N : Total number of observations</p><p>When normalized observations are utilized as RMSE inputs, the correlation coefficient has a direct link. Basically, when a correlation coefficient is 1, for instance, if the RMSE is 0 since all of the points are on the regression line (&amp; therefore there are no errors).</p><p><strong>Mean Absolute Percentage Error (MAPE)</strong></p><p>Because RMSE has some limitations, analysts prefer MAPE over RMSE, which delivers error in percentages so that alternative models can be considered for the task and their performance compared. MAPE can simply be calculated using the following formula:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/0*jf3L323CX4mprEPI.jpg" /></figure><p>Where N : Total number of observations</p><h3>Data preparation for Linear Regression</h3><p>Step 1: Linear Assumption</p><p>The first stage in data preparation is to look for variables that have a linear relationship with both the dependent and independent variables.</p><p>Step 2: Remove Noise</p><p>It is the process of lowering the amount of attributes in a dataset by removing those that aren’t required for the model’s building.</p><p>Step 3: Remove Collinearity</p><p>The strength of the association between independent variables is determined by collinearity. If two or more variables are strongly collinear, keeping both of them when assessing the model is pointless, thus we can keep one of them.</p><p>Step 4: Gaussian Distributions</p><p>If the input and output variables have a Gaussian distribution, the linear regression model will yield more dependable results. According to the Gaussian theorem, a sample mean from an infinite population is nearly normal, or Gaussian, with a mean equal to the underlying population and variance equal to the population variation divided by the sample size. As the sample size grows larger, the approximation improves.</p><p>Step 5: Rescale Inputs</p><p>If the input variables are rescaled using standardization or normalization, the linear regression model will provide more reliable predictions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7cc1e5ffd3c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>