<?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 Michel Montero on Medium]]></title>
        <description><![CDATA[Stories by Michel Montero on Medium]]></description>
        <link>https://medium.com/@michelmontero2019?source=rss-c1cbb9bd4eb6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ykn_KGcA2lU8BARz8y08qw.jpeg</url>
            <title>Stories by Michel Montero on Medium</title>
            <link>https://medium.com/@michelmontero2019?source=rss-c1cbb9bd4eb6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 14:20:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@michelmontero2019/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[Resampling Methods for Machine Learning modeling]]></title>
            <link>https://medium.com/geekculture/resampling-methods-for-machine-learning-modeling-d2cdc1d3640f?source=rss-c1cbb9bd4eb6------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2cdc1d3640f</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[resampling]]></category>
            <category><![CDATA[crossvalidation]]></category>
            <category><![CDATA[bootstrap]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Michel Montero]]></dc:creator>
            <pubDate>Wed, 07 Apr 2021 15:52:13 GMT</pubDate>
            <atom:updated>2021-04-09T21:15:40.458Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*gT-NcAM-0lddm6ik" /><figcaption>Image by <a href="https://unsplash.com/@madhatterzone">Manja Vitolic</a><strong> </strong>from <a href="https://unsplash.com/">Unsplash</a></figcaption></figure><p><strong>What is a resampling method?</strong></p><p>Generally speaking, a resampling method is a tool consisting in repeatedly drawing samples from a dataset and calculating statistics and metrics on each of those samples in order to obtain further information about something, in the machine learning setting, this something is the performance of a model. But in case of merely statistical analysis this could be additional insight about the behavior of some parameter</p><p><strong>Why we have to use it?</strong></p><p>Two words can express the liability that makes necessary the use of resampling methods: <strong>random chance</strong>. Every time we draw a sample from a population and calculate a statistic, the estimated parameter can be as far as close to the real population value, only due to random chance, therefore we don’t have any information about the confidence of our conclusions and our prediction will be dubious. That is why we use <strong>bootstrapping</strong>, drawing multiples samples from our original sample (resampling), we can explore the different combinations that could result in the first place, computing standard errors and confidence intervals, which give us a consistent range of values for estimate the true population parameter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*aKuEDrwWA3_9z-0IuEi-zQ.png" /><figcaption>Computing a statistic from a sample carries some degree of uncertainty. In the image we can see how the sample estimate differs from the real value in approx. 36%. The bootstrap method helps us to address this problem. PS: the effect has been exaggerated. Image by Author</figcaption></figure><p>In case of evaluating a model performance we usually split the dataset into a training set and a test set. But this approach comes with a drawback, the performance of the model can show different results depending on the test set selected. And since what cares about a model is how well does it generalize (performs on unseen data), the instability of this measures makes difficult to compare different models and gives a suspicious sight of the model performance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*A8lT5zYXMADQ7Ll0nqIoNQ.png" /><figcaption>Depending on the test set selected, the evaluation of a model can be very misleading. In the image we can see how the model shows F1 Scores (a performance metric) ranging from 0.2 to 1.0 (Which is a big deal of difference). The cross-validation approach comes in handy to address this volatility. Image by Author</figcaption></figure><p><strong>The Bootstrap</strong></p><p>Bootstrapping is the resampling method by antonomasia. It consists in taking multiples samples out of our original sample and study the resulting distribution, and why we would do that? Well, it allows us to see how much variation there would have been and gives further understanding of the sample that we took in the first place.</p><p>The bootstrap method is mostly used to provide the standard error of the estimates, and therefore compute confidence intervals.</p><p><strong>Advantages of the bootstrap method</strong></p><ul><li>It is easy to implement</li><li>It doesn’t rely in any kind of assumption that we would make about the population distribution</li><li>Allows us to get a sense of the uncertainty relative to our dataset and therefore drive us to more consistent conclusions</li></ul><p><strong>How does it work?</strong></p><p>The steps for performing a bootstrap resampling works as follows:</p><ul><li>Take a sample of the population, a dataset</li><li>Take multiple samples with replacement out of that sample. The more samples we take, the more accurate it would be, … and the more time it will consume</li><li>Compute the statistic of interest for each of these sample</li><li>Determine the standard error (standard deviation) of the resulting distribution, and compute the confidence intervals with them</li><li>Then use this confidence intervals for the purpose of your data analysis. You can make conclusions about the population parameters with the detailed degree of uncertainty subject to that</li></ul><p><strong>Illustration</strong></p><p>Let’s assume that we have two variables X and Y, and wish to quantify the correlation between them. The people who do statistics now that this measure can be determined with the formulae:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/116/0*eJ5zf3XOMZqu5f97" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*a8VuqYiLR5932prz" /></figure><p>For our simulation-generated dataset (Image) we have that the correlation calculated is 0.55, which indicated a kind of positive relationship between X and Y:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*f-knmRN5fgZvsNFd8eiBUg.png" /><figcaption>Image by Author</figcaption></figure><p>The problem arises in real case scenarios where we don’t have access to population parameters because we cannot generate data through simulation, quantities such as the variance and thereby the correlation are inaccessible, but yet estimable. What we can do is compute approximations for those measures using sample data, but due to the effect of random chance explained above, we cannot completely rely in those point estimates. That’s where bootstrap comes in play</p><p>We initially take a sample out of the population, let’s suppose that our sample has 100 observations</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*COhPPxUrWraHwpwvzce-0A.png" /><figcaption>Image by Author</figcaption></figure><p>Now, the bootstrap approach allows us to use a computer to emulate the process of obtaining new sample sets, so we can estimate the variability of the correlation, using only our initial sample (100 observations). Rather than obtaining independent data sets from the population, we instead obtain distinct data sets by repeatedly sampling observations from the original data set and calculating the correlation for each of these resamples. This process is described in the following image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*hBD9ZxDZiIy9wBlEn-ikFg.png" /><figcaption>Image by Author</figcaption></figure><p>The resulting metrics (in this case the correlation) in each of this resamples constitutes a distribution, the so called the Bootstrap Distribution</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*3d3PVjDIu-AAMzJcC24RYA.png" /><figcaption>Bootstrap distribution build on a sample of 100 observations draw out from a 10K population. The black line represents the real population value (0.55). Image by Author</figcaption></figure><p>Then we can use this bootstrap distribution to do whatever we meant to do in this first place. Like computing confidence intervals or making estimates about population parameters.</p><p>It is worth to notice that bootstrapping it is not way to reduce the errors, but to estimate them. It is meant to figure out the shape and spread of the population, not point estimates (single values instead of an interval of them). It does not add new data to our sample, as we can see from the histogram above, the mean of the bootstrap distribution differs a little from the actual mean, this is because the bias introduced by the chosen sample, if our data had been more representative, our distribution would be more mean-centered and vice versa. It helps to get further understanding of our population, but it is not panacea, if our sample is extremely biased, then any conclusion that we draw from bootstrapping or any other resampling method will be dubious</p><p><strong>Cross — Validation</strong></p><p>Among the major drawbacks in the machine learning setting is the divergence between training error and test error. One example of this is the (in)famous overfitting, most statistical learning algorithms either directly or indirectly seek to minimize the training error by taking into account more noise than signal, then, when is given new data to the model it performs badly in contrast to what the training metrics may indicated in the first place. Don’t get me wrong, training metrics are key to automatize and get a glance at the performing of learning algorithms (a quick comparison), but in the end, the utility of a model resides in how well does it manage unseen data (measured through test metrics). For illustration, when we optimize the training metrics, we are probably memorizing the data, when optimizing the test metrics, we are learning from it, and that is what we want.</p><p><strong>What is the cross — validation method?</strong></p><p>Dividing a dataset into one big training set and one small test set is the typical way to fit and evaluate a model, this is, called the validation–set approach. But this method has the following problems:</p><ul><li>The validation estimate of the test error rate can be highly variable, depending on precisely which observations are included in the training set and which observations are included in the validation set (As illustrated in the second picture of this essay)</li><li>Only a subset of the observations — those that are included in the training set rather than in the validation set — are used to ﬁt the model</li></ul><p>Cross — validation is a refinement of this approach and is meant to address the previous liabilities. It has few variants, but the most practical is the <strong>stratified</strong> <strong>k-fold cross-validation</strong></p><p>It basically works on the following way:</p><ul><li>Instead of creating two subsets of the data and use one for training and the other for test. This approach involves <strong>randomly</strong> dividing the set of observations into <em>k</em> groups, or folds, of approximately equal size. The ﬁrst fold is treated as a validation set, and the method is ﬁt on the remaining k − 1 folds</li><li>Then, the test error (or test metrics) is computed on the observations of the held-out fold (the validation set)</li><li>This procedure is repeated <em>k</em> times; each time, a diﬀerent group of observations is treated as a validation set. This process results in <em>k</em> estimates of the test error. The k-fold cross-validation estimate is computed by averaging these values, which can be considered our final, curated, test metric for evaluate our model</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*UEDAttUgYr_CcObQBuTVmg.png" /><figcaption>An illustration of how the stratified k-fold cross-validation approach works. In this case we are performing the algorithm with k = 5. Acv is the average of all the metrics estimated, and is the metric that we can use to compare between models. Acv could be any test metric we want, like the Mean Square Error (MSE), or the F1-Score; in case of classification models. Image by Author</figcaption></figure><p><strong>Advantages of cross — validation</strong></p><p>Basically, the advantages/utility of the cross — validation approach is that it addresses the liabilities previously mentioned</p><ul><li>Due to the quantity of resampling, we can average the different test metrics obtained, beating the effect that random chance has when we only have one test set</li><li>We use all the data. Well build algorithms performs better as we give them more data. But also test the model with data they have not seen, obtaining accurate test metrics</li></ul><p><strong>When to use Bootstrapping vs. Cross Validation?</strong></p><p>Though bootstrap and CV are both resampling methods, it’s uses are in different scenarios, related do. You should use Cross validation when you to <strong>asses</strong> a <strong>model </strong>performance through test metrics. And Bootstrapping when you want to <strong>make estimates</strong> about some <strong>population </strong>value with his standard errors and confidence intervals.</p><h3>Reference:</h3><p>Introduction to Statistical Learning in R by Gareth James, Daniela Witten, Trevor Hastie, Robert Tibshirani.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2cdc1d3640f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/resampling-methods-for-machine-learning-modeling-d2cdc1d3640f">Resampling Methods for Machine Learning modeling</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>