<?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 Nehra Vikas on Medium]]></title>
        <description><![CDATA[Stories by Nehra Vikas on Medium]]></description>
        <link>https://medium.com/@nehra.vikas95?source=rss-16e865297907------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*IH1k6RKwVFIH1-xGHzt2Vw@2x.jpeg</url>
            <title>Stories by Nehra Vikas on Medium</title>
            <link>https://medium.com/@nehra.vikas95?source=rss-16e865297907------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 12:11:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nehra.vikas95/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[Z-TEST]]></title>
            <link>https://medium.com/@nehra.vikas95/z-test-1e82382cc448?source=rss-16e865297907------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e82382cc448</guid>
            <category><![CDATA[performing-a-z-test]]></category>
            <category><![CDATA[z-test]]></category>
            <category><![CDATA[one-proportion-z-test]]></category>
            <category><![CDATA[z-test-analysis]]></category>
            <dc:creator><![CDATA[Nehra Vikas]]></dc:creator>
            <pubDate>Wed, 28 Aug 2024 10:26:04 GMT</pubDate>
            <atom:updated>2024-08-28T10:26:04.200Z</atom:updated>
            <content:encoded><![CDATA[<p><em>The z-test is a hypothesis test to determine if a single observed mean is significantly different (or greater or less than) the mean under the null hypothesis, µhypo when you know the standard deviation of the population.</em></p><p><strong>It’s a statistical check to see if what you observed is meaningfully different from what you expected, using the knowledge of overall variability in the data.</strong></p><h4>Z-test is the most commonly used statistical tool in research methodology, with it being used for studies where the sample size is large (n&gt;30).</h4><h3>When to use the z test:</h3><ul><li>Normal distribution of data</li><li>All data points are independent</li><li>Standard deviation is known</li><li>Sample Size ≥ 30</li><li>Equal sample variance</li></ul><blockquote><strong><em>Standard deviation for sample distribution = Population Standard Deviation / √n</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AGF8VSRcvM4hNUAIpXRu1w.png" /></figure><h3>Types of Z Test in Hypothesis Testing:</h3><ol><li>Z-test for Means</li><li>Z-test for Proportions</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KnqIlUncogwyS_vO8tTWzg.png" /></figure><h3>Steps to Perform a Z-Test for Means:</h3><ol><li><strong>State the Hypotheses:</strong></li></ol><ul><li><strong>Null Hypothesis (H₀):</strong> Assumes there’s no difference between the sample mean and the population mean .</li><li><strong>Alternative Hypothesis (H₁):</strong> Suggests that there is a difference (e.g., the sample mean is not equal to, greater than, or less than the population mean).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WqH_M31xdV1cxmW5PgoDJQ.png" /></figure><blockquote><em>One-sample z-test is used to compare the sample mean with the population mean. In other words, it checks whether the sample belongs to the given population using Z-statistics.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*ZAD_Yt650jcSbmm_.png" /></figure><h3>Two-Sample Z Test for means:</h3><blockquote>A <strong>Two-Sample Z-Test for Means</strong> is a statistical method used to compare the averages (means) of two different groups to see if they are significantly different from each other.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*K1jcny3GFzK3d3uh.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f2H5LAX5hHSrwbMGL6u80Q.png" /></figure><h3>Z Test for Proportions</h3><ul><li><strong>Single Proportion</strong>: When you want to compare the proportion of a particular outcome in a sample to a known population proportion.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*H8sPFJq1lY82Bedr.jpg" /></figure><ul><li><strong>Two Proportions</strong>: When you want to compare the proportions of a particular outcome between two independent groups.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cnEoqm8lZc49ePyKSbT1uQ.png" /></figure><ul><li><strong>Z-Test for Means</strong>: This test compares the average of a sample to a known population mean, or it compares the means of two different samples to determine if they differ significantly.</li><li><strong>Z-Test for Proportions</strong>: This test evaluates if a sample proportion differs from a known population proportion, or if the proportions from two different samples are significantly different from each other.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e82382cc448" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CHI-SQUARE TEST]]></title>
            <link>https://medium.com/@nehra.vikas95/chi-square-test-3f18b403bc5f?source=rss-16e865297907------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f18b403bc5f</guid>
            <category><![CDATA[chi-square]]></category>
            <category><![CDATA[chi-square-test]]></category>
            <category><![CDATA[hypothesis-testing]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Nehra Vikas]]></dc:creator>
            <pubDate>Mon, 10 Jun 2024 11:21:43 GMT</pubDate>
            <atom:updated>2024-06-10T11:21:43.735Z</atom:updated>
            <content:encoded><![CDATA[<p>The Chi-Square test is like a tool that helps us understand if there is a real connection between two things we are observing, or if what we’re seeing is just random luck.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZGA1X6LQ0rxO3Zjq.jpg" /></figure><h3>Imagine you have a bag of candies, and you think there might be a pattern to the colors of the candies. Maybe you think there are more red candies than any other color. To figure out if you’re right, you can use the Chi-Square test.</h3><p><em>Here’s how it works in easy steps:</em></p><p>1.<strong> Collect Data </strong>: First, you count how many candies of each color are in the bag. This is your “<strong>observed</strong>” data.</p><p>2. <strong>Make a Prediction</strong>: Next, you predict how many candies of each color you would expect to find if everything was totally random. This is your “<strong>expected</strong>” data.</p><p>3. <strong>Compare Observed and Expected</strong>: The Chi-Square test compares the <em>observed data with the expected data .</em></p><p>4. <strong>Calculate the Difference</strong>: When we “<em>calculate the difference</em>,” we’re seeing how different our actual counts (observed) are from what we thought they would be (expected).</p><h3>Formula For Chi-Square Test</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/309/0*aGPc836M5f_azN6S.png" /></figure><p>Where</p><p>c = Degrees of freedom</p><p>O = Observed Value</p><p>E = Expected Value</p><h3>There are two main types of Chi-Square tests namely -</h3><ol><li><strong>Independence</strong></li></ol><p>2<strong>. Goodness-of-Fit</strong></p><h3>Independence:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*sM_42goyArfka3Le.jpg" /></figure><h3>Chi-Square Test of Independence: The Classroom Study</h3><p>Imagine you are a <strong>researcher</strong> trying to determine if there is a relationship between students’ preferred study methods and their performance on exams.</p><h4>Steps to Conduct the Test:</h4><ol><li><strong>Collect Data</strong>:</li></ol><p>You survey a group of students about their preferred study methods (e.g., flashcards, group study, solo study) and categorize their exam performance (e.g., high, medium, low).</p><p><strong>2. Formulate Hypotheses</strong>:</p><p><strong>Null Hypothesis (H0)</strong>: There is no relationship between the study methods and exam performance.</p><p><strong>Alternative Hypothesis (H1)</strong>: There is a relationship between the study methods and exam performance.</p><p><strong>3. Create a Contingency Table</strong>:</p><ul><li>You organize the data into a table with study methods as rows and exam performance levels as columns, noting the frequency of each combination.</li></ul><h4>4. Performing the Chi-Square Test:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*QrU0pRg1OsO8lMNe.png" /></figure><h3>2.Goodness-Of-Fit-</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*csruw2kf0RCKZloA.jpg" /></figure><p>Imagine we’re testing if a fair six-sided dice actually behaves as expected. We roll the dice many times and record the outcomes. Then we compare our observed results to what we’d expect from a fair dice using the Chi-Square Test.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f18b403bc5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recurrent Neural Networks]]></title>
            <link>https://medium.com/@nehra.vikas95/recurrent-neural-networks-7b0a3e499b21?source=rss-16e865297907------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b0a3e499b21</guid>
            <category><![CDATA[lstm-networks]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[rnn]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[gated-recurrent-unit]]></category>
            <dc:creator><![CDATA[Nehra Vikas]]></dc:creator>
            <pubDate>Fri, 03 May 2024 14:42:22 GMT</pubDate>
            <atom:updated>2024-05-03T14:42:22.166Z</atom:updated>
            <content:encoded><![CDATA[<h3>Recurrent neural networks (RNNs) are the state of the art algorithm for sequential data and are used by Apple’s Siri and Google’s voice search. It is the first algorithm that remembers its input, due to an internal memory, which makes it perfectly suited for machine learning problems that involve sequential data. It is one of the algorithms behind the scenes of the amazing achievements seen in deep learning over the past few years.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QhRqi5b1lbog4W-Q.png" /></figure><p>In time series data, the current observation depends on previous observations, and thus observations are not independent from each other. <strong>Traditional neural networks, however, view each observation as independent as the networks are not able to retain past or historical information.</strong></p><h3>But how does an RNN achieve this memory?</h3><p>RNNs achieve a memory through a feedback loop in the cell. And this is the main difference between a RNN and a traditional neural network. The feed-back loop allows information to be passed within a layer in contrast to feed-forward neural networks in which information is only passed between layers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lBbJwBcxci9tWCG2.jpg" /></figure><h3>Types Of RNN</h3><p>There are four types of RNNs based on the number of inputs and outputs in the network.</p><ol><li>One to One</li><li>One to Many</li><li>Many to One</li><li>Many to Many</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GjZqbDIL_oEvnmJT.png" /></figure><h4>One to One</h4><p>This type of RNN behaves the same as any simple Neural network it is also known as Vanilla Neural Network. In this Neural network, there is only one input and one output.</p><h4>One To Many</h4><p>In this type of RNN, there is one input and many outputs associated with it. One of the most used examples of this network is Image captioning where given an image we predict a sentence having Multiple words.</p><h4>Many to One</h4><p>In this type of network, Many inputs are fed to the network at several states of the network generating only one output. This type of network is used in the problems like sentimental analysis. Where we give multiple words as input and predict only the sentiment of the sentence as output.</p><h4>Many to Many</h4><p>In this type of neural network, there are multiple inputs and multiple outputs corresponding to a problem. One Example of this Problem will be language translation. In language translation, we provide multiple words from one language as input and predict multiple words from the second language as output.</p><h3>different types of RNN evolved:</h3><ul><li><strong>Traditional Recurrent Neural Network (RNN)</strong></li><li><strong>Long-Short-term-Memory Recurrent Neural Network (LSTM)</strong></li><li><strong>Gated Recurrent Unit Recurrent Neural Network (GRU)</strong></li></ul><h3>Recurrent Neural Network (RNN)</h3><p>The RNN suffers from the vanishing gradient descent. In this, the gradients that are used to update the weights during backpropagation become very small. Multiplying weights with a gradient that is close to zero prevents the network from learning new weights. This stopping of learning results in the RNN forgetting what is seen in longer sequences. The problem of vanishing gradient descent increases the more layers the network has.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/0*PFM_Xh0wswz34b-5.gif" /></figure><p><strong>As the RNN only keeps recent information, the model has problems to consider observations which lie far in the past. The RNN, thus, tends to loose information over long sequences as it only stores the latest information. Hence, the RNN has only a short-term but not a long-term memory.</strong></p><h3>Long-Short-Term-Memory (LSTM)</h3><p>LSTMs are a type of special neural network that is great at understanding and remembering patterns in sequences of data, like words in a sentence.</p><p>Imagine you’re learning a song: LSTMs are good at remembering the melody and lyrics you heard earlier, even as you continue listening to new parts of the song. This ability to remember earlier parts helps them figure out the overall pattern and make sense of the whole sequence.</p><p><strong>In simple terms, LSTMs are like smart algorithms that can learn from sequences of data and make predictions based on what they’ve learned. They are used in advanced applications such as language translation and speech recognition to handle complex sequential data effectively.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*wJhPNlp86LkWFv4Vd4kkhA.png" /></figure><h3>Gated Recurrent Unit (GRU)</h3><p>Similar to LSTMs, The difference to LSTMs, however, is that GRUs use fewer gates and do not have a separate internal memory, i.e., <strong>update gate and reset gate</strong>. Hence, the GRU solely relies on the hidden state as a memory, leading to a simpler architecture.</p><h3>How do GRUs work?</h3><p>Basically, these are two vectors which decide what information should be passed to the output. The special thing about them is that they can be trained to keep information from long ago, without washing it through time or remove information which is irrelevant to the prediction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*wIK93taP_l4kyH0lkSCr_g.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b0a3e499b21" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gradient Descent In Details]]></title>
            <link>https://medium.com/@nehra.vikas95/gradient-descent-in-details-c2517bbbaddf?source=rss-16e865297907------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2517bbbaddf</guid>
            <category><![CDATA[gradient-descent]]></category>
            <category><![CDATA[mini-batch-gradient]]></category>
            <category><![CDATA[stochastic-gradient]]></category>
            <category><![CDATA[batch-gradient-descent]]></category>
            <category><![CDATA[gradient-background]]></category>
            <dc:creator><![CDATA[Nehra Vikas]]></dc:creator>
            <pubDate>Mon, 29 Apr 2024 12:58:37 GMT</pubDate>
            <atom:updated>2024-04-29T12:58:37.347Z</atom:updated>
            <content:encoded><![CDATA[<h3>A gradient is like a guide telling you the steepest path up a hill. It shows the direction and speed to reach the peak of a function, helping find its highest or lowest points.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W-2pg4j1O18uOEVt" /></figure><h4>Optimization algorithms aim to achieve one of two goals when minimizing a function:</h4><ol><li><strong>Global Minimum</strong>: This is the overall smallest value of the function. It’s achievable when the function is convex, meaning every local minimum is also the global minimum.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/0*NNfRPcSpaBG8wL3k.png" /></figure><ol><li><strong>Local Minimum</strong>: If the function is not convex .he goal is to find the lowest value in the function’s immediate surroundings.</li></ol><h3>Intuition behind Gradient Descent:</h3><p>For ease, let’s take a simple linear model.</p><p><em>Error = Y(Predicted)-Y(Actual)</em></p><blockquote><strong>A machine learning model always wants low error with maximum accuracy, in order to decrease error we will intuit our algorithm that you’re doing something wrong that is needed to be rectified, that would be done through Gradient Descent.</strong></blockquote><p>We need to minimize our error, in order to get pointer to minima we need to walk some steps that are known as alpha(learning rate).</p><h3>Steps to implement Gradient Descent</h3><ol><li>Randomly initialize values.</li><li>Update values.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/0*UQMUupBSGeXMtsFe.png" /></figure><p>3. Repeat until slope =0(get minimum)</p><p>A derivative is like finding how steep a hill is at one spot. Imagine drawing a line that just touches the hill at that point. The slope of this line tells us the direction to move to reach the bottom of the hill.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/0*OXzDrYiQWSwQHrM7.png" /></figure><p><strong>Learning rate must be chosen wisely as:</strong></p><p>1. if it is too small, then the model will take some time to learn.</p><p>2. if it is too large, model will converge as our pointer will shoot and we’ll not be able to get to minima.</p><h3>Big Learning rate v/s Small Learning rate</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v9wO-pvDPw64Xtzn.png" /></figure><h3>Gradient Descent with different learning rates</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/0*sOIz_t1Ar4UEpn6q.png" /></figure><h3>Gradient descent can be categorized into different types</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/0*-6xGDT_vOgF3cguP.png" /></figure><h3>Batch Gradient Descent</h3><p>In Batch Gradient Descent, all the training data is taken into consideration to take a single step. We take the average of the gradients of all the training examples and then use that mean gradient to update our parameters. So that’s just one step of gradient descent in one epoch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*heqnP-xVMzpjYAMJ.png" /></figure><p>Batch Gradient Descent is great for convex or relatively smooth error manifolds. In this case, we move somewhat directly towards an optimum solution.</p><h3>Stochastic Gradient Descent</h3><p>In Batch Gradient Descent we were considering all the examples for every step of Gradient Descent. But what if our dataset is very huge. Deep learning models crave for data.</p><p>Since we are considering just one example at a time the cost will fluctuate over the training examples and it will <strong>not </strong>necessarily decrease. But in the long run, you will see the cost decreasing with fluctuations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*CgPrOY-9cyULUcly.png" /></figure><p>Also because the cost is so fluctuating, it will never reach the minima but it will keep dancing around it.</p><p>SGD can be used for larger datasets. It converges faster when the dataset is large as it causes updates to the parameters more frequently.</p><h3>Mini Batch Gradient Descent</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kUavlrc1Hf4L00N_.png" /></figure><p>We have seen the Batch Gradient Descent. We have also seen the Stochastic Gradient Descent. Batch Gradient Descent can be used for smoother curves. SGD can be used when the dataset is large. Batch Gradient Descent converges directly to minima. SGD converges faster for larger datasets. But, since in SGD we use only one example at a time, we cannot implement the vectorized implementation on it. This can slow down the computations. To tackle this problem, a mixture of Batch Gradient Descent and SGD is used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*5mHkZw3FpuR2hBNFlRxZ-A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2517bbbaddf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ANOVA TEST.]]></title>
            <link>https://medium.com/@nehra.vikas95/anova-test-f0c275748dae?source=rss-16e865297907------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0c275748dae</guid>
            <category><![CDATA[anova]]></category>
            <category><![CDATA[anova-python]]></category>
            <category><![CDATA[anova-test]]></category>
            <dc:creator><![CDATA[Nehra Vikas]]></dc:creator>
            <pubDate>Mon, 22 Apr 2024 08:20:43 GMT</pubDate>
            <atom:updated>2024-04-22T08:20:43.829Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*QmAIBEmk4ZqeH_ds.jpg" /></figure><p><strong>The ANOVA</strong>, which stands for the <strong>Analysis of Variance</strong> test, is a tool in statistics that is concerned with<strong> comparing the means of more than two groups of data sets</strong> and to what extent they differ.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/0*ubrrrANF8Uwr1uxi.jpg" /></figure><p><strong>Null hypothesis(<em>H</em>0):</strong> There is no difference among group means.</p><p><strong>Alternative hypothesis (<em>H</em>a):</strong>there is at least one group differs significantly from the overall mean of the dependent variable.</p><h3><strong>STEPS IN ANNOVA TEST.</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/0*aByHTTvsd-Sle_EF" /></figure><h3>Step 1:</h3><p><strong>We start with defining hypothesis</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/0*GCVTkOdiytBFo5vV" /></figure><ul><li><strong>Null hypothesis:</strong> All the group averages are the same.</li><li><strong>Alternative hypothesis</strong>: At least one group average is different.</li></ul><h3>Step 2:</h3><p><strong>Collect Data: </strong>Gather data from different groups.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*jk7wQoMnSVg6e4TD.jpg" /></figure><h3>Step 3:</h3><p><strong>Degree of Freedom (DF):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n02bY-6oaa61iEET.jpg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/0*TBAEf0Lg9_T_FkEJ.png" /></figure><ul><li>Calculate the degrees of freedom for both within-group(dfw) and between-group variations(dfb).</li><li>it refers to the number of values in a statistical calculation that are free to vary. It’s like the number of “choices” you have when making a calculation.</li></ul><h3>Step 4:</h3><p><strong>Calculate Group Averages in each group</strong>:</p><ul><li>Find the average (mean) for each group.</li></ul><h3>Step 5:</h3><p><strong>Find the Overall Average</strong>:</p><ul><li>Calculate the average across all the groups combined.</li></ul><h3>Step 6:</h3><p><strong>Measure Differences:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*HE5RNT1H9KO3ZuWR.png" /></figure><ul><li>We measure two types of differences:</li><li><strong>Within-group differences</strong>: How much data varies within each group.</li><li><strong>Between-group differences</strong>: How much data differs between the each groups.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/0*MOwt64HDCBThw9p6" /></figure><h3>Step 7:</h3><p><strong>Calculate F-statistic:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/0*YBciTETcMsJeeDOj.png" /></figure><ul><li>This is a number that tells us if the differences between groups are big enough to be meaningful.</li><li>It’s like a signal-to-noise ratio: we want the signal (between-group differences) to be much bigger than the noise (within-group differences).</li></ul><h3>Step 8:</h3><p><strong>Compare to Critical Value</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3d7zqUkS9Sywn4l-.jpg" /></figure><ul><li>We compare the F-statistic to a critical value from a table. If our F-statistic is bigger than the critical value, we have enough evidence to reject the null hypothesis.</li></ul><h3>Step 9:</h3><p><strong>Make a Conclusion</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Yoq6ZFbmKaWitdhd.jpg" /></figure><ul><li>If we reject the null guess, we conclude that there’s enough evidence to say that at least one diet is different from the others.</li></ul><blockquote><strong>code of python for one way anova.</strong></blockquote><blockquote><em>import scipy.stats as stats</em></blockquote><blockquote><em># Example data representing three treatment groups<br>group1 = [23, 25, 27, 29, 31]<br>group2 = [20, 22, 24, 26, 28]<br>group3 = [18, 21, 24, 27, 30]</em></blockquote><blockquote><em># Perform one-way ANOVA<br>statistic, p_value = stats.f_oneway(group1, group2, group3)</em></blockquote><blockquote><em># Print results<br>print(“ANOVA statistic:”, statistic)<br>print(“p-value:”, p_value)</em></blockquote><blockquote><em># Interpret results<br>alpha = 0.05<br>if p_value &lt; alpha:<br> print(“Reject null hypothesis: There is a significant difference between group means.”)<br>else:<br> print(“Fail to reject null hypothesis: There is no significant difference between group means.”)</em></blockquote><h3>Post hoc Analysis</h3><p>Post hoc analysis is used after conducting an ANOVA (Analysis of Variance) test to determine which specific groups are significantly different from each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eDXh2vzKBkcbgyfh.jpg" /></figure><p><strong>Step in post hoc analysis.</strong></p><p>1. Conduct ANOVA test.<br>2. If ANOVA indicates significant differences, proceed to post hoc analysis.<br>3. Choose appropriate post hoc test (e.g., Tukey’s HSD)<br>4. Perform pairwise comparisons between groups.<br>5. Identify significant differences between specific groups.<br>6. Interpret and report findings.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0c275748dae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MATRICES FOR MACHINE LEARNING MODELS.]]></title>
            <link>https://medium.com/@nehra.vikas95/matrices-for-machine-learning-models-f0f8574221c1?source=rss-16e865297907------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0f8574221c1</guid>
            <category><![CDATA[machine-learning-metrics]]></category>
            <category><![CDATA[classification-metrics]]></category>
            <category><![CDATA[regression-metric]]></category>
            <dc:creator><![CDATA[Nehra Vikas]]></dc:creator>
            <pubDate>Mon, 22 Apr 2024 05:55:37 GMT</pubDate>
            <atom:updated>2024-04-22T05:55:37.001Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qiVB0bGyap3GoLtR.jpg" /></figure><p>Performance metrics is an essential part in machine learning to understand how well the model is performing. The key is to build a machine learning model that generalizes well i.e., a model that performs well on the future unseen data.</p><p>When evaluating a model it is crucial to assess it predictive ability, generalizing capacity and overall quality. The choice of the performance metric depends on the problem domain, the type of data and the desired outcome.</p><p><strong>Predictive Models</strong></p><p>Predictive models are of two types — classification and regression model. Classification tasks are those for which the output is a class label and in regression models the output is a continuous value.</p><h3>Classification Metrics</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/0*Fd4Oaoys6j2r4vA-.png" /></figure><h3>1. Accuracy</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lJNmKKMoFH_iu3cv.png" /></figure><p>Accuracy is the most common and simple performance metric. It is the ratio of correctly classified points divided by total no. of points in the dataset.</p><p><strong>Accuracy is a good performance metric when the class is balanced. In contrary if the class is imbalanced, accuracy could be a misleading metric.</strong></p><h3>2. Confusion matrix</h3><p>Confusion matrix as the name says gives a N*N matrix as output where N is the number of target class.<strong> The confusion matrix is a tabular summary of the number of correct and incorrect predictions made by the classifier.</strong> The matrix compares the actual values with the predicted values by the machine learning model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/0*raoQTg1ZL_s6_G50.png" /></figure><h3>Understanding confusion matrix:</h3><p><strong>True Positive:</strong> The actual value is Positive and predicted value is also Positive.</p><p><strong>True Negative: </strong>The actual value is negative and predicted value is also negative.</p><p><strong>False Positive</strong>: The actual value is negative whereas predicted value is positive.</p><p><strong>False Negative</strong>: The actual value is positive whereas predicted value is negative.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/0*cgyebTJZ1YQuaO6g.png" /></figure><h3>3. Precision</h3><p>Precision is a metric that measures the proportion of true positives among the positive predictions.</p><p><strong><em>Out of all the datapoints the model predicted to be positive, how many are actually positive.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/0*ZpWGKNOYaWE_szpM.png" /></figure><h3>4. Recall</h3><p>Recall is a metric that measures the proportion of true positives among the actual positives.</p><p><strong>Recall is a useful metric in cases where False Negative is of higher concern than False Positive.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/0*V5_owUjXX1CyyXH6.png" /></figure><h3>5. F1 Score</h3><p>There is one metric which combines both precision and recall. F1score comes in handy to tackle this problem. F1 score is a metric that combines the precision and recall in a single score. <strong>It is simply the harmonic mean of precision and recall.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/0*a4uh5O48-zr9wfjC.png" /></figure><h3>6. Area Under the Receiver Operating Characteristic Curve (AUC-ROC)</h3><p><strong>The AUC-ROC curve is a probability curve that plots TPR (True Positive Rate) and FPR (False Positive Rate)</strong> at various thresholds that separates the classes. <strong>The curve is a graph that shows how well a classification model distinguishes between two classes at various thresholds. Higher the AUC, better the model is. </strong>Below is the graph showing ROC curve having TPR at y-axis and FPR at x-axis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*26LAvxzgtJ3fgk-k.png" /></figure><p><strong>A classifier’s performance is considered optimal when it achieves a high TPR without a significant increase in FPR. Hence, the top-left corner of the ROC curve, which signifies <em>a high TPR and a low FPR, represents the ideal balance or “sweet spot”.</em></strong></p><h3>7. Log loss</h3><p>The log loss lies between 0 and infinity. A lower Log Loss indicates better model performance. A Log Loss of 0 means the predicted probabilities match the actual outcomes perfectly, while higher values indicate increasing levels of deviation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/0*ot4Df1R4mPgBP6QA.png" /></figure><p>Log loss encourages models to be not only accurate but also confident in their predictions</p><h3>Regression Metrics</h3><p>When the output is a real number then the whole game changes as we can no longer use the above discussed metrics.</p><p><strong>Below are some of the metrics discussed to deal with regression based problems.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/0*rsdNxVxoazf1Xguk.png" /></figure><h3>8. Mean Absolute Errors(MAE)</h3><p>It is the most simplest and common metric used in regression problems.<strong> It is basically the sum of average of the absolute difference between the actual and the predicted values</strong>. Lower the value, better is the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/0*MfNeTfujkzFGLTMX.png" /></figure><p>This metric is robust to outliers as it treats all points equally irrespective of the outliers.</p><h3>9. Mean Squared Error (MSE):</h3><p><strong>It is simply the average squared difference of the actual and predicted values.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/0*45CSK4zIwQndnEvv.png" /></figure><p>The problem with this metric is that, it treats all the points equally irrespective of the outliers. So this metric too is robust to outliers as is it doesn’t penalize high errors. Also the errors are over represented due to squaring. The value of the error ranges from 0 to infinity and the model is as good as the value is close to 0.</p><h3>10. Root mean squared errors (RMSE)</h3><p>The root mean squared error calculates the square root of average squared residuals. The good point about RMSE is that it is easier to interpret since the metric is in the scale of the target variable. Other than that it is very similar to MSE.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/0*YEL0rSAlpM0DvBbE.png" /></figure><h3>11. R squared error</h3><p>To understand R² error we need to understand the <strong>Total Sum of Square (TSS)</strong>. TSS is basically the worst approximation line that you can create for your model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*wjl-KBV73wCwtj7h.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/0*etnxjSk3kyyfTCdW.png" /></figure><p><strong>Residual Sum of Squares (RSS) </strong>measures the difference between the expected and the actual values for the fitted line in linear regression.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/0*DN6YdQoh9Kts8DSt.png" /></figure><p>The R² value ranges between 0 and 1. The more the r-squared value is close to 1, the better is the model’s performance is.</p><h3>Interpretation of R squared error:</h3><p><strong>Case 1: R² = 1</strong></p><p>When SSR = 0 , when each and every ei = 0 =&gt; R² = 1</p><p>This is the ideal model, but in reality we would never encounter such a model.</p><p><strong>Case 2: R²&gt;0 and R² &lt;1</strong></p><p>When SSR &gt; SST</p><p>This is the typical case. More the value is close to 1, better the model is.</p><p><strong>Case 3: R² = 0</strong></p><p>When SSR = SST</p><p>This is the case when our model is a simple mean model.</p><p><strong>Case 4: R²&lt;0</strong></p><p>When SSR &gt; SST</p><p>In this case the model is worse than the simple mean model.</p><h3>12. Adjusted R square error</h3><p>Adjusted R square is an updated version of R-squared as it takes into account the number of independent variable while calculating R-squared.</p><p><strong>The disadvantage with the R squared metric is that as more and more predictors increase, the R-squared value also increases even though if the predive power is less. To overcome this, adjusted r-square is introduced which incurs a penalty for increasing the number of predictors. This helps to prevent overfitting. Also the value of adjusted R-squared increases only if the predictors contribute to the model meaningfully.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/0*zhtaDzBsQSs13PGz.png" /></figure><p>In summary, adjusted R-square is a more reliable measure of a models goodness of fit when considering the tradeoff between the complexity of the model (no. of predictors) and the predictive power. This metric is useful to access a model in cases when increasing the number of predictors would improve the performance of the model.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0f8574221c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DATA PREPROCESSING STEP IN NLP.]]></title>
            <link>https://medium.com/@nehra.vikas95/data-preprocessing-step-in-nlp-d5266a47ea26?source=rss-16e865297907------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5266a47ea26</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[text-preprocessing]]></category>
            <category><![CDATA[nlp-preprocessing]]></category>
            <dc:creator><![CDATA[Nehra Vikas]]></dc:creator>
            <pubDate>Fri, 19 Apr 2024 11:14:21 GMT</pubDate>
            <atom:updated>2024-04-19T11:14:21.262Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/370/0*LbMa4wKE9KN-aMGF" /></figure><p>we delve into the crucial data preprocessing steps essential for laying the groundwork for NLP tasks. While advancements in NLP have enabled the development of applications capable of perceiving and understanding human language, a critical prerequisite remains — preparing and supplying our machines with data in a format they can comprehend. This process involves a series of diverse and vital preprocessing steps.</p><p><strong>Here’s what to expect in this deep dive</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/361/0*nmZUnuftq6RUc2cL" /></figure><ol><li><strong>Tokenization and Text Cleaning:</strong> Discover the art of breaking down text into meaningful units and ensuring pristine, understandable language. This includes handling punctuation and refining the text for further processing.</li><li><strong>Stop Words Removal:</strong> Learn why removing certain words is essential for focusing on more meaningful content in the dataset.</li><li><strong>Stemming and Lemmatization: </strong>Dive into text normalization techniques, understanding when and how to use stemming or lemmatization to simplify words to their root forms.</li><li><strong>Part-of-Speech Tagging (POS):</strong> Explore how assigning grammatical categories to each word aids in a deeper understanding of sentence structure and context.</li><li><strong>Named Entity Recognition (NER):</strong> Uncover the role of NER in enhancing language understanding by identifying and classifying entities within the text.</li></ol><p>Each of these steps is a critical building block in translating raw text into a language that machines can comprehend, setting the stage for more advanced NLP tasks.</p><h3>1. Tokenization and Text Cleaning</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/0*Fy06ks5OqVdxehdb" /></figure><p>At the heart of NLP lies the art of breaking down text into meaningful units. <strong>Tokenization </strong>is the process of splitting text into words, phrases, or even sentences (tokens). It’s the initial step that sets the stage for further analysis. Coupled with text cleaning, where we remove unnecessary characters, numbers, and symbols, tokenization ensures we work with pristine, understandable language units.</p><pre>#!pip install nltk<br># Example Tokenization and Text Cleaning<br>text = &quot;NLP is amazing! Let&#39;s explore its wonders.&quot;<br>tokens = nltk.word_tokenize(text)<br>cleaned_tokens = [word.lower() for word in tokens if word.isalpha()]<br>print(cleaned_tokens)</pre><pre>[&#39;nlp&#39;, &#39;is&#39;, &#39;amazing&#39;, &#39;let&#39;, &#39;explore&#39;, &#39;its&#39;, &#39;wonders&#39;]</pre><h3>2. Stop Words Removing:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/0*kwQh8gw--7-Kqi5u" /></figure><p>Not all words contribute equally to the meaning of a sentence. Stop words like “the” or “and” are often filtered out to focus on more meaningful content.</p><pre># Example Stop Words<br>from nltk.corpus import stopwords<br>stop_words = set(stopwords.words(&quot;english&quot;))<br>filtered_sentence = [word for word in cleaned_tokens if word not in stop_words]<br>print(filtered_sentence</pre><pre>[&#39;nlp&#39;, &#39;amazing&#39;, &#39;let&#39;, &#39;explore&#39;, &#39;wonders&#39;]</pre><h3>3. Stemming and Lemmatizing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*i_4JTMDNizlJl1LF.png" /></figure><p>Stemming and lemmatization are both text normalization techniques used in Natural Language Processing (NLP) to reduce words to their base or root forms. While they share the goal of simplifying words, they operate differently in terms of the linguistic knowledge they apply.</p><p><strong>Stemming: Reducing to Root Forms</strong></p><p>Stemming involves cutting off prefixes or suffixes of words to obtain their root or base form, known as the stem. The purpose is to treat words with similar meanings as if they were the same. Stemming is a rule-based method that doesn’t always result in a valid word, but it’s computationally less intensive.</p><p><strong>Lemmatization: Transforming to Dictionary Form</strong></p><p>Lemmatization, on the other hand, involves reducing words to their base or dictionary forms, known as lemmas. It takes into account the context of the word in a sentence and applies morphological analysis. Lemmatization results in valid words and is more linguistically informed compared to stemming.</p><p><strong>When to Use Stemming vs. Lemmatization:</strong></p><p>Stemming:</p><ul><li>Pros: Simple and computationally less expensive.</li><li>Cons: May not always result in valid words.</li></ul><p>Lemmatization:</p><ul><li>Pros: Produces valid words; considers linguistic context.</li><li>Cons: More computationally intensive than stemming.</li></ul><p><strong>Choosing Between Stemming and Lemmatization:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/0*cMw4v09NOiD3ha9b.png" /></figure><p>The choice between stemming and lemmatization depends on the specific requirements of your NLP task. If you need a quick and straightforward method for text analysis, stemming might be sufficient. However, if linguistic accuracy is crucial, especially in tasks like information retrieval or question answering, lemmatization is often preferred.</p><p>In practice, the choice often depends on the trade-off between computational efficiency and linguistic accuracy based on the specific characteristics of your NLP application.</p><pre># Example Stemming, and Lemmatization <br>from nltk.stem import PorterStemmer, WordNetLemmatizer</pre><pre>stemmed_words = [stemmer.stem(word) for word in filtered_sentence]<br>lemmatized_words = [lemmatizer.lemmatize(word) for word in filtered_sentence]<br>print(stemmed_words)<br>print(lemmatized_words)</pre><pre>[&#39;nlp&#39;, &#39;amaz&#39;, &#39;let&#39;, &#39;explor&#39;, &#39;wonder&#39;]<br>[&#39;nlp&#39;, &#39;amazing&#39;, &#39;let&#39;, &#39;explore&#39;, &#39;wonder&#39;]</pre><h3>4. Part-of-Speech Tagging:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/0*VtZwkNJx8B0e4st6" /></figure><p>Part-of-speech tagging (POS tagging) is a natural language processing task where the goal is to assign a grammatical category (such as noun, verb, adjective, etc.) to each word in a given text. This provides a deeper understanding of the structure and function of each word in a sentence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CAuiXhgmHHQjq8s4.jpg" /></figure><pre># Example Part-of-Speech Tagging <br>from nltk import pos_tag<br>pos_tags = nltk.pos_tag(filtered_sentence)<br>print(pos_tags)</pre><pre>[(&#39;nlp&#39;, &#39;RB&#39;), (&#39;amazing&#39;, &#39;JJ&#39;), (&#39;let&#39;, &#39;NN&#39;), (&#39;explore&#39;, &#39;NN&#39;), (&#39;wonders&#39;, &#39;NNS&#39;)]</pre><h3>5. Named Entity Recognition (NER):</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FF8kxQHSv4T9GZZe.png" /></figure><p>NER takes language understanding to the next level by identifying and classifying entities like names, locations, organizations, etc., in a given text. This is crucial for extracting meaningful information from unstructured data.</p><pre># Example Named Entity Recognition (NER) <br>from nltk import ne_chunk</pre><pre>ner_tags = ne_chunk(pos_tags)<br>print(ner_tags)</pre><pre>(S nlp/RB amazing/JJ let/NN explore/NN wonders/NNS)</pre><h3>Real-World Applications of NLP Preprocessing Steps</h3><p>While we’ve delved into the technical aspects of NLP preprocessing, it’s equally important to understand how these steps are applied in real-world scenarios. Let’s explore some notable examples:</p><p><strong>Tokenization and Text Cleaning in Social Media Sentiment Analysis:<br></strong>In social media sentiment analysis, tokenization, and text cleaning are crucial. For instance, when analyzing tweets to gauge public sentiment about a new product, tokenization helps in breaking down tweets into individual words or phrases. Text cleaning is used to remove noise like hashtags, mentions, and URLs, which are common in social media text.</p><pre>import re<br>def clean_tweet(tweet):<br>    tweet = re.sub(r&#39;@\w+&#39;, &#39;&#39;, tweet)  # Remove mentions<br>    tweet = re.sub(r&#39;#\w+&#39;, &#39;&#39;, tweet)  # Remove hashtags<br>    tweet = re.sub(r&#39;http\S+&#39;, &#39;&#39;, tweet)  # Remove URLs<br>    return tweet</pre><pre>tweet = &quot;Loving the new #iPhone! Best phone ever! @Apple&quot;<br>clean_tweet(tweet)</pre><pre>&#39;Loving the new ! Best phone ever! &#39;</pre><p><strong>Stop Words Removal in Search Engines:</strong><br>Search engines extensively use stop word removal. When processing search queries, common words like ‘the’, ‘is’, and ‘in’ are often removed to focus on the keywords that are more likely to be relevant to the search results.</p><p><strong>Stemming and Lemmatization in Text Classification:<br></strong>News agencies and content aggregators often use stemming and lemmatization for text classification. By reducing words to their base or root forms, algorithms can more easily categorize news articles into topics like ‘sports’, ‘politics’, or ‘entertainment’.</p><p><strong>Part-of-Speech Tagging in Voice Assistants:</strong><br>Voice assistants like Amazon’s Alexa or Apple’s Siri use part-of-speech tagging to improve speech recognition and natural language understanding. By determining the grammatical context of words, these assistants can more accurately interpret user requests.</p><p><strong>Named Entity Recognition (NER) in Customer Support Automation:<br></strong>NER is widely used in customer support chatbots. By recognizing and classifying entities such as product names, locations, or user issues, chatbots can provide more effective and tailored responses to customer inquiries.</p><p>These examples highlight the practical implications of NLP preprocessing steps in various industries, making the abstract concepts more tangible and easier to grasp. Understanding these applications not only provides context but also inspires ideas for future projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5266a47ea26" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ADABOOST ALGORITHM]]></title>
            <link>https://medium.com/@nehra.vikas95/adaboost-algorithm-ef043e6104e0?source=rss-16e865297907------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef043e6104e0</guid>
            <category><![CDATA[adaboost-algorithm]]></category>
            <category><![CDATA[ensemble-learning]]></category>
            <category><![CDATA[adaboost]]></category>
            <dc:creator><![CDATA[Nehra Vikas]]></dc:creator>
            <pubDate>Tue, 16 Apr 2024 04:30:18 GMT</pubDate>
            <atom:updated>2024-04-16T04:30:18.633Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*8wVK16HGNOPn8O8O" /></figure><p>When it comes to ensemble models, there are two major techniques — bagging and boosting. In this blog we will discuss about boosting. There are 3 major boosting algorithms Adaboost, Gradient boost and XGBoost. We will see adaboost in the following blog.</p><p>We use boosting for combining <strong>weak learners</strong> with high bias. Boosting aims in producing a model with low bias and low variance. Boosting is sequential training of models whereas bagging involves parallel training of models. Boosting algorithm is designed in such a way that the its improves the errors of the previous learners in sequence. It works like, for the datapoints that are incorrectly classified, the corresponding weight increases. Thus more importance is given to the points in the next model/step such that the error decreases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*_YyhPs9lfCviaQJ5.png" /></figure><p>Now comes the question of what is a weak learner?</p><p>Weak learner is nothing but a model that perform slightly better than the random model. These models are generally high bias models. For instance if a weak learners accuracy is approx. 55% or 60% then random models accuracy would be 50%. With boosting technique our aim is to create a generalized model such that the resulting model will be of low bias and low variance. For boosting the baseline is basically learning from the mistakes.</p><p>To tell in a layman terms, I am the eldest child in my family. I get all the scolding from parents for doing something wrong. My younger sister is more cautious and learns from my mistakes and do things wisely. This is the same with boosting. In the sequential list of models, one model is always better than the previous model.</p><p>Now lets dive deep into Adaboost algorithm.</p><h3>AdaBoost Technique</h3><p>Adaboost = <strong>Ada</strong>ptive <strong>Boost</strong>ing. This algorithm is the very first algorithm in boosting techniques and has proven to be very effective. In adaboost we majorly used decision stumps as the weak learners. Here, the incorrectly classified points are punished by assigning a larger weight to them after each round of prediction. This way the algorithm is learning from the previous mistakes. The final prediction is the weighted majority vote.</p><p>There are three ideas behind the adaboost algorithm:</p><ol><li>AdaBoost combines a lot of “weak learners” to make classifications. The weak learners are almost always stumps.</li><li>Some stumps get more to say in classification than the others.</li><li>Each stump is made by taking the previous stumps mistakes into account.</li></ol><p>Now lets discuss the steps followed in adaboost:</p><ol><li>At the start all the samples get the same weight.</li></ol><p>Initial weight = 1/(total no. of samples)</p><p>2. Now to make the first stump, we need to calculate the information gain of all the features in the dataset. Whichever feature has the highest information gain we start by creating a stump for the same.</p><p>3. Now e need to calculate the total error.</p><p>Total error = sum of weights associated with all the misclassified samples.</p><p>4. Now we need to calculate the amount of say/performance of the stump. Amount of Say is basically how much that particular stump would contribute to the final classification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d8GOb8tMDpvQI9p8.png" /></figure><p>5. Now we need to modify the weight so that the next stump will take the errors that the current stump made into account. This is done by increasing the weight of the incorrectly classified sample so that in the next stump it is correctly classified. Also we decrease the weight of the correctly classified samples.</p><p>For incorrectly classified sample,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0iNc_FQYnDeoPFxK.png" /></figure><p>For correctly classified sample,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5ryqEF1qKJg6uf6Y.png" /></figure><p>6. Now we get the new sample weights. But when we add all the weights we wont get 1. So we need to normalize the weights.</p><p>7. We now need to create a new dataset with size equal to the size of the original datasets. Now how do we create a new one?</p><p>Pick a random number between 0 and 1 and we see where the number falls when we use the sample weights like a distribution. By this way the misclassified samples will be more likely to be present and the corresponding bucket size is more.</p><p>8. Again carry out the same step from step 1.</p><p>9. Finally when a test sample comes, we perform majority vote of all the decision stumps created.</p><p><strong>CODE OF ADABOOSTING CLASSIFIER</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/0*ruJEWEdXV6xo2b91.png" /></figure><p><strong>POINTS TO REMEMBER.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/0*vCPSt4z3Go_70aBH" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef043e6104e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DBSCAN(density based clustering).]]></title>
            <link>https://medium.com/@nehra.vikas95/dbscan-density-based-clustering-f8d34b79455c?source=rss-16e865297907------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8d34b79455c</guid>
            <category><![CDATA[dbscan]]></category>
            <dc:creator><![CDATA[Nehra Vikas]]></dc:creator>
            <pubDate>Sun, 14 Apr 2024 16:06:18 GMT</pubDate>
            <atom:updated>2024-04-14T16:06:18.337Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>DBSCAN</strong> stands for <strong>D</strong>ensity-<strong>B</strong>ased <strong>S</strong>patial <strong>C</strong>lustering of <strong>A</strong>pplications with <strong>N</strong>oise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/0*7Dr6Fws0G-JN2pzX.png" /></figure><p>It is a popular clustering algorithm used in data mining and machine learning. It is known for its ability to discover clusters of arbitrary shapes and sizes in a dataset, making it particularly useful in various real-world applications. In this article, we will delve into the intricacies of DBSCAN, exploring its underlying principles, implementation details, and practical examples.</p><ul><li><strong>IMPORTANT POINT TO REMEMBER.</strong></li><li><strong>Core Points</strong>: In DBSCAN, a core point is a data point that has at least a minimum number of other points within a specified radius (epsilon). These core points are indicative of dense regions in the dataset.</li><li><strong>Border Points</strong>: Border points are data points that are not core points themselves but are within the epsilon radius of a core point. They are considered part of the same cluster as the core point.</li><li><strong>Noise Points</strong>: Data points that are neither core points nor border points are classified as noise points or outliers. DBSCAN can effectively identify and disregard noise points during the clustering process.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/0*CKnYNOWWxI4IRDN5" /></figure><ul><li><strong>DBSCAN algorithm proceeds as follows:</strong></li></ul><ol><li><strong>Initialize</strong>: Specify the epsilon (eps) parameter and the minimum number of points (MinPts) required to form a cluster.</li><li><strong>Core Point Identification</strong>: Identify core points in the dataset by finding data points with at least <strong>MinPts neighbors </strong>within the epsilon radius.</li><li><strong>Cluster Expansion</strong>: Expand clusters by adding border points to them. A border point becomes part of the cluster if it is within the epsilon radius of a core point.</li><li><strong>Noise Point Detection</strong>: Identify noise points that do not belong to any cluster.</li></ol><ul><li><strong>The algorithm continues until all points are assigned to a cluster or classified as noise.</strong></li></ul><h3>Difference Between DBSCAN and K-Means.</h3><p>DBSCAN K-Means</p><p>1.In DBSCAN we need not specify the number of clusters.but in K-Means is very sensitive to the number of clusters so it need to specified.</p><p>2.Clusters formed in DBSCAN can be of any arbitrary shape. but in Clusters formed in K-Means are spherical or convex in shape</p><p>3.DBSCAN can work well with datasets having noise and outliers but K-Means does not work well with outliers data. Outliers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*txV73HIv6xluzZYZ.jpg" /></figure><p><strong>Advantages of DBSCAN:</strong></p><ul><li>Ability to handle clusters of arbitrary shapes: Unlike traditional clustering algorithms like K-means, DBSCAN can identify clusters with irregular shapes and sizes.</li><li>Robust to noise: DBSCAN is robust to outliers and noise in the dataset, as it does not rely on predefined cluster centers.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*NjzV9yOfLo7i55vt.jpg" /></figure><ul><li>Automatic determination of the number of clusters: DBSCAN automatically determines the number of clusters based on the data’s density distribution.</li></ul><p><strong>Practical Examples:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/0*sOJSxezhALEpYDtt.gif" /></figure><ul><li>Example 1: <strong>Customer Segmentation.</strong></li><li>Use DBSCAN to segment customers based on their purchasing behavior, identifying groups with similar preferences for targeted marketing campaigns.</li><li>Example 2: <strong>Anomaly Detection.</strong></li><li>Apply DBSCAN to detect anomalies in network traffic data, identifying unusual patterns or behaviors that may indicate security threats.</li><li>Example 3: <strong>Geographic Clustering.</strong></li><li>Use DBSCAN to cluster geographic locations based on proximity, identifying regions with similar characteristics or demographics.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8d34b79455c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[REGULARISATION (L1 ,L2)]]></title>
            <link>https://medium.com/@nehra.vikas95/regularisation-l1-l2-b5ae9f75e5b5?source=rss-16e865297907------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5ae9f75e5b5</guid>
            <dc:creator><![CDATA[Nehra Vikas]]></dc:creator>
            <pubDate>Tue, 09 Apr 2024 11:42:53 GMT</pubDate>
            <atom:updated>2024-04-09T11:42:53.379Z</atom:updated>
            <content:encoded><![CDATA[<h3>REGULARISATION (L1 ,L2)</h3><p><strong>Regularisation</strong> is a process of introducing additional information in order to prevent overfitting. The focus for this article is<strong> L1 and L2 regularisation.</strong></p><p>O<strong>verfitting</strong> is a phenomenon that occurs when a machine learning or statistics model is tailored to a particular dataset and is unable to generalise to other datasets. This usually happens in complex models, like deep neural networks.</p><p>Let’s go!</p><h3>What’s L1 and L2?</h3><p>L1 and L2 regularisation owes its name to L1 and L2 norm of a vector <strong><em>w </em></strong>respectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/0*bq3qy3W2R0hKidOm.png" /></figure><p>1-norm (also known as L1 norm)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/0*YKhL48GHjW6CX0rP.png" /></figure><p>2-norm (also known as L2 norm or Euclidean norm)</p><p>A linear regression model that implements L1 norm for regularisation is called <strong>lasso regression.</strong></p><p>one that implements (squared) L2 norm for regularisation is called <strong>ridge regression</strong>.</p><h3>Loss function with no regularisation</h3><p>We define the loss function L as the squared error, where error is the difference between <em>y</em> (the true value) and <em>ŷ </em>(the predicted value).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/0*inc3_twYzXseMg4a.png" /></figure><p>Let’s assume our model will be overfitted using this loss function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*DTUV0kCqmik4YiMV" /></figure><h3>Loss function with L1 regularisation</h3><p>Based on the above loss function, adding an L1 regularisation term to it looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/0*0w35oAAUaAs02K4k.png" /></figure><p>where the regularisation parameter <em>λ</em> &gt; 0 is manually tuned. Let’s call this loss function L1. Note that |<em>w| </em>is differentiable everywhere except when <em>w</em>=0, as shown below. We will need this later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/0*eWij711uePi983gY.png" /></figure><h3>Loss function with L2 regularisation</h3><p>Similarly, adding an L2 regularisation term to L looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*8LIn83MSiMgw-HvB.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5ae9f75e5b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>