<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged squares</title>
<link>https://coderlegion.com/tag/squares</link>
<description>Powered by Question2Answer</description>
<item>
<title>Main Idea of Least Squares Method and Linear Regression</title>
<link>https://coderlegion.com/21642/main-idea-of-least-squares-method-and-linear-regression</link>
<description>
&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href=&quot;https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;Star git-lrc on GitHub&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;Linear Regression is a  method that finds the best fitting line for a set of data points.&lt;/p&gt;

&lt;p&gt;It is used to predict the value of a dependent variable based on the value of one or more independent variables.&lt;/p&gt;

&lt;p&gt;let's assume we have a set of data points $(x_1, y_1), (x_2, y_2), ..., (x_n, y_n)$.&lt;/p&gt;

&lt;p&gt;The data points can be represented as a scatter plot.&lt;/p&gt;

&lt;p&gt;The data points are scattered in a way that it may represent a line.&lt;/p&gt;

&lt;p&gt;where each point $(x_i, y_i)$ represents a data point.&lt;/p&gt;

&lt;p&gt;A line can be represented as $y = mx + b$, where $m$ is the slope and $b$ is the y-intercept.&lt;/p&gt;

&lt;p&gt;Usually, we have some random value of $m$ and $b$ and we want to find the best value of $m$ and $b$ such that the line passes through the data points.&lt;/p&gt;

&lt;p&gt;For example in this graph there are mulitple data points, and we want to find the best fitting line for these data points.&lt;/p&gt;

&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0r2evqxp8vh5itokena4.png&quot; class=&quot;article-body-image-wrapper&quot;&gt;&lt;img src=&quot;https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0r2evqxp8vh5itokena4.png&quot; alt=&quot;&quot; width=&quot;589&quot; height=&quot;604&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This can be done using the least squares method.&lt;/p&gt;

&lt;h2&gt;
  
  
  Least Squares Method
&lt;/h2&gt;

&lt;p&gt;The least squares method is a method that finds the best fitting line for a set of data points.&lt;/p&gt;

&lt;p&gt;we calculate the sum of the squares of the differences between the actual values and the predicted values. &lt;/p&gt;

&lt;p&gt;$(y_i - (mx_i + b))^2$&lt;/p&gt;

&lt;p&gt;We want to minimize this value.&lt;/p&gt;

&lt;p&gt;So, we check each state of line and calculate the sum of the squares of the differences between the actual values and the predicted values. &lt;/p&gt;

&lt;p&gt;We choose the line that minimizes this value.&lt;/p&gt;

&lt;h2&gt;
  
  
  How this is done mathematically
&lt;/h2&gt;

&lt;p&gt;This whole caculation can be done mathematically. I will discuss in depth in my next article.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/HexmosTech/git-lrc&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;&lt;img src=&quot;https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabn6nl3iehrohehnxgje.png&quot; alt=&quot;git-lrc&quot; width=&quot;800&quot; height=&quot;373&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It&amp;rsquo;s online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;&amp;#11088; &lt;a href=&quot;https://github.com/HexmosTech/git-lrc?utm_source=chatgpt.com&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;Star git-lrc on GitHub&lt;/a&gt;&lt;/p&gt;
</description>
<category>Other</category>
<guid isPermaLink="true">https://coderlegion.com/21642/main-idea-of-least-squares-method-and-linear-regression</guid>
<pubDate>Tue, 07 Jul 2026 10:15:30 +0000</pubDate>
</item>
</channel>
</rss>