<?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 Shafil Ahamed on Medium]]></title>
        <description><![CDATA[Stories by Shafil Ahamed on Medium]]></description>
        <link>https://medium.com/@shafil.me?source=rss-8dac2e5ea825------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*2Mky8mW7PeIvKwVX8K5NDA.jpeg</url>
            <title>Stories by Shafil Ahamed on Medium</title>
            <link>https://medium.com/@shafil.me?source=rss-8dac2e5ea825------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 07:07:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shafil.me/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[Which evaluation metric should you choose for evaluating your Classification and Regression models?]]></title>
            <link>https://medium.com/almabetter/which-evaluation-metric-should-you-choose-for-evaluating-your-classification-and-regression-models-1df8237f9a24?source=rss-8dac2e5ea825------2</link>
            <guid isPermaLink="false">https://medium.com/p/1df8237f9a24</guid>
            <category><![CDATA[root-mean-squared-error]]></category>
            <category><![CDATA[precision]]></category>
            <category><![CDATA[recall]]></category>
            <category><![CDATA[r-squared]]></category>
            <category><![CDATA[mean-squared-error]]></category>
            <dc:creator><![CDATA[Shafil Ahamed]]></dc:creator>
            <pubDate>Thu, 16 Sep 2021 22:07:47 GMT</pubDate>
            <atom:updated>2021-09-17T08:40:55.583Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*Ae6Y7GunyNaOHpXz3l3EsA.png" /><figcaption>Source: <a href="https://ec.europa.eu/social/main.jsp?langId=en&amp;catId=1174&amp;furtherNews=yes&amp;newsId=9348">https://ec.europa.eu/social/main.jsp?langId=en&amp;catId=1174&amp;furtherNews=yes&amp;newsId=9348</a></figcaption></figure><p>When it comes to evaluating your model’s performance there are different metrics that you can choose from. To choose the best evaluation metric to assess your model, it is necessary that you understand the advantages and disadvantages of each and every metric. As a Data Scientist, you might have come across statements like <strong>your model is extremely accurate but depending on the business problem your model is not performing up to the mark</strong>, in such cases maybe be you should go with a different metric.</p><h3><strong>Classification</strong></h3><p>Let us first look into the evaluation metrics used in classification models. Here we will not only get to know the metrics we will also see which ones are used in a specific business problem.</p><p>For a classification-based model, all the parameters are included inside a metric called <strong>Confusion Matrix</strong>.</p><p>A Confusion matrix is an M x M matrix used for assessing the performance of a classification model, where M is the number of predicted classes. The matrix compares the actual predicted values with those predicted by our classification model. This gives us a comprehensive view of how well our classification model is performing and what kind of metric is reliable.</p><p>Since we will be looking at binary classification, let us take a 2 x 2 matrix as shown below with 4 values:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*YLuQ4GZogyh8dUh8oK5Jqw.png" /><figcaption>source: <a href="https://stats.stackexchange.com/questions/116585/confusion-matrix-of-classification-rules">https://stats.stackexchange.com/questions/116585/confusion-matrix-of-classification-rules</a></figcaption></figure><p>Here <strong>‘Actual Class’</strong> is what actually happened and <strong>‘Predicted Class’</strong> is what my model predicted. Now let me explain the diagram with a realistic example. Let us imagine a classification model that predicts whether it will <strong>rain or not rain</strong>. ‘Rain’ is a positive class and ‘Not rain’ is a negative class. <strong>True positive (TP)</strong> is when my model predicts Rain and it actually rains. <strong>True Negative (TN)</strong> is when my model predicts Not Rain and it doesn&#39;t rain in real. Whereas <strong>False Positive (FP)</strong> is when my model predicts a positive class(Rain) but it turns out to be false and it doesn&#39;t rain. Similarly, <strong>False Negative (FN)</strong> is when my model predicts a negative class ( Not Rain) but it rains on that day.</p><p>Based on these four parameters we will define evaluation metrics like Accuracy, Recall, Precision, and F1_Score.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*ZrCk9fJHra1AR6k1pGwjFw.png" /><figcaption>Source: <a href="https://stats.stackexchange.com/questions/116585/confusion-matrix-of-classification-rules">https://stats.stackexchange.com/questions/116585/confusion-matrix-of-classification-rules</a></figcaption></figure><h4><strong>ACCURACY</strong></h4><p>In very simple terms accuracy is an evaluation metric that measures the total number of predictions that my model got right out of the total number of predictions it made. In terms of confusion matrix, the formula for accuracy is :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*BVUXZfcoo9hlqFNS-09nwg.png" /><figcaption>source: <a href="https://medium.com/@erika.dauria/accuracy-recall-precision-80a5b6cbd28d">https://medium.com/@erika.dauria/accuracy-recall-precision-80a5b6cbd28d</a></figcaption></figure><p>Accuracy takes into account both True positives and True negatives, many a time we might need any one of them, for which there are other metrics defined. Every term in the formula of Accuracy is present in the confusion matrix and we can calculate it accordingly. Many a time the model built is fairly accurate but it still can’t solve a business problem. Such cases arise when we have an imbalanced dataset i.e. a dataset that has a majority of observations in the positive class and very few observations in the negative class and vice versa.</p><p>For example, you build a model to predict if the email you got is spam or not. In this case, 1 maybe 2 emails out of 100 that you get, turn out to be spam. So if you build a model which shows all mails are legitimate you will still achieve an accuracy of 98% but it will neglect all the spam emails and the model does not work in any way. When accuracy is not a good metric to evaluate your model you need to look at other metrics.</p><h4><strong>PRECISION</strong></h4><p>In very simple terms precision measures how precisely a model predicts the positive labels. In other words, out of all the positive predictions how many were correctly predicted. The formula for precision is given below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*0AEAX2BxJluajn90O--RxA.png" /><figcaption>source: <a href="https://medium.com/@erika.dauria/accuracy-recall-precision-80a5b6cbd28d">https://medium.com/@erika.dauria/accuracy-recall-precision-80a5b6cbd28d</a></figcaption></figure><p>The numerator of this formulae essentially tells us the positive observations that my model predicts correctly. The denominator essentially shows all the points that my models predicted as positive.</p><h4><strong>RECALL</strong></h4><p>Also known as true positive rate(TPR) or Sensitivity, recall can be defined as out of all the actual positive values, how many of them were predicted correctly. The formula for the recall is given below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*Q6SPtx9H0y0OwKf6mFdV1g.png" /><figcaption>Source: <a href="https://medium.com/@erika.dauria/accuracy-recall-precision-80a5b6cbd28d">https://medium.com/@erika.dauria/accuracy-recall-precision-80a5b6cbd28d</a></figcaption></figure><p>The numerator is the same as precision. but the denominator has all the actual positive values irrespective of which class the model predicted it to.</p><p>Now let me give explain to you both precision and recall in realistic terms to get a better intuition. Imagine your friend gives you a present at every birthday for the past 10 years. In the 11th year she makes a bet, she says that I will give you your favorite PlayStation if you can correctly guess all the 10 presents that I gave you over the course of 10 years. Now you really want PlayStation so you try hard to <strong>recall </strong>each present one by one. Suppose you were able to recall 7 presents out of 10, therefore you have a recall of 7/10 i.e. 70 %. Now to further the bet she says okay you try to guess the other presents you can take infinite guesses. you try your best and were able to name all 10 presents in 20 tries. Though this makes your recall as 100% you were not <strong>precise </strong>enough, your <strong>Precision </strong>gets as low as 10/20 i.e. 50%. Hope this gives more clarity on both the terms.</p><h4>How do you choose between precision and recall for your business problem?</h4><p>The best explanation for this is to choose <strong>Precision when your False-positives cost you more than your False-negatives</strong>. For example imagine you sell gym products, your invest in a brand of protein supplements as suggested by your ML model. But it turns out that you got a false positive signal and your customers hate the supplement and you incur a huge loss. Any business problem which involves investing in your output prediction such as giving loans, customer churn analysis, other banking systems you use <strong>Precision</strong>.</p><p>Now imagine you have to deploy a model in the health sector, detecting cancer in patients. Here if you get any false negatives i.e. you get a prediction that the patient doesn&#39;t have cancer whereas, in reality, he has cancer, in this case, his life is at risk because of wrong predictions. <strong>So any business problem where a False-negative can cost you more than a False-positive you use Recall</strong>. Other places that you can use recall are credit card fraud prediction, all healthcare domains, etc.</p><p>What happens if your data has class imbalance but you cant choose between precision and recall as both hold equal importance. In such cases, you go for an amalgamation of both, there is a metric that combines both precision and recall and is named f1_score.</p><p><strong>F1_score also known as F Measure </strong>is the harmonic mean of both precision and recall. F1 score can be calculated using the following formula.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*l6kChXQSMC_ahLDoPio20Q.png" /></figure><h3>REGRESSION</h3><p>Evaluation metrics play a very significant role in building any machine learning model. The Mean squared error, root mean squared error, mean absolute error, R-Squared, and Adjusted R-squared are used to evaluate the performance of the model in regression algorithms.</p><p><strong>Mean Squared Error(MSE) </strong>measures the arithmetic mean of the squared difference between the actual and predicted values in the dataset. It is a measure of the variance of residuals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/253/1*QrjZBfBOWLKkhtt_6KYHig.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*UgcNAOcInO3BhqvaoTP1SQ.png" /></figure><p><strong>Mean absolute error(MAE)</strong> measures the arithmetic mean of the absolute difference between the actual and the predicted values in the dataset. It measures the average of residuals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/255/1*nFGg2hyuRgIafo66c0D0VQ.png" /></figure><p><strong>Root Mean Squared Error(RMSE)</strong> is nothing but the square root of the mean squared error that we calculated earlier. It measures the root of variance i.e. standard deviation of residuals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*iEc3eda4s_K5aLDKVIaGCw.png" /></figure><p><strong>R-squared </strong>measures the degree to which variance in the dependent variable can be explained by the independent variables(features). It will always range from 0 to 1, the higher the R-squared better is my model. It is a relative metric that can be used to compare when we apply more than one algorithm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/0*Q2kREYwDCulazh8O.png" /></figure><p><strong>Adjusted R squared</strong> is a slight modification to the R-square value, this measures the variance in the target variable, explained by only the features that are helpful in making predictions, it will always be less than or equal to R² because it will penalize you for adding features which are not useful in making predictions. In the formula below <strong>n</strong> is the number of rows in the data and <strong>k</strong> is the number of columns in the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/262/0*eMBdeYzdnDpRovF-.png" /></figure><h4>What to choose between MSE, RMSE, MAE, and MAPE?</h4><blockquote>Whenever you have to penalize the outliers present in the dataset you use either MSE or RMSE. I personally prefer RMSE over MSE as the latter does not have the same unit as my predicted value.</blockquote><blockquote>Use MAE when your predictions do not get affected by outliers as MAE is robust to outliers.</blockquote><blockquote>RMSE and MSE both are differentiable and are generally chosen over MAE, as MAE is not differentiable when <strong>actual value = predicted value.</strong></blockquote><blockquote>Whenever your mean predicted values are large(in thousands or millions), choose MAPE(mean absolute percentage error) over the others as very large error values might look misleading.</blockquote><blockquote>R-Squared is a relative metric and should be preferred to compare models when we apply more than one algorithm.</blockquote><blockquote>Both R-Squared and the Error metrics hold important information, as the former tells us the relationship between independent and dependent variables and the latter tells us about how close are actual and predicted values.</blockquote><h4>CONCLUSION</h4><p>We often make the mistake of randomly applying these evaluation metrics to access our model’s performance, but data science is all about asking the question “why?”.That is exactly what we should be doing while choosing certain evaluation metrics over others. With this blog, I hope I am able to clear the intuitions between different evaluation metrics used in classification as well as regression analysis.</p><p>Happy Learning!</p><p>References:</p><ul><li><a href="https://medium.com/analytics-vidhya/mae-mse-rmse-coefficient-of-determination-adjusted-r-squared-which-metric-is-better-cd0326a5697e">MAE, MSE, RMSE, Coefficient of Determination, Adjusted R Squared — Which Metric is Better?</a></li><li><a href="https://www.theanalysisfactor.com/assessing-the-fit-of-regression-models/">Measures of Model Fit for Linear Regression Models</a></li><li><a href="https://www.statology.org/rmse-vs-r-squared/">RMSE vs. R-Squared: Which Metric Should You Use?</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1df8237f9a24" width="1" height="1" alt=""><hr><p><a href="https://medium.com/almabetter/which-evaluation-metric-should-you-choose-for-evaluating-your-classification-and-regression-models-1df8237f9a24">Which evaluation metric should you choose for evaluating your Classification and Regression models?</a> was originally published in <a href="https://medium.com/almabetter">AlmaBetter</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recommender Systems — The most valued application of machine learning.]]></title>
            <link>https://medium.com/almabetter/recommender-systems-the-most-valued-application-of-machine-learning-cf85aedefa32?source=rss-8dac2e5ea825------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf85aedefa32</guid>
            <category><![CDATA[recommendation-system]]></category>
            <category><![CDATA[content-filtering]]></category>
            <category><![CDATA[collaborative-filtering]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[cold-start]]></category>
            <dc:creator><![CDATA[Shafil Ahamed]]></dc:creator>
            <pubDate>Thu, 02 Sep 2021 20:35:00 GMT</pubDate>
            <atom:updated>2021-09-03T06:13:50.125Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Recommender Systems — The most valued application of machine learning.</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RbUFMnB4D2d_aeNigp4fTA.png" /><figcaption>source: <a href="https://blog.statsbot.co/recommendation-system-algorithms-ba67f39ac9a3">https://blog.statsbot.co/recommendation-system-algorithms-ba67f39ac9a3</a></figcaption></figure><p>Recommender systems are machine learning algorithms that help customers discover <strong>new products and services</strong>. Every time you browse online for either shopping or watching content, a recommendation system is guiding you towards the potential item you might purchase or watch. They are so widely used now that many of us benefit from them without even knowing. We can’t possibly look through all the products or content on a website, this is where the recommendation system comes into play by giving us a better search experience, while also showing us many more products we might not discover otherwise.</p><p>In 2006 Netflix famously offered a prize to solve a simple problem that had been around for years all online. Commerce giants are fighting to get better at solving this same problem given observations of a user’s past behavior predict which other things that the same user will like, for example, based on a person’s <strong>viewing history</strong> will she like the matrix or star wars.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*vlcXuQffW2E_7XA77Umfpw.png" /><figcaption>source: <a href="https://www.youtube.com/watch?v=n3RKsY2H-NE">https://www.youtube.com/watch?v=n3RKsY2H-NE</a></figcaption></figure><p>We can represent user preferences graphically as connections between people on one side and things on the other such as movies here, <strong>the strength of the connection is visually represented by the thickness of the lines</strong> so the problem is to fill out all of these missing connections we don’t yet know shown in red, but because of the messy unpredictable nature of people’s tastes, we can never perfectly predict what they will like because for one it involves a guess about the future based on something you’ve never seen and two the answer is always in flux because people’s tastes change over time. What we can do is try to estimate those values as best we can be using whatever data we have access to. So regardless of the context, we can describe the problem in the following mathematical form.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*D-plw760R2YdVWEMyWOeHg.png" /><figcaption>source: <a href="https://medium.com/@bhawna7374/movie-recommendation-system-with-neural-networks-and-collaborative-filtering-explicit-feedback-d2afaafef350">https://medium.com/@bhawna7374/movie-recommendation-system-with-neural-networks-and-collaborative-filtering-explicit-feedback-d2afaafef350</a></figcaption></figure><p>We use a matrix which is a collection of numbers organized into rows and columns where the rows are users and the columns are items. In this case movies and each cell in this matrix contains a number that describes how much each individual likes each movie for example we could use a scale from 0 to 5 where a 0 would represent I hate it 2 is neutral and 5 as I love it. At any given moment there will be some set of preference data for users and movies but it will be incomplete because users have only seen and rated a few movies each and so the problem boils down to trying to predict these missing values how should we make these predictions.</p><p><strong>There are two general approaches to this problem the first is called :</strong></p><p><strong>Content filtering</strong> is to use the information we know about people in things as connective tissue for recommendations. It’s like asking a person questions about what kinds of movies she likes to figure out if she will like the matrix. It begins by labeling each person and movies with some known attributes or what we call features,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*9Yaxe8ZFWqvpEmuizmj9EQ.png" /><figcaption>source: <a href="https://www.youtube.com/watch?v=n3RKsY2H-NE">https://www.youtube.com/watch?v=n3RKsY2H-NE</a></figcaption></figure><p>for example, action and comedy that means if a person likes comedy and hates action we can represent her as 3 0 each movie is also mapped to each feature in the same way, for example, that matrix has no comedy and lots of action so we could represent it as 0 4 and to determine whether someone will like a movie we need to multiply these factors together so we could represent the strength of the connection between the user and the matrix as 3 times 0 plus 0 times 4 equals 0 so our estimation is that she will hate the movie so to make our predictions we first need to gather this feature data for every user and movie to simplify let’s return to a matrix the representation we can store this information in two matrices. One defines the mapping between people and features the other defines the mapping between movies and futures and by multiplying these two matrices together using matrix multiplication we get an estimated strength of the connection between every person and movie and if we’d like we can normalize our data to make sure the scale stays between 0 and 4 by dividing all values by 8 and rounding to the nearest point 4 that’s one way to solve this problem is known as content filtering.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*9qDxRdqINlgqXIgBBaWtUA.png" /><figcaption>source: <a href="https://www.youtube.com/watch?v=n3RKsY2H-NE">https://www.youtube.com/watch?v=n3RKsY2H-NE</a></figcaption></figure><p><strong>The problem is :</strong></p><ol><li>it’s overly simplistic</li><li>not very accurate</li></ol><p>that’s because there are obviously more relevant features of a movie than just comedy or action. The obvious way to improve this is just to<strong> include more features </strong>if your call when Netflix started it did just this would ask new users to fill out a laundry list of questions about their preferences before presenting them with suggested movies and this leads to the problem of having to collect all of this preference data on users not only is it a burden for users, it’s also prone to failure as we aren’t always great at describing our own preferences. Sometimes we simply can’t explain why we like things we just do which brings us to another approach called</p><p><strong>Collaborative filtering: </strong>The motivation for collaborative filtering comes from the idea that you will probably like things people with similar viewing habits. This idea was popularized in this 2009 paper by Cohen Bell and Wolinski. So to begin we can throw away the idea of dreaming up features used to connect people and movies. Instead, we flip things around and use the user preference data we do have to generate the features. For example, we might have this incomplete set of preference data and we will instead learn or discover the relevant features based on patterns in this data. This is done by simply reversing the problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*kZMIJKLgY4P7Mq4ecN_L2Q.png" /><figcaption>source: <a href="https://www.youtube.com/watch?v=n3RKsY2H-NE">https://www.youtube.com/watch?v=n3RKsY2H-NE</a></figcaption></figure><p>We first perform an approximate factorization into two <strong>matrices </strong>and we can do this using a <strong>machine-learning</strong> approach. The job of the machine-learning algorithm is to guess values for those matrices which will match the existing data and the preference matrix as closely as possible. The simplest approach is to simply guess numbers over and over until you arrive at a set of numbers that predict the data with the <strong>lowest error overall</strong>. Once this estimation is finished we can multiply the matrices as before to fill in all of the <strong>missing values.</strong></p><p>It’s important to note that we won’t know exactly what to label these discovered features.<strong> So we call them latent features because they arise out of the underlying patterns and the data. </strong>You can think of them as an average or weighted sum of the patterns in the data are not based on a human-defined feature such as comedy. That’s the key insight behind this method. With content filtering the features come from the <strong>human mind</strong> whereas with collaborative filtering the features are extracted directly from the <strong>patterns in the data</strong>. This will predict the data in the same way but more accurately.</p><p>It’s also important to notice that this kind of prediction is actually a form of compression because we can represent a huge matrix of preference data by two smaller matrices of feature data. Once our feature data is determined or learned we can throw away the original data we started with because we can simply multiply the features together to recreate that data. The reason this is possible is that the preference data we started with is not random but follows patterns that exist across people. If instead the preference data was filled with random numbers we would not be able to compress it accurately because there would be no patterns to extract.</p><p>This <strong>collaborative filtering </strong>approach has also been applied to a wide range of contexts such as evaluating policy outcomes before they are implemented in the real world known as <strong>synthetic control</strong>. For example, if we wanted to understand the effect of gun control or minimum wage increases in some city we could look at the effect in similar cities first which have implemented those policies to approximate the outcome using the same mechanism. So it is the patterns we share that allow this method to work. Recommendation systems based on the ideas are in widespread use today whether it’s movies music news articles or anything else you search for online the things that are recommended to you are based on patterns the machine has observed in other people who are similar to yourself.</p><p>But Collaborative Filtering comes with its own shortcomings. <strong>One such problem in such kinds of systems is the problem of Cold-Start.</strong></p><p><strong>Cold- Start</strong> represents in a literal sense a situation when the engine is cold and we were are unable to start it. The user or visitor cold start simply means that when <strong>a recommendation system meets a new user for the first time and thus there is a lack of history about her preferences</strong>. Getting to know your user is critical in creating a great user experience for them.</p><p><strong>It is faced when we have</strong></p><ol><li>A new user.</li><li>A new product</li><li>A new recommender system is in place.</li></ol><p>Remedies for the cold start problem is :</p><p><strong>When we have a new user :</strong></p><ol><li>Start by recommending whatever is newer, cheaper, or popular. Popular items are highly likely to be liked by the user because it is popular and it is easier to build a profile on popular items.</li><li>Recommend demographically relevant products. For example, if it is a movie recommendation system you can recommend Punjabi songs to a user situated in Punjab.</li><li>Recommend product according to age, sex, or geography.</li><li>Use other sources of data like social network data.</li></ol><p><strong>When we have a new recommender system :</strong></p><ol><li>Design a Non-Recommender system that captures data to feed it later to the recommender system.</li><li>Get similar data from other sources.</li></ol><h3>Six Examples of Recommender Systems</h3><p>Recommender systems work behind the scenes on many of the world’s most popular websites. E-commerce websites, for example, often use recommender systems to increase user engagement and drive purchases, but suggestions are highly dependent on the quality and quantity of data that freemium (free service to use/the user is the product) companies already have in place.</p><h3>1. AMAZON</h3><p>When we buy something or browse anything on Amazon, we see recommended products based on our likes or search results on the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*eGT8Pezpho9ow6Si.png" /><figcaption>Amazon’s Recommender</figcaption></figure><p>As we can see above, I may have searched for products related to Sudha Murthy, but Amazon clusters it into segments based on other previous search results. A recommender system often biases the user’s opinion.</p><h3>2. IMDB</h3><p>When we rate a TV show or movie on IMDb it recommends other shows or movies based on important details like cast, genre, sub-genre, plot, and summary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/0*crCUJQWlpRd1Onro.png" /><figcaption>IMDB’s Recommender</figcaption></figure><p>As we can see above, I was recommended to rate <em>Frozen Planet</em> because I’ve watched David Attenborough’s wildlife documentary series. In this case, IMDb suggested this to me based on the cast of the series.</p><h3>3. FACEBOOK &amp; INSTAGRAM</h3><p>Facebook and Instagram use recommender systems on a wider scale for suggesting friends and stories in the newsfeed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/0*9cZOY7TI9sZU4aF8.jpeg" /><figcaption>Facebook’s Recommender</figcaption></figure><p>Often in the newsfeed section, the user is bombarded with articles similar to one another based on the likes and pages they follow. Some argue it creates an unconscious bias among the user, which may be bad or useful depending on how the user interprets something when they have only one side of the argument.</p><h3>4. YOUTUBE</h3><p>YouTube recommends videos based on previous clicks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*zoQTGYZgfbM9yZYC.png" /><figcaption>Youtube’s Recommender</figcaption></figure><p>As we can see above, the first video is about Google. While I’ve seen the video, YouTube recommends it to me again.</p><h3>5. GOOGLE</h3><p>Whenever we are logged in and search on Google, it is stored in our history and recommends products based on our previous searches. Not surprisingly, more than 95% of the company’s revenue is generated through advertising.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*NQjwfpk96WS2Ykh5.png" /><figcaption>Google’s Recommender</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*0wUSuCnMG-rCrxxp.png" /><figcaption>Flipkart’s recommender</figcaption></figure><p>From the above, we can see we were getting targeted with these advertisements based on recent search results.</p><h3>6. ANOTHER GOOGLE SUBSIDIARY- GMAIL</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*s9FwX7V6vsXNAd11.png" /></figure><p>Gmail’s Sponsored Ad</p><p>Gmail recommends advertisements based on my personal inbox and tags they may have generated.</p><p>Other examples of recommender systems at work include movies on Netflix, songs on Spotify, and profiles on Bumble.</p><h3>To summarise:</h3><p>In this article we understood how the Recommendation System works and the difference between Collaborative Filtering vs Content-Based Filtering and their working. Both methods have their own set of advantages and disadvantages. We defined the problem of a cold start and saw some ways to tackle it. In the end, we saw some use cases of recommendation systems in big tech giants. Recommendation systems are very widely used in the tech industry, there are many kinds of research going on to develop more features in the recommender. I&#39;ll be writing a second part for the codes(building recommender systems)and other technological advancements in this area of machine learning.</p><p><strong>Happy learning!</strong></p><p>Resources on Recommendation engines :</p><ul><li><a href="https://medium.com/airbnb-engineering/listing-embeddings-for-similar-listing-recommendations-and-real-time-personalization-in-search-601172f7603e">Listing Embeddings in Search Ranking</a></li><li><a href="https://www.zillow.com/tech/embedding-similar-home-recommendation/">Home Embeddings for Similar Home Recommendations - Zillow Tech Hub</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FgiIXNoiqO_U&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DgiIXNoiqO_U&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FgiIXNoiqO_U%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a23650e799760e60cb1d2bee799def0/href">https://medium.com/media/4a23650e799760e60cb1d2bee799def0/href</a></iframe><ul><li><a href="https://developers.google.com/machine-learning/crash-course/embeddings/video-lecture">Embeddings | Machine Learning | Google for Developers</a></li><li><a href="https://labs.spotify.com/2020/01/16/for-your-ears-only-personalizing-spotify-home-with-machine-learning/">For Your Ears Only: Personalizing Spotify Home with Machine Learning</a></li><li><a href="https://pdfs.semanticscholar.org/f635/6c70452b3f56dc1ae07b4649a80239afb1b6.pdf">[PDF] Pandora &#39; s Music Recommender | Semantic Scholar</a></li><li><a href="https://blog.twitter.com/engineering/en_us/topics/insights/2018/embeddingsattwitter.html">Embeddings@Twitter</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf85aedefa32" width="1" height="1" alt=""><hr><p><a href="https://medium.com/almabetter/recommender-systems-the-most-valued-application-of-machine-learning-cf85aedefa32">Recommender Systems — The most valued application of machine learning.</a> was originally published in <a href="https://medium.com/almabetter">AlmaBetter</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ensembling methods and why they are most preferred among Machine Learning practitioners.]]></title>
            <link>https://medium.com/almabetter/ensembling-methods-and-why-they-are-most-preferred-among-machine-learning-practitioners-e0d6368e994e?source=rss-8dac2e5ea825------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0d6368e994e</guid>
            <category><![CDATA[gradient-boosting]]></category>
            <category><![CDATA[ensemble-method]]></category>
            <category><![CDATA[random-forest]]></category>
            <category><![CDATA[boosting]]></category>
            <category><![CDATA[bagging]]></category>
            <dc:creator><![CDATA[Shafil Ahamed]]></dc:creator>
            <pubDate>Thu, 26 Aug 2021 07:19:38 GMT</pubDate>
            <atom:updated>2021-08-26T17:59:26.390Z</atom:updated>
            <content:encoded><![CDATA[<h3>Ensemble methods and why they are most preferred among Machine Learning practitioners.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*HYw8ydwSBljyglEM2UZq0A.png" /><figcaption>source: <a href="https://freedesignfile.com/219961-dense-forest-landscape-vector-material/">https://freedesignfile.com/219961-dense-forest-landscape-vector-material/</a></figcaption></figure><h3><strong>INTRODUCTION</strong></h3><p>One of the major disadvantage a tree based algorithm face is its tendency to overfit the data points.</p><ol><li>The Decision tree tends to split on the features that are most important for the model and features that hold slightly less value are left as it is.</li><li>Allowing a decision tree to split till a granular degree, is a prime behavior of this model that makes it prone to learning every point extremely well — to the point of perfect classification on a training set — ie: overfitting.</li></ol><p>Now before getting into how Ensembling technique overcomes this drawback of Decision Tree, let us first define what are these <strong>Emsembling techniques</strong>.</p><p><strong>Ensemble techniques are meta algorithms that combine several machine learning techniques into one supervised model in order to decrease variance through bagging, bias through boosting, or improve predictions through stacking.</strong></p><p>Ensemble methods can be divided into two Sub-categories:</p><ul><li><strong><em>Sequential</em> ensemble</strong> methods are a way in which data is trained on multiple weak learners(stumps) sequentially and the input of each successive learner is the residual of previous learner.(e.g. AdaBoost,CatBoost,GBM).<br>The overall performance can also be boosted by weighing previously mislabeled examples with higher weight.</li><li><strong><em>Parallel</em> ensemble</strong> methods where multiple weak learners work in parallel to come to a strong prediction either by taking average or by voting classifiers.(e.g. Random Forest).<br>The basic motivation of parallel methods is that the error can be reduced dramatically by averaging.</li></ul><p>Why are Ensembling methods so popular:</p><ul><li><strong>Performance</strong>: An ensemble can make better predictions and achieve better performance than any single base model.</li><li><strong>Robustness</strong>: An ensemble reduces the variance of the predictions and model performance.</li><li><strong>Stability</strong>:We use Bagging when there is low bias — high variance and we use boosting when there is high bias — low variance.</li></ul><h3><strong>Bagging</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*pf0vovrfpeojQ26O3s0dyQ.png" /><figcaption>source : <a href="https://corporatefinanceinstitute.com/resources/knowledge/other/bagging-bootstrap-aggregation/">https://corporatefinanceinstitute.com/resources/knowledge/other/bagging-bootstrap-aggregation/</a></figcaption></figure><p><strong>Bagging</strong>, also known as <strong>bootstrap aggregation</strong>, is an ensemble technique that is often used to reduce <strong>variance</strong> within a dataset. The technique is useful for both regression and classification method.Bagging is used with multiple decision trees, where it raises the stability of models by improving accuracy and reducing variance, which eliminates the problem of overfitting.Let us understand this with most common bagging algorithm called <strong>Random Forest.</strong></p><p><strong>Random Forest </strong>takes its name in a quite literal sense. Like a forest consists of multiple trees, similarly, the Raondom forest algorithm uses multiple decision trees in a bagging fashion.This in turn reduces the variance by taking an average of the predicted values of all the trees.</p><p>Bagging has two subcategories Bootstrap and Aggregation.</p><p><strong>Bootstrap</strong> is a sampling method that works on a principle of sampling with replacement. Let&#39;s say we have<strong> M rows and N features</strong>. We will sample out some data which has m rows and n features, given M&gt;m and N&gt;n. After sampling out we replace the space created in the original data with the same values, we do this to completely randomize our sample.We get large number of such samples and feed them to individual decision trees.Another advantage of sampling is that all features get equal opportunity to get split upon in a decision tree.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*h-HczhYyiJC6lRLzdaarxw.png" /><figcaption>Source: <a href="https://www.researchgate.net/figure/Bootstrap-Sampling-Procedure-The-classical-procedure-of-bootstrapping-involves-sampling_fig1_332849902">https://www.researchgate.net/figure/Bootstrap-Sampling-Procedure-The-classical-procedure-of-bootstrapping-involves-sampling_fig1_332849902</a></figcaption></figure><p><strong>Aggregation </strong>is a way of combining the predictions that multiple decision trees have made. Aggregation methods are different for classification and regression. In the case of <strong>regression</strong>, an <strong>average</strong> is taken of all the outputs predicted by the individual classifiers, this is known as soft voting. For <strong>classification</strong> problems, the class with the highest <strong>majority of votes </strong>is accepted; this is known as hard voting.</p><h3><strong>Boosting</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*0mWCU1JEd3Ghtt4-_El6PA.png" /><figcaption>Source : <a href="https://en.wikipedia.org/wiki/Boosting_(machine_learning)#/media/File:Ensemble_Boosting.svg">https://en.wikipedia.org/wiki/Boosting_(machine_learning)#/media/File:Ensemble_Boosting.svg</a></figcaption></figure><p><strong>Boosting </strong>is an ensembling technique specifically used when the model has <strong>high bias and low variance </strong>unlike bagging this technique works sequentially, it takes a weak learner and converts it into a strong learner by successively modeling on the residuals of the previous learner. Let us understand it in layman&#39;s terms.</p><ol><li>The model first takes a weak learner preferably a <strong>stump</strong>(one split decision tree)we feed the data into it.</li><li>The model underfits on the data, leaving<strong> residuals</strong>.</li><li>Now because the model was unable to capture all the features of the data,there are still multiple features present in the residual(error margins)</li><li>This residual is given to the next weak learner as input which again is able to capture some features from it.</li><li>The process goes on till there are no features left in the residuals and the cost function is reached its <strong>minima</strong>.</li><li>The final value is calculated as the <strong>sum of predictions</strong> of all the <strong>weak learners.</strong></li></ol><p>Some examples of boosting techniques are <strong>AdaBoost</strong> and <strong>Gradient Boosting Machine(GBM)</strong>, a brief description of their work is given below :</p><p><strong>Adaboost</strong> or adaptive boosting is a technique that is used as an ensemble method in machine learning. It is known as <strong>adaptive boosting</strong> because the weights are re-assigned at each instance, and higher weights are assigned to incorrectly classified instances.</p><p>It works on the principle where<strong> learners are added sequentially.</strong> Except for the first, each subsequent learner is grown from previously added learners. In simple words, weak learners are converted into strong learners by modeling on the residuals.</p><p>Adaboost algorithm also works on the same principle as boosting, but there is a slight difference in working. In boosting algorithms, only the incorrectly classified data points are sent to the next base learner. While in Adaboost, both records are allowed to pass.Though there is an increase in the weight of wrongly classified records and a decrease in the weight of correctly classified records.</p><blockquote>To get deeper knowledge of Adaboost and see its working in a stepwise example please refer to the link :<a href="https://www.mygreatlearning.com/blog/adaboost-algorithm/">https://www.mygreatlearning.com/blog/adaboost-algorithm/</a></blockquote><p><strong>Gradient Boosting Machine(GBM) </strong>is a machine learning technique for regression and classification problems, which produces a prediction model in the form of an ensemble of weak prediction models, typically<strong> decision trees</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*wvTCDpJ5LVCw2zUYMJAhOA.png" /><figcaption>source:<em>https://data-flair.training/blogs/gradient-boosting-algorithm/</em></figcaption></figure><p>Input requirements for<strong> GBM :</strong></p><p>1.A <strong>Loss Function</strong> to optimize.</p><p>2.A <strong>weak learner</strong> to make predictions (Generally Decision tree).</p><p>3.An <strong>additive model</strong> to add base learners to minimize the cost function.</p><p><strong>Working: </strong>Gradient Boosting relies on the intuition that the best possible next model when combined with the previous models, minimizes the overall prediction errors.</p><p>Just like AdaBoost, GBM works by sequentially adding base learners to an ensemble, each one correcting its predecessor. However, instead of changing the weights for every incorrect classified observation after every iteration like AdaBoost, Gradient Boosting method tries to fit the new base learner to the residual errors made by the previous predictor.</p><p><strong>Some important features of Gradient Boosting Machine :</strong></p><p>1)Gradient Boosting is one of the boosting algorithms that is used to minimize bias error of the model.</p><p>2)We can tune the <strong>n_estimator </strong>of the gradient boosting algorithm. However, if we do not mention the value of n_estimator, the default value is taken as 100. (n_estimator is the number of decision trees)</p><p>3)When it is used as a regressor, the cost function is <strong>Mean Square Error (MSE) </strong>and when it is used as a classifier then <strong>Log loss</strong> is taken as a cost function.</p><blockquote>For further information on Gradient Boosting Machine please refer to the link: <a href="https://www.analyticsvidhya.com/blog/2021/04/how-the-gradient-boosting-algorithm-works/">https://www.analyticsvidhya.com/blog/2021/04/how-the-gradient-boosting-algorithm-works/</a></blockquote><p>Now to answer the question with which we started this blog. <strong>How do Ensembling techniques overcome the drawbacks of Decision trees?</strong></p><p>For decision trees, ensemble methods are one of the only efficient means of performing <strong>regularization</strong> on the model.</p><p>While using decision trees we face a conundrum: in order to model a complex set of data, we often need <em>many levels of the tree </em>, but as the tree grows deeper, it becomes prone to <strong>overfitting</strong>.</p><p>That’s because every time you add a new level to your tree, you’re adding a new predicate in the sequence.The chain becomes so specific that it’s very likely to apply very few training examples for each leaf. Also, the number of leaves grows <em>exponentially</em> with the number of levels, each successive level gets significantly more prone to overfitting.</p><p>So instead of using one tree for example with depth 50, we might use 10 trees each of depth 5 in a <strong>random forest</strong>. Each tree comes to its own prediction, and then voting methods is used for the final prediction where each tree gets a vote. That way our model becomes more robust and less overtly specific.</p><p><strong>Advantages of using Ensembling technique</strong></p><ol><li>It acts as a regularising parameter on overfitting models.</li><li>it increases stability of our final model</li><li>it increases the accuracy of our model drastically</li></ol><p><strong>Disadvantages of using Ensembling technique</strong></p><ol><li>It is considered as a black box model and therefore in a tradeoff between accuracy and interpretability it becomes very difficult to interpret the model which is a vital part of any real-world solution.</li><li>Also, ensemble techniques cost more to create, train, and deploy. The ROI(Return of Investment)of an ensemble approach should be considered while keeping its computational cost in mind.</li></ol><h3>Conclusion</h3><p>Apart from the methods discussed in this article, it is common to use ensembles in deep learning by training diverse and accurate classifiers. Diversity can be achieved by varying model architectures, hyperparameter tuning, and training techniques.</p><p>Ensemble methods have been thriving in setting record performance on big datasets and are among the winners of Kaggle competitions. But at the same time, we need to keep in mind the high computational cost and low interpretability of these models.</p><h3>Recommended reading :</h3><ul><li><a href="https://www.analyticsvidhya.com/blog/2018/06/comprehensive-guide-for-ensemble-models/">Ensemble Learning | Ensemble Techniques</a></li><li><a href="https://blog.statsbot.co/ensemble-learning-d1dcd548e936">Ensemble Learning to Improve Machine Learning Results</a></li><li><a href="https://www.kaggle.com/c/otto-group-product-classification-challenge/discussion/14335">Otto Group Product Classification Challenge</a></li><li><a href="https://scikit-learn.org/stable/modules/ensemble.html">1.11. Ensemble methods</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0d6368e994e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/almabetter/ensembling-methods-and-why-they-are-most-preferred-among-machine-learning-practitioners-e0d6368e994e">Ensembling methods and why they are most preferred among Machine Learning practitioners.</a> was originally published in <a href="https://medium.com/almabetter">AlmaBetter</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>