<?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 Bruno Silva on Medium]]></title>
        <description><![CDATA[Stories by Bruno Silva on Medium]]></description>
        <link>https://medium.com/@b2silva?source=rss-f3af40e9d7b8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3iZmLrcnLzb_RGay-1CTZA.png</url>
            <title>Stories by Bruno Silva on Medium</title>
            <link>https://medium.com/@b2silva?source=rss-f3af40e9d7b8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 06:06:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@b2silva/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[Houston, I have a problem…I just want to be fit]]></title>
            <link>https://b2silva.medium.com/i-just-want-to-be-fit-26e9e31cd690?source=rss-f3af40e9d7b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/26e9e31cd690</guid>
            <category><![CDATA[bias-variance-tradeoff]]></category>
            <category><![CDATA[underfitting]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[overfitting]]></category>
            <dc:creator><![CDATA[Bruno Silva]]></dc:creator>
            <pubDate>Fri, 22 Mar 2024 09:57:00 GMT</pubDate>
            <atom:updated>2024-03-22T10:57:32.612Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Get back to basics series</em></p><p>In the intricate landscape of machine learning, where algorithms and models try to conquer the world with data looking for unseen patterns, l would like to dissect two common challenges that practitioners often encounter: <strong>overfitting</strong> and <strong>underfitting</strong>.</p><p>These phenomena occur when a model fails to generalize well to unseen data, leading to suboptimal performance. Understanding the concepts of overfitting and underfitting is crucial for building robust and reliable machine learning models.</p><p>If you want to understand the root cause for poor model performance you should double click and understand the model fit. That will give you hints to take corrective steps.</p><figure><img alt="Source: MathWorks" src="https://cdn-images-1.medium.com/max/1024/1*1XoZ7EqfKdhyGzB9RyQkSg.png" /></figure><h3>What is Overfitting?</h3><p>Overfitting occurs when a model learns the training data too well, including the noise or the random fluctuations that do not represent the underlying patterns in the data. As a result, the model performs exceptionally well on the training set but fails to generalize to new/ unseen data. In other words, it fits too closely to the training set memorising the training examples instead of learning the underlying relationships between features and the target variable.</p><h4>Symptoms</h4><ol><li><strong>Large Discrepancy Between Training and Test Performance:</strong> There’s a significant gap between the model’s performance on the training set and its performance on the test set. For example, the model achieves high accuracy on the training data but performs poorly on the test data.</li><li><a href="https://mlu-explain.github.io/bias-variance/"><strong>Low Bias, High Variance:</strong></a> The overfitted model has <strong>low bias</strong> since it will closely match the training data sets and also <strong>high variance. </strong>Bias, in a simplistic way, is the overall error from the training set, while Variance is the overall error from the testing set.</li><li><strong>Complex Decision Boundaries:</strong> The decision boundaries learned by the model are overly complex and convoluted, capturing noise rather than true patterns.</li></ol><h4>Root causes</h4><ol><li><strong>Small datasets: </strong>Insufficient data can compromise the ability to generalize well to new data</li><li><strong>Noisy data:</strong> Impure data can lead to mistake noise in the data for signal</li><li><strong>Overly complex model:</strong> Models with too many parameters can easily memorize the training examples.</li></ol><h3>What is Underfitting?</h3><p>Contrary to overfitting, underfitting occurs when a model lacks the capacity to capture the underlying structure of the data. It fails to learn from the training data effectively, resulting in poor performance both on the training set and unseen data. Underfitting typically happens when the model is too simple (e.g. trying to predict quadratic data with a linear model) or when insufficient training data is provided.</p><h4>Symptoms</h4><ol><li><strong>Low Training and Test Accuracy:</strong> The model performs poorly on both the training and test datasets.</li><li><strong>High Bias, Low Variance:</strong> Underfit models tend to have high bias and low variance, meaning they make strong assumptions about the data and are unable to capture its complexity.</li><li><strong>Simplistic Decision Boundaries:</strong> The model’s decision boundaries are overly simplistic and fail to capture the underlying patterns in the data.</li></ol><h4>Root causes</h4><ol><li><strong>Insufficient number of features:</strong> Lower number or ineffective features can prevent the model from learning effectively.</li><li><strong>Insufficient training time:</strong> The model has not trained for enough time to determine a meaningful relationship between the input and output variables.</li><li><strong>Overly Simplified Models:</strong> Models doesn’t have enough parameters to learn the underlying patterns.</li></ol><h3>Addressing Overfitting and Underfitting:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*xOZCX3R6-UnqFD51rS-4TQ.png" /><figcaption>Bias-Variance tradeoff</figcaption></figure><h4>Overfitting:</h4><ol><li><strong>Data Cleaning:</strong> In order to reduce the noise.</li><li><strong>Data Augmentation:</strong> In case that it is not possible to obtain more data, we can increase the size of the training set using techniques that artificially creates modified copies of a dataset using existing data.</li><li><strong>Feature Selection:</strong> Removing irrelevant or redundant features can help reduce the model’s complexity and mitigate overfitting.</li><li><strong>Regularization:</strong> Techniques such as L1 and L2 regularization penalize overly complex models, preventing them from fitting the noise in the data. Also techniques like early stopping and dropout can help to prevent overfitting.</li><li><strong>Cross-Validation:</strong> Using techniques like k-fold cross-validation helps in assessing the model’s performance on unseen data and prevents overfitting.</li><li><strong>Pruning: </strong>For tree-based algorithms, removing sections of the tree that are non-critical and redundant — without compromising the model’s performance.</li></ol><h4>Underfitting:</h4><ol><li><strong>Collecting More Data:</strong> Increasing the size of the training dataset (via Data Augmentation or not) can help the model learn more effectively and generalize better to unseen data.</li><li><strong>Feature Engineering:</strong> Introducing additional relevant parameters to the model can provide it with more information to learn from, reducing underfitting (for example — add polynomial features).</li><li><strong>Increasing Model Complexity:</strong> Using more complex models such as deep neural networks or ensembles can help capture the underlying patterns in the data. We can also reduce the regularization parameters, increase the training time, or fine-tune the hyperparameters of the model.</li></ol><h3>Conclusion:</h3><p>Overfitting and underfitting are common challenges in machine learning that can hinder the performance of models. By understanding the signs and causes of overfitting and underfitting, practitioners can employ appropriate strategies to mitigate these issues and build models that generalize well to unseen data.</p><p>If you want to know more about this topic, please look for Bias-Variance tradeoff.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26e9e31cd690" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How a data scientist…. decorates his living room?]]></title>
            <link>https://medium.com/data-science/how-a-data-scientist-decorates-his-living-room-c5026f490c2b?source=rss-f3af40e9d7b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5026f490c2b</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-driven-decisions]]></category>
            <dc:creator><![CDATA[Bruno Silva]]></dc:creator>
            <pubDate>Fri, 02 Apr 2021 15:38:29 GMT</pubDate>
            <atom:updated>2021-04-02T17:22:15.696Z</atom:updated>
            <content:encoded><![CDATA[<h4>A data-driven approach: episode #2</h4><p>I was looking for illustrations for a while for my living room without any success.<br>So, I remembered what I did with <a href="https://towardsdatascience.com/how-a-data-scientist-decorates-his-newborns-nursery-22aaed7f4a2c">my son’s room</a>. That was fun. 😂</p><p>That way, I started thinking of ways to build my own illustrations using my math knowledge and skills. After searching for a couple of minutes on the web, I stumbled upon this Marcus Volz amazing <a href="https://github.com/marcusvolz/mathart">GitHub repo</a> about generative art.</p><p>Instantly, I got really pumped and started writing my first lines of code.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3oEduOnl5IHM5NRodO%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3oEduOnl5IHM5NRodO%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F3oEduOnl5IHM5NRodO%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="217" frameborder="0" scrolling="no"><a href="https://medium.com/media/dfb61ff8b43b02dae079e8bd3255e77b/href">https://medium.com/media/dfb61ff8b43b02dae079e8bd3255e77b/href</a></iframe><p>My approach was the following:</p><p><strong>Illustration #1</strong></p><p>I knew that I had a couple of frames collecting dust for years in my home office. So I tried to replicate <a href="https://marcusvolz.com/#nearest-neighbour-graph">Marcus Volz’s nearest neighbors graph</a> but adding a personal touch.</p><p>I slightly modified the code from the repo mentioned above in order to build a rectangular shape for my illustrations.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/20da934e644885609a442b08008a1b29/href">https://medium.com/media/20da934e644885609a442b08008a1b29/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*9xkYeUX6dBwcYeqdATIgsw.png" /><figcaption>Image by Author</figcaption></figure><p>It was cool but I needed more. What if, instead of connecting each point to its <em>k</em> nearest neighbors, I somehow highlighted the relationship between the points. I mean, what if I identified the points with the following property:</p><blockquote>point A is a <em>k</em> nearest neighbor of point B <strong>and </strong>B is also a <em>k</em> nearest neighbor of A.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9cfe48a808fa4243917e59ce02289d87/href">https://medium.com/media/9cfe48a808fa4243917e59ce02289d87/href</a></iframe><p>I really loved the output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*aF3W_aXEIMR6JOXgkEW8DA.png" /><figcaption>k = 8 nearest neighbors. Why yellow? To be in harmony with the rest of the living room’s decoration (Image by Author)</figcaption></figure><p>Suddenly I was thinking, is there a relationship between the yellow segments and the black ones? I will leave it as an exercise 😉</p><p><strong>Illustration #2</strong></p><p>I kept exploring <a href="https://marcusvolz.com/">Marcus’s webpage</a> and since I was aware of the relationship between the <a href="https://en.wikipedia.org/wiki/Delaunay_triangulation">Delaunay triangulation and the Voronoi diagram</a> I decided to combine both in the same chart using the same dataset and again playing with the black and yellow lines.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/46c873533b7ece027636faac9bed74a2/href">https://medium.com/media/46c873533b7ece027636faac9bed74a2/href</a></iframe><p>The result was this one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*Blg8td_scnl1B41zesn_lw.png" /><figcaption>Delaunay triangulation plus Voronoi diagram version (Image by Author)</figcaption></figure><p>Mission accomplished. Now, it’s time to print and hang them😎.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*0X0-jMQHFGxRXFnqaoQ0nw.jpeg" /><figcaption>Image by Author</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5026f490c2b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/how-a-data-scientist-decorates-his-living-room-c5026f490c2b">How a data scientist…. decorates his living room?</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[How a data scientist…. decorates his newborn’s nursery?]]></title>
            <link>https://medium.com/data-science/how-a-data-scientist-decorates-his-newborns-nursery-22aaed7f4a2c?source=rss-f3af40e9d7b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/22aaed7f4a2c</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-driven-decisions]]></category>
            <dc:creator><![CDATA[Bruno Silva]]></dc:creator>
            <pubDate>Sat, 12 Dec 2020 14:46:21 GMT</pubDate>
            <atom:updated>2021-01-07T03:28:05.182Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>A data-driven approach</em></h4><p>Almost three years ago, my wife asked me to decorate a wall of my baby’s bedroom. So after searching a bunch of sites, we selected a vinyl piece composed of 117 “unperfect” circles of 4 colors.</p><h3>Problem</h3><p>Immediately, my head thought on the following question:</p><p><em>How to distribute them on a wall of 290cmx210cm?</em> That’s easy…. Using R 😎</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FLPrAK9rEedDwjtL1J0%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fmemecandy-LPrAK9rEedDwjtL1J0&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2FLPrAK9rEedDwjtL1J0%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="316" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a0f705d2a88979fdab410a1c4d0e335/href">https://medium.com/media/0a0f705d2a88979fdab410a1c4d0e335/href</a></iframe><h3>Getting Data</h3><p><strong>Extracting the right colors</strong></p><p>Beforehand, I needed to get the HEX codes from the image.</p><p><strong>How?</strong></p><p>My first attempt was to use this <a href="https://html-color-codes.info/colors-from-image/">website </a>for that:</p><ul><li>#A8C6C4</li><li>#32312F</li><li>#BDBFBE</li><li>#D6C245</li></ul><p>However, I was not happy with that solution. So I tried to automatically grab the colors from the image. 🚀</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b202ec43c6ad0f315214c4c4bf55e488/href">https://medium.com/media/b202ec43c6ad0f315214c4c4bf55e488/href</a></iframe><p>Firstly, I plotted the original picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/302/1*ZBS43BbSuPWcX72e8mhvfQ.png" /></figure><p>Then, I cropped the image keeping only the top left corner in order to extract the hex codes of the circles in that picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*G6_M_P-GJzgz8FMQ-2q73w.jpeg" /></figure><p>Now, it was time to pick the HEX codes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*JhRLgXPzHp6eHkdjLx8dPg.png" /></figure><h3>Preparing the dataset</h3><p>With the selection finished, I was ready to project the circles on the wall, and a couple of minutes later…<em>voilá</em>. For that, I decided to use a uniform distribution.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1592817b9604f189a47e5af64a8c8273/href">https://medium.com/media/1592817b9604f189a47e5af64a8c8273/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*cZJ1iq3STGny_9NiG5LxCg.png" /></figure><p>Finally, it was time for the “real” work.👌</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vFpavxTMIWotBGaq9EaR4g.jpeg" /><figcaption>I know, I know….but I don’t remember the seed used at the time.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22aaed7f4a2c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/how-a-data-scientist-decorates-his-newborns-nursery-22aaed7f4a2c">How a data scientist…. decorates his newborn’s nursery?</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>