<?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 Anuja Nagpal on Medium]]></title>
        <description><![CDATA[Stories by Anuja Nagpal on Medium]]></description>
        <link>https://medium.com/@anujanagpal?source=rss-defb8a4d5ef1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*G-d0-Oq670KQZBzJDGAJsQ.jpeg</url>
            <title>Stories by Anuja Nagpal on Medium</title>
            <link>https://medium.com/@anujanagpal?source=rss-defb8a4d5ef1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 28 May 2026 17:08:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anujanagpal/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[Principal Component Analysis- Intro]]></title>
            <link>https://medium.com/data-science/principal-component-analysis-intro-61f236064b38?source=rss-defb8a4d5ef1------2</link>
            <guid isPermaLink="false">https://medium.com/p/61f236064b38</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[dimensionality-reduction]]></category>
            <dc:creator><![CDATA[Anuja Nagpal]]></dc:creator>
            <pubDate>Tue, 21 Nov 2017 17:53:31 GMT</pubDate>
            <atom:updated>2017-11-22T01:27:39.019Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cTec2mXxUcoyDoTk13vevg.jpeg" /></figure><h4>Variable Reduction Technique</h4><blockquote>Too many variables? Should you be using all possible variables to generate model?</blockquote><p>In order to handle “curse of dimensionality” and avoid issues like over-fitting in high dimensional space, methods like Principal Component analysis is used.</p><p>PCA is a method used to reduce number of variables in your data by extracting important one from a large pool. It reduces the dimension of your data with the aim of retaining as much information as possible. In other words, this method combines highly correlated variables together to form a smaller number of an artificial set of variables which is called “principal components” that account for most variance in the data.</p><p>Let’s dive in to understand how to PCA is implemented behind the scene.</p><p><strong><em>Start</em></strong> by normalizing the predictors by subtracting the mean from each data point. It is important to normalize the predictor as original predictors can be on the different scale and can contribute significantly towards variance. The result will look like table 2 with a mean of zero.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*yffTLw7LRoDgJPzSB-aL1A.png" /><figcaption>Normalized Data</figcaption></figure><p><strong>Next</strong>, calculate the covariance matrix for the data which would measure how two predictors move together. It is measured between two predictors but if you have 3-dimensional data (x, x1, x2), then measure the covariance between x x1, x x2, x1 x2. For reference covariance formula is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/252/1*vYlPM9CL1aGpO8VNPs1Zmg.png" /></figure><p>In our case covariance matrix would look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*lSF7qhTkw4O-JsN4YgYqvw.png" /><figcaption>Covariance Matrix</figcaption></figure><p><strong>Now</strong>, calculate Eigen values and Eigen vector of the above matrix. This helps in finding underlying patterns in the data. In our case it would be approximately:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/1*4W39v2-lwPlUFpQrs-0OZg.png" /><figcaption>Eigen Value and Vector</figcaption></figure><p>We are almost there :). Perform reorientation. To convert the data into new axes multiply original data with eigenvectors, which suggests the direction of new axes. Note, that you can choose to leave out smaller eigen vector or use both. Also, decide how many set of features to keep based on which set accounts for 95% or more variance.</p><p><strong>Finally,</strong> the scores calculated from above step can be plotted and and fed into the predictive model. Plots gives us the sense of how close/highly correlated two variables are. Instead of using original data to plot X and Y axis which doesn’t tell us much how points are related to each other, we plot transformed data (using eigen vectors) that find patterns and shows the relationships between points.</p><p><em>End Note</em>: It is easy to confuse <em>PCA</em> with <em>Factor Analysis</em> but there is a conceptual difference between these two methods. I will be going into details of <em>Factor Analysis</em> and how it is different from <em>PCA </em>in my next post.. stay tuned.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61f236064b38" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/principal-component-analysis-intro-61f236064b38">Principal Component Analysis- Intro</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Machine Learning Quick Reference Card]]></title>
            <link>https://medium.com/data-science/machine-learning-quick-reference-card-cf92f6accd08?source=rss-defb8a4d5ef1------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf92f6accd08</guid>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[cheatsheet]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[quick-reads]]></category>
            <dc:creator><![CDATA[Anuja Nagpal]]></dc:creator>
            <pubDate>Fri, 03 Nov 2017 16:48:17 GMT</pubDate>
            <atom:updated>2017-11-04T08:59:27.094Z</atom:updated>
            <content:encoded><![CDATA[<h4>Supervised and Unsupervised Machine Learning</h4><p>In my last few <a href="https://medium.com/@anujanagpal">posts</a>, I had discussed few algorithms that I implement frequently at my work. However, the most important question is when to use these algorithms. There is no one right way of doing things. You play with different algorithms and see which one works best in your case by doing model comparisons.</p><p>However, having a quick reference card helps narrow down the options and in making the decision. That also means that this reference card makes some generalizations/simplifications, but it points you towards the right direction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WwkA_1qFN945ZtA4_MXP1Q.png" /></figure><p>You can download this reference card <a href="https://drive.google.com/file/d/0Bw3chZyB9zlvV29DWnFQTFYyaEYyc29IYUxNSm96cUVweHFZ/view?usp=sharing">here.</a></p><p>Hope you enjoyed this post. Stay tuned for next posts to learn more on Machine learning basics.</p><p>Happy Learning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf92f6accd08" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/machine-learning-quick-reference-card-cf92f6accd08">Machine Learning Quick Reference Card</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clustering — Unsupervised Learning]]></title>
            <link>https://medium.com/data-science/clustering-unsupervised-learning-788b215b074b?source=rss-defb8a4d5ef1------2</link>
            <guid isPermaLink="false">https://medium.com/p/788b215b074b</guid>
            <category><![CDATA[clustering]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[unsupervised-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[analytics]]></category>
            <dc:creator><![CDATA[Anuja Nagpal]]></dc:creator>
            <pubDate>Thu, 02 Nov 2017 21:18:11 GMT</pubDate>
            <atom:updated>2017-11-05T14:31:02.097Z</atom:updated>
            <content:encoded><![CDATA[<h4>Machine Learning</h4><blockquote><strong><em>What is Clustering?</em></strong></blockquote><p>“Clustering” is the process of grouping similar entities together. The goal of this unsupervised machine learning technique is to find similarities in the data point and group similar data points together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HGxubBB0IKpNKW0Odo7lhw.gif" /></figure><blockquote><strong>Why use Clustering?</strong></blockquote><p>Grouping similar entities together help profile the attributes of different groups. In other words, this will give us insight into underlying patterns of different groups. There are many applications of grouping unlabeled data, for example, you can identify different groups/segments of customers and market each group in a different way to maximize the revenue. Another example is grouping documents together which belong to the similar topics etc. <br>Clustering is also used to reduces the dimensionality of the data when you are dealing with a copious number of variables.</p><blockquote><strong>How does Clustering algorithms work?</strong></blockquote><p>There are many algorithms developed to implement this technique but for this post, let’s stick the most popular and widely used algorithms in machine learning.</p><ol><li>K-mean Clustering</li></ol><p>2. Hierarchical Clustering</p><h4>K-mean Clustering</h4><ol><li>It starts with K as the input which is how many clusters you want to find. Place K centroids in random locations in your space.</li><li>Now, using the euclidean distance between data points and centroids, assign each data point to the cluster which is close to it.</li><li>Recalculate the cluster centers as a mean of data points assigned to it.</li><li>Repeat 2 and 3 until no further changes occur.</li></ol><p><strong><em>Now, you might be thinking that how do I decide the value of K in the first step.</em></strong></p><p>One of the methods is called “<strong>Elbow</strong>” method can be used to decide an optimal number of clusters. Here you would run K-mean clustering on a range of K values and plot the “<em>percentage of variance explained</em>” on the Y-axis and “<em>K</em>” on X-axis.</p><p>In the picture below you would notice that as we add more clusters after 3 it doesn&#39;t give much better modeling on the data. The first cluster adds much information, but at some point, the marginal gain will start dropping.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/359/1*byeya_Btqm6Yszpg7CcLjA.png" /><figcaption>Elbow Method</figcaption></figure><h4><strong>Hierarchical Clustering</strong></h4><p>Unlike K-mean clustering <em>Hierarchical </em>clustering starts by assigning all data points as their own cluster. As the name suggests it builds the hierarchy and in the next step, it combines the two nearest data point and merges it together to one cluster.</p><p>1. Assign each data point to its own cluster.</p><p>2. Find closest pair of cluster using euclidean distance and merge them in to single cluster.</p><p>3. Calculate distance between two nearest clusters and combine until all items are clustered in to a single cluster.</p><p>In this technique, you can decide the optimal number of clusters by noticing which vertical lines can be cut by horizontal line without intersecting a cluster and covers the maximum distance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*vwMwG1ooqt7BuFBievZtkQ.png" /><figcaption><strong>Dendogram</strong></figcaption></figure><blockquote><strong>Things to remember when using clustering algorithm:</strong></blockquote><ul><li>Standardizing variables so that all are on the same scale. It is important when calculating distances.<br>• Treat data for outliers before forming clusters as it can influence the distance between the data points.</li></ul><p>If you learnt something from this article then please ❤ click below so other people will see this on Medium.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=788b215b074b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/clustering-unsupervised-learning-788b215b074b">Clustering — Unsupervised Learning</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decision Tree Ensembles- Bagging and Boosting]]></title>
            <link>https://medium.com/data-science/decision-tree-ensembles-bagging-and-boosting-266a8ba60fd9?source=rss-defb8a4d5ef1------2</link>
            <guid isPermaLink="false">https://medium.com/p/266a8ba60fd9</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ensemble-learning]]></category>
            <category><![CDATA[decision-tree]]></category>
            <category><![CDATA[gradient-boosting]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Anuja Nagpal]]></dc:creator>
            <pubDate>Tue, 17 Oct 2017 20:35:36 GMT</pubDate>
            <atom:updated>2017-10-18T02:06:26.985Z</atom:updated>
            <content:encoded><![CDATA[<h4>Random Forest and Gradient Boosting</h4><p>We all use Decision Tree technique on daily basis to plan our life, we just don’t give a fancy name to those decision-making process.</p><p>Businesses use these supervised machine learning techniques like Decision trees to make better decisions and make more profit. Decision trees have been around for a long time and also known to suffer from bias and variance. You will have a large bias with simple trees and a large variance with complex trees.</p><p><strong><em>Ensemble methods</em></strong>, which combines several decision trees to produce better predictive performance than utilizing a single decision tree. The main principle behind the ensemble model is that a group of weak learners come together to form a strong learner.</p><p>Let’s talk about few techniques to perform ensemble decision trees:</p><p>1. Bagging</p><p>2. Boosting</p><blockquote><strong><em>Bagging </em></strong>(Bootstrap Aggregation) is used when our goal is to reduce the variance of a decision tree. Here idea is to create several subsets of data from training sample chosen randomly <em>with replacement</em>. Now, each collection of subset data is used to train their decision trees. As a result, we end up with an ensemble of different models. Average of all the predictions from different trees are used which is more robust than a single decision tree.</blockquote><p><strong><em>Random Forest</em></strong> is an extension over bagging. It takes one extra step where in addition to taking the random subset of data, it also takes the random selection of features rather than using all features to grow trees. When you have many random trees. It’s called Random Forest 😊</p><p>Let’s look at the steps taken to implement Random forest:</p><p><strong>1</strong>. Suppose there are N observations and M features in training data set. First, a sample from training data set is taken randomly with replacement.</p><p><strong>2</strong>. A subset of M features are selected randomly and whichever feature gives the best split is used to split the node iteratively.</p><p><strong>3</strong>. The tree is grown to the largest.</p><p><strong>4</strong>. Above steps are repeated and prediction is given based on the aggregation of predictions from n number of trees.</p><p><strong>Advantages of using Random Forest technique:</strong></p><ul><li>Handles higher dimensionality data very well.</li><li>Handles missing values and maintains accuracy for missing data.</li></ul><p><strong>Disadvantages of using Random Forest technique:</strong></p><ul><li>Since final prediction is based on the mean predictions from subset trees, it won’t give precise values for the regression model.</li></ul><blockquote><strong>Boosting</strong> is another ensemble technique to create a collection of predictors. In this technique, learners are learned sequentially with early learners fitting simple models to the data and then analyzing data for errors. In other words, we fit consecutive trees (random sample) and at every step, the goal is to solve for net error from the prior tree.</blockquote><p>When an input is misclassified by a hypothesis, its weight is increased so that next hypothesis is more likely to classify it correctly. By combining the whole set at the end converts weak learners into better performing model.</p><p><strong>Gradient Boosting</strong> is an extension over boosting method.</p><blockquote>Gradient Boosting= Gradient Descent + Boosting.</blockquote><p>It uses gradient descent algorithm which can optimize any differentiable loss function. An ensemble of trees are built one by one and individual trees are summed sequentially. Next tree tries to recover the loss (difference between actual and predicted values).</p><p><strong>Advantages of using Gradient Boosting technique:</strong></p><ul><li>Supports different loss function.</li><li>Works well with interactions.</li></ul><p><strong>Disadvantages of using Gradient Boosting technique:</strong></p><ul><li>Prone to over-fitting.</li><li>Requires careful tuning of different hyper-parameters</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=266a8ba60fd9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/decision-tree-ensembles-bagging-and-boosting-266a8ba60fd9">Decision Tree Ensembles- Bagging and Boosting</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[L1 and L2 Regularization Methods]]></title>
            <link>https://medium.com/data-science/l1-and-l2-regularization-methods-ce25e7fc831c?source=rss-defb8a4d5ef1------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce25e7fc831c</guid>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Anuja Nagpal]]></dc:creator>
            <pubDate>Fri, 13 Oct 2017 16:08:37 GMT</pubDate>
            <atom:updated>2017-10-14T00:22:03.792Z</atom:updated>
            <content:encoded><![CDATA[<p>Machine Learning</p><p>In my last <a href="https://medium.com/@anujanagpal/over-fitting-and-regularization-64d16100f45c">post</a>, I covered the introduction to Regularization in supervised learning models. In this post, let’s go over some of the regularization techniques widely used and the key difference between those.</p><p>In order to create less complex (parsimonious) model when you have a large number of features in your dataset, some of the Regularization techniques used to address over-fitting and feature selection are:</p><p>1.<strong> L1 Regularization</strong></p><p>2.<strong> L2 Regularization</strong></p><p>A regression model that uses L1 regularization technique is called <strong><em>Lasso Regression</em></strong> and model which uses L2 is called <strong><em>Ridge Regression</em></strong>.</p><p><em>The key difference between these two is the penalty term.</em></p><p><strong>Ridge regression</strong> adds “<em>squared magnitude</em>” of coefficient as penalty term to the loss function. Here the <em>highlighted</em> part represents L2 regularization element.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/243/1*jgWOhDiGjVp-NCSPa5abmg.png" /><figcaption>Cost function</figcaption></figure><p>Here, if <em>lambda</em> is zero then you can imagine we get back OLS. However, if <em>lambda</em> is very large then it will add too much weight and it will lead to under-fitting. Having said that it’s important how <em>lambda</em> is chosen. This technique works very well to avoid over-fitting issue.</p><p><strong>Lasso Regression</strong> (Least Absolute Shrinkage and Selection Operator) adds “<em>absolute value of magnitude</em>” of coefficient as penalty term to the loss function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*4MlW1d3xszVAGuXiJ1U6Fg.png" /><figcaption>Cost function</figcaption></figure><p>Again, if <em>lambda</em> is zero then we will get back OLS whereas very large value will make coefficients zero hence it will under-fit.</p><p>The <strong>key difference</strong> between these techniques is that Lasso shrinks the less important feature’s coefficient to zero thus, removing some feature altogether. So, this works well for <strong>feature selection</strong> in case we have a huge number of features.</p><p>Traditional methods like cross-validation, stepwise regression to handle overfitting and perform feature selection work well with a small set of features but these techniques are a great alternative when we are dealing with a large set of features.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce25e7fc831c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/l1-and-l2-regularization-methods-ce25e7fc831c">L1 and L2 Regularization Methods</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Over-fitting and Regularization]]></title>
            <link>https://medium.com/data-science/over-fitting-and-regularization-64d16100f45c?source=rss-defb8a4d5ef1------2</link>
            <guid isPermaLink="false">https://medium.com/p/64d16100f45c</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[analytics]]></category>
            <dc:creator><![CDATA[Anuja Nagpal]]></dc:creator>
            <pubDate>Wed, 11 Oct 2017 17:42:43 GMT</pubDate>
            <atom:updated>2017-10-13T17:11:37.155Z</atom:updated>
            <content:encoded><![CDATA[<p>Machine Learning</p><p>In supervised machine learning, models are trained on a subset of data aka training data. The goal is to compute the target of each training example from the training data.</p><p>Now, overfitting happens when model learns signal as well as noise in the training data and wouldn’t perform well on new data on which model wasn’t trained on. In the example below, you can see underfitting in first few steps and overfitting in last few.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*u2MTHaUPMJ8rkTYjm2nHww.gif" /></figure><p>Now, there are few ways you can avoid overfitting your model on training data like cross-validation sampling, reducing number of features, pruning, regularization etc.</p><p>Regularization basically adds the penalty as model complexity increases. Regularization parameter (lambda) penalizes all the parameters except intercept so that model generalizes the data and won’t overfit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*-kA1uR2nBKf_1rsrKLFfkQ.png" /><figcaption>Regularization in cost function</figcaption></figure><p>In above gif as the complexity is increasing, regularization will add the penalty for higher terms. This will decrease the importance given to higher terms and will bring the model towards less complex equation.</p><p>Stay tuned for the next post which will cover the different type of regularization techniques.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64d16100f45c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/over-fitting-and-regularization-64d16100f45c">Over-fitting and Regularization</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>