<?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 Sri Sai Subramanyam on Medium]]></title>
        <description><![CDATA[Stories by Sri Sai Subramanyam on Medium]]></description>
        <link>https://medium.com/@saidavanam183?source=rss-69d3927ea6b8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Sri Sai Subramanyam on Medium</title>
            <link>https://medium.com/@saidavanam183?source=rss-69d3927ea6b8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 14:18:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@saidavanam183/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[Understanding Bias and Variance in Machine Learning: Concept of Underfitting]]></title>
            <link>https://medium.com/@saidavanam183/underfitting-in-machine-learning-c80f829e6914?source=rss-69d3927ea6b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/c80f829e6914</guid>
            <dc:creator><![CDATA[Sri Sai Subramanyam]]></dc:creator>
            <pubDate>Sat, 04 Jan 2025 11:01:49 GMT</pubDate>
            <atom:updated>2025-01-04T12:21:11.963Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>This is going to be series of articles which is going to explain bias and variance problems in machine learning. This article speaks only about concept of underfitting and there will be upcoming articles on overfitting and bias and variance analysis.</strong></p><p><strong>INTUITION ON UNDERFITTING</strong> :-</p><p><strong>Underfitting is a condition where a model performs worse on training data due to its simplistic assumptions.</strong></p><p>Let me walk through the example to understand the above statement more deeply by story telling</p><p>“Meet Nandini, a seasoned cosmetician whose expertise spans decades in the beauty industry. Driven by her passion to share time-tested beauty secrets and techniques, she ventured into the world of Instagram Reels. The graph illustrates her remarkable journey, showing how number of followers evolved over months.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*pVcaLPRH00fmRr0DyzZdPQ.png" /></figure><p>Let us develop an machine learning model which can predict future outcomes.</p><p>we will use Linear Regression here as machine learning model.Below is the code snippet.Feel free to use it</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>from sklearn.linear_model import LinearRegression<br><br># Data<br>np.random.seed(40)<br>x = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])  # Months<br>f_x = np.array([2, 6, 19, 53, 147, 402, 1096, 2980, 8102, 22025, 59873, 162754])  # Followers<br># Number of followers in each month<br><br># Fit a linear regression model<br>lr = LinearRegression()<br>lr.fit(x.reshape(-1, 1), f_x.reshape(-1, 1))<br><br># Regression line parameters<br>slope = lr.coef_[0][0]<br>intercept = lr.intercept_[0]<br>y_pred = slope * x + intercept<br><br># Plot the data points<br>plt.scatter(x, f_x, label=&quot;Data points&quot;, color=&quot;blue&quot;, alpha=0.7)<br><br># Plot the regression line<br>plt.plot(x, y_pred, label=&quot;Regression line&quot;, color=&quot;red&quot;, linewidth=2)<br><br># Plot residuals (vertical lines from data points to regression line)<br>for i in range(len(x)):<br>    plt.plot([x[i], x[i]], [f_x[i], y_pred[i]], color=&quot;gray&quot;, linestyle=&quot;--&quot;, linewidth=1)<br><br><br>plt.title(&quot;Regression Plot with Residuals&quot;)<br>plt.xlabel(&quot;Months&quot;)<br>plt.ylabel(&quot;Total Followers&quot;)<br>plt.legend()<br>plt.xlim(0, 12.5)<br>plt.ylim(0, 180000)<br><br>plt.show()</pre><p>The result is shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*CbeEIi2jE2U5jiSGW2jVfw.png" /></figure><p>Red line shows how model has learnt the data. Dotted lines represents deviations from data to line which is very high. To represent mathematically, calculate mean squared error between predictions by using <strong>same training data. value will be very high</strong></p><pre>mean_squared_error(f_x,y_pred)</pre><p>output :- 1158157697…. which is very very high. <strong>Here model is performing worse on training data itself. This is the condition which is referred as underfitting.</strong></p><p>One of the main reason why model is underfitted is because of wrong assumptions. The pattern in dataset is non linear(in fact it is exponential) but we used linear regression to fit the model which fits data linearly which is wrong. Now read the definition of underfitting again and everything will make sense.</p><p>To quantify how worse model is performing on training data,we use term <strong>bias </strong>here.<br><strong>Bias :- </strong>The inability of the model to capture true relationship in the <strong>training set</strong> is known as bias.</p><p><strong>Higher bias is what leads to underfitting.</strong></p><h3>How to avoid underfitting??</h3><p><strong>Increasing model complexity :- A</strong>pproaching with more complex model like polynomial regression(Switching to non linearity) solves the problem..</p><p>Also there are other ways like <strong>adding more number of features</strong> but those are not relevant in context of this article. But the core idea of underfitting is important to understand. If you have any questions or need further clarification, please feel free to comment below, and I’ll be happy to assist.<br>Thanks for reading…..</p><p>Next article is on overfitting. stay tuned..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c80f829e6914" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>