{ "cells": [ { "cell_type": "markdown", "id": "30a702e8-308e-4b19-ba7e-a456af040667", "metadata": { "tags": [] }, "source": [ "# Linear Regression" ] }, { "cell_type": "code", "execution_count": 1, "id": "3e2de384-b68e-4b8c-9233-6fa437417792", "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import random" ] }, { "cell_type": "markdown", "id": "e92509ce-594c-4042-8cc7-399c4a31a11c", "metadata": {}, "source": [ "Say there exists a linear relationship between an independent, explanatory variable $x$ and a dependent, response variable $y$. The relationship can be described in the form of a general **linear regression model**:" ] }, { "cell_type": "markdown", "id": "d3b9b32f-febd-4f12-af15-0fc8ecef7285", "metadata": {}, "source": [ "$$y = \\beta_0 + \\beta_1 x$$" ] }, { "cell_type": "markdown", "id": "82761915-8fa6-4069-bae7-eaea301f67ef", "metadata": {}, "source": [ "where $\\beta_0$ and $\\beta_1$ are the true (but unknown) constant values that express the relationship between $x$ and $y$. When modeling data in general, and especially in the real world, the data I obtain is almost always going to have some sort of deviation between the actual value of $y$ and the model's expected value of $y$ for any given $x$. These deviations are known as **errors**. So if I have a collection of $n$ observational $(x, y)$ data points in dataset $D$, I can more accurately describe the relationship between $x$ and $y$ for each observed data point as:" ] }, { "cell_type": "markdown", "id": "6b708365-a387-444e-b38c-47700e61c565", "metadata": {}, "source": [ "$$y_i = \\beta_0 + \\beta_1 x_i + \\epsilon_i$$" ] }, { "cell_type": "markdown", "id": "9188b10e-9481-4cb1-866c-8d9dda567df0", "metadata": {}, "source": [ "where $i$ is the $i^{th}$ term in the dataset $D$. Taking all data points into account, I can write this in matrix form:" ] }, { "cell_type": "markdown", "id": "706ea47f-0159-42b6-9d24-b3d7136ab4e8", "metadata": {}, "source": [ "$$\n", "\\begin{bmatrix}\n", " y_1 \\\\\n", " y_2 \\\\\n", " \\vdots \\\\\n", " y_n\n", "\\end{bmatrix}\n", "=\n", "\\begin{bmatrix}\n", " \\beta_0 + \\beta_1 x_1 \\\\\n", " \\beta_0 + \\beta_1 x_2 \\\\\n", " \\vdots \\\\\n", " \\beta_0 + \\beta_1 x_n\n", "\\end{bmatrix}\n", "+\n", "\\begin{bmatrix}\n", " \\epsilon_1 \\\\\n", " \\epsilon_2 \\\\\n", " \\vdots \\\\\n", " \\epsilon_n\n", "\\end{bmatrix}\n", "$$" ] }, { "cell_type": "markdown", "id": "05e149cf-b8aa-47f5-9b55-74aebcdff2b5", "metadata": {}, "source": [ "which is the same as:" ] }, { "cell_type": "markdown", "id": "a1ae0131-b1c5-4045-a167-78d26bca80c2", "metadata": {}, "source": [ "$$\n", "\\begin{bmatrix}\n", " y_1 \\\\\n", " y_2 \\\\\n", " \\vdots \\\\\n", " y_n\n", "\\end{bmatrix}\n", "=\n", "\\begin{bmatrix}\n", " 1 & x_1 \\\\\n", " 1 & x_2 \\\\\n", " \\vdots & \\vdots \\\\\n", " 1 & x_n\n", "\\end{bmatrix}\n", "\\begin{bmatrix}\n", " \\beta_0 \\\\\n", " \\beta_1\n", "\\end{bmatrix}\n", "+\n", "\\begin{bmatrix}\n", " \\epsilon_1 \\\\\n", " \\epsilon_2 \\\\\n", " \\vdots \\\\\n", " \\epsilon_n\n", "\\end{bmatrix}\n", "$$" ] }, { "cell_type": "markdown", "id": "a5607cf6-ecd1-4804-a31f-31ecf53e0bce", "metadata": {}, "source": [ "which can also be written as:" ] }, { "cell_type": "markdown", "id": "05628820-a616-4448-b8a5-1b7695157d04", "metadata": {}, "source": [ "$$ \\mathbf{Y} = \\mathbf{X}\\boldsymbol\\beta + \\boldsymbol\\epsilon$$" ] }, { "cell_type": "markdown", "id": "41aa5af5-d33b-4bf8-9a9a-09a53cbeda07", "metadata": {}, "source": [ "where $\\mathbf{Y}_{n \\times 1}$ is the vector of responses, $\\mathbf{X}_{n \\times 2}$ is the design matrix, $\\boldsymbol\\beta_{2 \\times 1}$ is the vector of parameters, and $\\boldsymbol\\epsilon_{n \\times 1}$ is the vector of error terms." ] }, { "cell_type": "markdown", "id": "4c76c58f-651f-432b-a51a-c198f8c77922", "metadata": {}, "source": [ "I expect my collection of data points to be a good representation of the total population. However, because my sample dataset doesn't contain the whole population, it is unlikely that the line of best fit calculated from my collection of data points will have parameters that are exactly equivalent to the true values of $\\beta_0$ and $\\beta_1$ (but theoretically it should be close if I took a good sample). That means the best model I can come up with given my dataset is:" ] }, { "cell_type": "markdown", "id": "f6e803ce-9225-43fc-82d5-ec2e681d98bc", "metadata": {}, "source": [ "$$\\hat{y} = \\hat{\\beta}_0 + \\hat{\\beta} x$$" ] }, { "cell_type": "markdown", "id": "c354e8c0-da97-4bb3-b3d9-0f0fb7a1529a", "metadata": {}, "source": [ "where $\\hat{\\beta}_0$ is my estimation of the true $\\beta_0$, $\\hat{\\beta}_1$ is my estimation of the true $\\beta_1$, and $\\hat{y}$ is the predicted $y$ value. For each observed data point, the relationship between $x$ and $y$ is then:" ] }, { "cell_type": "markdown", "id": "1b8554c3-a748-4fb0-a66b-1759bef17e03", "metadata": {}, "source": [ "$$y_i = \\hat{\\beta}_0 + \\hat{\\beta}_1 x_i + \\hat{\\epsilon}_i$$" ] }, { "cell_type": "markdown", "id": "f6b06e37-4573-4443-85d6-321f67e049c6", "metadata": {}, "source": [ "where $\\hat{\\epsilon}_i$ is the **residual** value for point $i$. The residual value is the difference in distance between the $y$ value predicted by the model and the $y$ value in the dataset." ] }, { "cell_type": "markdown", "id": "0d0f6a78-f540-4483-96cb-d53c330c42b6", "metadata": {}, "source": [ "In matrix form, the relationship is:" ] }, { "cell_type": "markdown", "id": "a09cddda-149c-4061-bbd0-8bae31b0a443", "metadata": {}, "source": [ "$$ \\mathbf{Y} = \\mathbf{X}\\hat{\\boldsymbol\\beta} + \\hat{\\boldsymbol\\epsilon}$$" ] }, { "cell_type": "markdown", "id": "6a37666f-bc42-42a1-ab3d-1d7a569616e7", "metadata": {}, "source": [ "Now, say I have collected some pairs of $x$ and $y$ samples and stored those values in a dataset $D$. Perhaps my dataset contains these specific values:" ] }, { "cell_type": "markdown", "id": "a1a9789e-9ee9-42c3-8a20-2173cc9f3913", "metadata": {}, "source": [ "$$D = [(-1.5, 4),(-0.1, 4),(0.6, 3.1),(2.3, 0.3),(-1.2, 2.4),(1.6, 0.4),(1.7, 1.2),(-0.2, 2.4),(0.7, 2.3),(0.5, 1.75)]$$" ] }, { "cell_type": "markdown", "id": "1d4044e1-9a60-4f8a-a325-a9dd289e55f2", "metadata": {}, "source": [ "I can quickly graph a scatterplot of the data to get a glimpse of what the data looks like:" ] }, { "cell_type": "code", "execution_count": 2, "id": "301d9da2-da21-4602-aa84-9909d6b21c08", "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEWCAYAAABrDZDcAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAApYklEQVR4nO3deZxcVZn/8c+XEKBla4GIpAmEzbiAEsiwCDODKEYRQkQUFJQwKjIjAzoShyjDIC4omeHngoiMKCAYEQghIE6IAirI1iGBACFD2IQOSgATEmkhhOf3xzkNlU519e3lVi/1fb9e9cqtc7enbnXuU/eec89RRGBmZo1rvYEOwMzMBpYTgZlZg3MiMDNrcE4EZmYNzonAzKzBORGYmTU4JwKzKiSdIenSOu1rP0kPSVolaXI99mlWyYnA+kTS/pL+IGmFpOck3Srp7/q4zSmSbulUdpGkr/Ut2nX2c5Gkl/IJ+DlJcyW9uRfbeUzSe/oQypnAuRGxSUTM6mL77ZJWSlqej/cJkgr9/5U0VlJIWr8PMQ6a/Vj/cyKwXpO0GXAd8D1gC6AF+Arw4kDGVU2Nk9PZEbEJsC3wNHBR3YJ6zfbA/d0sc2hEbJqX/Sbw78CFZQdmjcGJwPriTQARMSMi1kREe0TcEBH3diwg6dOSFuVfsw9I2iOXnyrp4YryD+bytwDnA/vmX+rLJR0PHA18MZddm5cdLekqScskPSrppIr9niHpSkmX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Rd6xj1Rsf39+p3FxE/I13ttAPXS3JX3SVxIrBqHgTGVtx7/mjFvDnAv0qv1iWMr5h3kNI4x02kk8atpF+kRyiN9dAxDvL23ez/VtKJGeDoTvv+p/yLFkktHdutYSVpOMGuzAD+jTTozm25bHNe6zL42GorVVG5zpRO86odl0rdfq6IWEK6Yjitovg04O48D2CvXL+yHnAkcItSj7DrRcRVefk9ItWPPCrpw3l/kvSOah8qJ+qrgXNIvW129PLZ1TGqerwjYgXwl477/8DHSXU0XVIa3+KRiPguqefbt9da3nrPicDWERF/I90K+qVSZXHlOARfJd32uFfS/axdeXknqY/2e0m3WVoj4gHSCegGSfeS7l13N2TfycBnJS2kYlSniLgB+BlwW553JbVP8pDueZ+vTpXFFeaS6gcur7g6OYN022QeULSP+7OBsyTNZ92rkXWOS+XMHnyuTwJvUmo6+jDwplzW4S7gXFK31o+STuAtwM35tt+lwLS87NHAJyV19LpbazjNy4FjeO22EHR9jK4FPthRWdxpO8cC0/Pfwe6keoJaPgLcl2PfFXDro5K491HrF5KmkCpBTxzoWMysZ3xFYGbW4HxFYGbW4HxFYGbW4JwIzMwanBOBmVmDcyIwM2twTgRmZg3u/wNqTgb7v3tm2AAAAABJRU5ErkJggg==\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "dataset = [(-1.5, 4),(-0.1, 4),(0.6, 3.1),(2.3, 0.3),(-1.2, 2.4),(1.6, 0.4),(1.7, 1.2),(-0.2, 2.4),(0.7, 2.3),(0.5, 1.75)]\n", "\n", "plt.title(\"Scatter Plot of Dataset\")\n", "plt.xlabel(\"Independent Variable Observations\")\n", "plt.ylabel(\"Dependent Variable Observations\")\n", "plt.scatter(x=[p[0] for p in dataset], y=[p[1] for p in dataset])\n", "plt.show()" ] }, { "cell_type": "markdown", "id": "021da571-af3a-4a84-a6d4-0624dd18b23b", "metadata": {}, "source": [ "From here, I want to figure out what is the line of best fit." ] }, { "cell_type": "markdown", "id": "a55031e7-7e96-4446-9e79-7e812a4f6732", "metadata": { "tags": [] }, "source": [ "## Least Absolute Deviations" ] }, { "cell_type": "markdown", "id": "36d29ba2-7c42-4a6f-8195-89c52e7c5ff9", "metadata": {}, "source": [ "One (less popular) way of finding the line of best is to create a function takes in two inputs $(\\hat{\\beta}_0, \\hat{\\beta}_1)$ and calculates the total residual sum between the line and each given data point. The parameters that minimize the residual sum will be the parameters of the best fit regression line. This residual sum function is:" ] }, { "cell_type": "markdown", "id": "f8cb6e32-4a48-4df7-8841-de0b30b73ad8", "metadata": {}, "source": [ "$$RS = \\sum\\limits_{i = 1}^{n} |\\hat{\\epsilon}_i| = \\sum\\limits_{i = 1}^{n} |y_i - \\hat{\\beta}_0 - \\hat{\\beta}_1 x_i|$$" ] }, { "cell_type": "markdown", "id": "cc58cf2d-9978-41d2-99a8-0251ba70ed61", "metadata": {}, "source": [ "where $n$ represents the number of data points in the dataset and $i$ represents the $i^{th}$ data point." ] }, { "cell_type": "markdown", "id": "82c4bb0d-223e-45cd-8a4f-f34140bf6a0c", "metadata": {}, "source": [ "This is an optimization problem where I have to find the inputs $(\\hat{\\beta}_0, \\hat{\\beta}_1)$ that produce the smallest $RS$ output. To find the smallest output, I can look for the critical points that make all first-order partial derivates of the residual sum function either equal to $0$ or undefined. The **gradient** for the $RS$ function is:" ] }, { "cell_type": "markdown", "id": "42bf87e8-019b-4f9d-94c3-2e47a8e0931e", "metadata": {}, "source": [ "$$\n", "\\nabla RS =\n", "\\begin{bmatrix}\n", " RS_{\\hat{\\beta}_0} \\\\\n", " RS_{\\hat{\\beta}_1}\n", "\\end{bmatrix}\n", "=\n", "\\begin{bmatrix}\n", " \\sum\\limits_{i = 1}^{n} \\frac{y_i - \\hat{\\beta}_0 - \\hat{\\beta}_1 x_i}{|y_i - \\hat{\\beta}_0 - \\hat{\\beta}_1 x_i|} \\\\\n", " \\sum\\limits_{i = 1}^{n} \\frac{-x_i(y_i - \\hat{\\beta}_0 - \\hat{\\beta}_1 x_i)}{|y_i - \\hat{\\beta}_0 - \\hat{\\beta}_1 x_i|}\n", "\\end{bmatrix}\n", "$$" ] }, { "cell_type": "markdown", "id": "a306b9c5-a28c-4e93-a103-17d6eca3ceaa", "metadata": {}, "source": [ "It's easy to see all the $\\hat{\\beta}_0$, $\\hat{\\beta}_1$ values that make the gradient undefined. As long as values are picked such that $y_i = \\hat{\\beta}_0 + \\hat{\\beta}_1 x_i$ for every $(x_i,y_i)$ in the dataset, those values are supposedly possible candidates that minimze the residual sum function. However, it is much harder to solve for the $\\hat{\\beta}_0$, $\\hat{\\beta}_1$ values that make $\\nabla RS$ equal to the zero vector." ] }, { "cell_type": "markdown", "id": "a8336528-baae-433f-bec3-855e8a9f3151", "metadata": {}, "source": [ "There are a few things I can note here in my attempt to find values that make $\\nabla RS$ equal to $\\mathbf{0}_{2 \\times 1}$. One note is that each term in the $RS_{\\hat{\\beta}_0}$ summation is essentially a modified signum function that takes in two inputs. As long as the denominator for a particular term is defined, the term is simplified to either a value of $-1$ or $1$. This means that, for an odd number of data points, this sum can never total to $0$, meaning $\\nabla RS$ can never equal the zero vector. However, for an even number of data points, finding values that produce $0$ is still an issue." ] }, { "cell_type": "markdown", "id": "4f2897f3-157e-452a-ab7b-d63a73314ec1", "metadata": {}, "source": [ "Another note is that in order for $\\nabla RS$ to be equal to the zero vector, $RS_{\\hat{\\beta}_0}$ must be equal to zero. It may be easier to find the $\\hat{\\beta}_0$, $\\hat{\\beta}_1$ values that make $RS_{\\hat{\\beta}_0}$ equal to $0$ and then plug those $\\hat{\\beta}_0$, $\\hat{\\beta}_1$ values into $RS_{\\hat{\\beta}_1}$ and filter out the inputs that do not make $RS_{\\hat{\\beta}_1}$ equal to $0$." ] }, { "cell_type": "markdown", "id": "4e598196-fdbf-472a-8c18-899363042ab8", "metadata": {}, "source": [ "Even with these observations, it is still difficult to solve for the $\\hat{\\beta}_0$, $\\hat{\\beta}_1$ that make $\\nabla RS$ equal to the zero vector, so a different approach is needed to find the line of best fit." ] }, { "cell_type": "markdown", "id": "ccec2925-bd58-4b79-97a9-899d85627742", "metadata": {}, "source": [ "Let me assume for a moment that there is only one point in my dataset. The line of best fit is any line that passes through the data point and there are an infinte amount of these lines. Every possible best fit line can be defined with $\\hat{\\beta}_0$, $\\hat{\\beta}_1$ values that makes the expression $y_1 = \\hat{\\beta}_0 + \\hat{\\beta}_1 x_1$ true. For two points in a dataset, there is only one line of best fit - the line that passes through the two points. This line can be expressed with the $\\hat{\\beta}_0$, $\\hat{\\beta}_1$ values that satisfies the system of equations $y_1 = \\hat{\\beta}_0 + \\hat{\\beta}_1 x_1$ and $y_2 = \\hat{\\beta}_0 + \\hat{\\beta}_1 x_2$. Somewhat intuitively, these two linear equations represent the lines where $\\nabla RS$ is undefined. Each $\\hat{\\beta}_0$, $\\hat{\\beta}_1$ value generated by each line is a solution to the optimization problem that \"minimizes\" the distance between the regression line and its corresponding point. So naturally, the most optimal solution for two data points are where these two lines intersect each other." ] }, { "cell_type": "markdown", "id": "6a115345-6d2f-4201-94e2-2c06246a372b", "metadata": {}, "source": [ "With an addition of a third data point to data set, this produces a third line that makes $\\nabla RS$ undefined. Unless all three points happen to be perfectly aligned, in general, linear regression on a dataset of three or more points will produce a non-zero residual sum. This behavior is reflected when graphing on a plane the three lines that make $\\nabla RS$ undefined - the three lines all interesect each other at three different points. The $\\hat{\\beta}_0$, $\\hat{\\beta}_1$ values at these three intersections correspond to three regression lines where each regression line is essentially a line drawn across every possible pairing of points. One of these three lines will be a solution to the best fit line for least absolute deviations." ] }, { "cell_type": "markdown", "id": "80ba35d3-ab50-424d-a164-5b977ee92bc4", "metadata": {}, "source": [ "Following this pattern for $n$ number of points in my data set, I can (very loosely) conclude that I can find the best fit line by finding every line for every possible pairing of points, calculate each ones $RS$ value, and keeping the one that ends up giving me the smallest $RS$ value. According to [Wikipedia](https://en.wikipedia.org/wiki/Least_absolute_deviations#Solution) (pulled on 10 May 2022), _Since it is known that at least one least absolute deviations line traverses at least two data points, this method will find a line by comparing the SAE (Smallest Absolute Error over data points) of each line, and choosing the line with the smallest SAE_, so the strategy works. I'll have to revisit this section at some point to really find a more full and comprehensive way of getting the best fit line, but this is fine for now." ] }, { "cell_type": "code", "execution_count": 3, "id": "54d742f4-45a3-44bc-80f2-e41b8e38d692", "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEWCAYAAABrDZDcAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAA510lEQVR4nO3dd3xUdfb/8dc7IUDoUkSINAVRmpSIAgo2BBUBARVddW2rrg1lbexvLavuirpfVCzYexcQUFFAUSIgKEhvCohgAClKkw7n98e92Y0hZUIymSRzno/HfThz65kbnDP387n3fGRmOOeci18JsQ7AOedcbHkicM65OOeJwDnn4pwnAueci3OeCJxzLs55InDOuTjnicDFjKT6krZJSozCvu+V9MZBbPeMpLsKO55w3w9I2iBpbTT279zB8kTgIibpMknzJG2XtFbSMEnV8rH9CkmnZ7w3s5VmVsnM9kUl4JzjOFnSz9ktM7Nrzez+KByzPvA3oJmZHVZI+zRJv4fJdKOkzyVdkI/tczwPhamojuMOnicCFxFJfwMeAm4DqgInAA2ACZLKxjK2EqI+sNHM1uV3Q0llcll8rJlVApoCrwBPSrrn4EJ0ccvMfPIp1wmoAmwDzs8yvxKwHrgifH8vMBx4F9gKfEfwRQXwOrAf2BHu63agIWBAmXCdL4EHgKnhOh8CNYA3gS3At0DDTMd/HFgVLpsJnJRp2b3AGzl8npOBn3NY9grwQOb1CH7JrwPWAJdnWrcc8B9gJfAL8AyQnM0+Tw8/9/7wc70Szu8JLAA2hZ/9mEzbrADuAOYCuzLOUZb9GtA4y7x+wE6gRvj+cmBR+PdYDlwTzq+YJaZtQF2gPfB1GNMa4EmgbLiNgEfDc7EFmAe0yO1c5HScWP+b9umPk18RuEh0BM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aQRl+z7oTSeWBp4F+ZtYSeD7LNlnrpWR9nwCcEP5Cbm1mKQeZBJYB9RUWK8ykHUFiyjYWC8ZGaE/wBd4D+DSCuH7PtIN0YGN45XQB/0uW9wNfhFdJ5/DHc3IwdmV6rfDYaQQjh6UDr0i6tIDHcMWIJwIXdeGX2hcEzTUZncRVCL7kNoe/Os/MYfPMMr7gNoS/mPtlWX4BgKQTCao9bs6yfDxwY8YbSa3z8TH+y8x+JxhDYIikxHBflxJcpUwMV6svqUP4+iJgchhzVTMbC9xC0MSS37jeBW4P95Nx9VSV/5U4vizTulsJOrSzM5X/deL/Cfgql2MiqQHwi5k9T9B0VbzH4HX54onAFZW3Cb74Mppv5gCzCNq33wKm5LxpwMw2EVwFzAfGETRXZLZT0izgGf7X/JTZTUBq2EG6kKBa5AEkrQCGAJdJ+llSs2xWG0TQzPO9pB+A84Bz7X9VHJcA10taBBwCDCP4Uv5I0lxgMjAwP3GFhhP2s2Sa9zDwYPjZMzf3fkHQ5DRb0gVZ9nMjcHkYyyXAAQOwZ3EyMCc8xgUE/RqulPDqo845F+f8isA55+KcJwLnnItzngiccy7OeSJwzrk454nAOefinCcC55yLc54InHMuzv1/3igGd9J3uosAAAAASUVORK5CYII=\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Optimal Line: y = 2.539473684210526 + -0.9736842105263159x\n", "Smallest Residual Sum: 5.792105263157895\n" ] } ], "source": [ "rs_func = lambda b_0_hat, b_1_hat: sum([abs(y_i - b_0_hat - b_1_hat * x_i) for x_i, y_i in dataset])\n", "\n", "min_rs_sum = float(\"inf\")\n", "b_0_hat = None\n", "b_1_hat = None\n", "\n", "for i in range(0, len(dataset) - 1):\n", " for j in range(i + 1, len(dataset)):\n", " b_1_hat_candidate = (dataset[i][1] - dataset[j][1]) / (dataset[i][0] - dataset[j][0])\n", " b_0_hat_candidate = dataset[i][1] - b_1_hat_candidate * dataset[i][0]\n", " rs_sum = rs_func(b_0_hat_candidate, b_1_hat_candidate)\n", " if rs_sum < min_rs_sum:\n", " min_rs_sum = rs_sum\n", " b_0_hat = b_0_hat_candidate\n", " b_1_hat = b_1_hat_candidate\n", "\n", "x_vals = np.linspace(min([x_i for x_i, y_i in dataset]), max([x_i for x_i, y_i in dataset]), num=100)\n", "y_vals = b_0_hat + b_1_hat * x_vals\n", "\n", "plt.title(\"Optimal Line for Dataset\")\n", "plt.xlabel(\"Variable 1 Observations\")\n", "plt.ylabel(\"Variable 2 Observations\")\n", "plt.scatter(x=[p[0] for p in dataset], y=[p[1] for p in dataset])\n", "plt.plot(x_vals, y_vals)\n", "plt.show()\n", "\n", "print(\"Optimal Line: y = {} + {}x\".format(b_0_hat, b_1_hat))\n", "print(\"Smallest Residual Sum:\", rs_func(b_0_hat, b_1_hat))" ] }, { "cell_type": "markdown", "id": "125ed10b-ca03-4324-bbc4-a3403c5c3097", "metadata": {}, "source": [ "One important thing to note is it is possible for there to be multiple lines of best fit for least absolute deviations. Consider the simple dataset of points $D = [(0, 0),(0, 1),(1, 0),(1, 1)]$. $y = 0.5$ and $y = x$ would both produce the same smallest $RS$ value and are both solutions to the optimization problem." ] }, { "cell_type": "markdown", "id": "1cf4ed06-feeb-4859-a127-8977f28b67e7", "metadata": {}, "source": [ "Finding the regression line for least absolute deviations DOES NOT have a **closed form solution** because it can only be solve iteratively through trial and error." ] }, { "cell_type": "markdown", "id": "7460aa56-85ca-4ab6-856d-5628c097c1be", "metadata": {}, "source": [ "The runtime of finding the least absolute deviations regression line is $O(n^2)$, assuming the residual sum function was hard coded (which is not the case here - my code has a cubic running time)." ] }, { "cell_type": "markdown", "id": "b15e6154-9910-46af-ad18-da672d8f1ae2", "metadata": { "tags": [] }, "source": [ "## Least Squares" ] }, { "cell_type": "markdown", "id": "5d05ae04-9f9a-4ae1-a9c4-40b095623d27", "metadata": {}, "source": [ "The least squares method is a more popular way of finding the line of best fit. It is another way of measuring the discrepancies between a data points and a regression line. Intuitively, it doesn't make that much sense to me why we square the vertical residuals - and maybe there isn't any intuitive meaning behind the squared distances at all. The only thing least squares really has going for it is that finding the regression line is supposedly less complicated. Plus, squaring each residual doesn't make \"that big of a difference\". Larger residuals will be more exaggerated due to the squaring and likewise smaller residuals ($<1$) will be less exaggerated." ] }, { "cell_type": "markdown", "id": "263959b4-ade0-43ab-b873-82b85147f49b", "metadata": { "tags": [] }, "source": [ "### Direct Calculation" ] }, { "cell_type": "markdown", "id": "afec7521-ce7e-4465-b6cc-294357fac575", "metadata": {}, "source": [ "In order to find the line of best fit, I can create a function that takes in two inputs $(\\hat{\\beta}_0, \\hat{\\beta}_1)$ and calculates the total sum of squared residuals. The parameters that minimize the squared residual sum will be the parameters of the best fit regression line. The squared residual sum function is:" ] }, { "cell_type": "markdown", "id": "c81510fd-5786-434f-99ff-687be798ed50", "metadata": {}, "source": [ "$$RSS = \\sum\\limits_{i = 1}^{n} {\\hat{\\epsilon}_i}^2 = \\sum\\limits_{i = 1}^{n} (y_i - \\hat{\\beta}_0 - \\hat{\\beta}_1 x_i)^2$$" ] }, { "cell_type": "markdown", "id": "4c9e186a-83f9-4201-9ffc-aa468e8bb5a3", "metadata": {}, "source": [ "where $n$ represents the number of data points in the dataset and $i$ represents the $i^{th}$ data point." ] }, { "cell_type": "markdown", "id": "e0852a03-be8a-4ab4-a280-99b70f6228f8", "metadata": {}, "source": [ "This is an optimization problem where I have to find the inputs $(\\hat{\\beta}_0, \\hat{\\beta}_1)$ that produce the smallest $RSS$ output. To find the smallest output, I can look for the critical points that make all first-order partial derivates of the residual sum function equal to $0$. The **gradient** for the $RSS$ function is:" ] }, { "cell_type": "markdown", "id": "75ae561d-f62f-4583-96e0-53eaa3423077", "metadata": {}, "source": [ "$$\n", "\\nabla RSS =\n", "\\begin{bmatrix}\n", " RSS_{\\hat{\\beta}_0} \\\\\n", " RSS_{\\hat{\\beta}_1}\n", "\\end{bmatrix}\n", "=\n", "\\begin{bmatrix}\n", " \\sum\\limits_{i = 1}^{n} -2(y_i - \\hat{\\beta}_0 - \\hat{\\beta}_1 x_i) \\\\\n", " \\sum\\limits_{i = 1}^{n} -2x_i(y_i - \\hat{\\beta}_0 - \\hat{\\beta}_1 x_i)\n", "\\end{bmatrix}\n", "$$" ] }, { "cell_type": "markdown", "id": "d58882f4-3dc7-4636-a6d5-f24075b0ed27", "metadata": {}, "source": [ "Focusing on the first term in $\\nabla RSS$ first, I set $RSS_{\\hat{\\beta}_0}$ equal to $0$ and solve for either $\\hat{\\beta}_0$ or $\\hat{\\beta}_1$ (both are shown for good measure):" ] }, { "cell_type": "markdown", "id": "00ddca2b-9886-4fcb-9011-65e7f42fcbd0", "metadata": {}, "source": [ "$$\\hat{\\beta}_0 = \\frac{\\sum\\limits_{i = 1}^{n} (y_i - \\hat{\\beta}_1 x_i)}{n} \\quad \\hat{\\beta}_1 = \\frac{\\sum\\limits_{i = 1}^{n} (y_i - \\hat{\\beta}_0)}{\\sum\\limits_{i = 1}^{n} x_i}$$" ] }, { "cell_type": "markdown", "id": "2b0d17bc-2560-4b32-b172-d7f633315410", "metadata": {}, "source": [ "Now for the second term term in $\\nabla RSS$, I set $RSS_{\\hat{\\beta}_1}$ equal to $0$ and solve for either $\\hat{\\beta}_0$ or $\\hat{\\beta}_1$ (again both are shown for good measure):" ] }, { "cell_type": "markdown", "id": "99105ee4-60d7-4532-b4a6-5b335f2714e6", "metadata": {}, "source": [ "$$\\hat{\\beta}_0 = \\frac{\\sum\\limits_{i = 1}^{n} x_i(y_i - \\hat{\\beta}_1 x_i)}{\\sum\\limits_{i = 1}^{n} x_i} \\quad \\hat{\\beta}_1 = \\frac{\\sum\\limits_{i = 1}^{n} x_i(y_i - \\hat{\\beta}_0)}{\\sum\\limits_{i = 1}^{n} {x_i}^2}$$" ] }, { "cell_type": "markdown", "id": "01a26596-c8af-45da-b60a-79d14fc9c626", "metadata": {}, "source": [ "The $\\hat{\\beta}_0$, $\\hat{\\beta}_1$ values that satisfy the expressions first $\\hat{\\beta}_1$ equals second $\\hat{\\beta}_1$, first $\\hat{\\beta}_0$ equals second $\\hat{\\beta}_0$ respectively are calculated below:" ] }, { "cell_type": "markdown", "id": "334b1b51-6b10-4ea1-8183-0fa8391a2699", "metadata": {}, "source": [ "$$\\hat{\\beta}_0 = \\frac{\\left(\\sum\\limits_{i = 1}^{n} {x_i}^2\\right)\\left(\\sum\\limits_{i = 1}^{n} y_i\\right) - \\left(\\sum\\limits_{i = 1}^{n} x_i\\right)\\left(\\sum\\limits_{i = 1}^{n} x_iy_i\\right)}{n\\sum\\limits_{i = 1}^{n} {x_i}^2 - \\left(\\sum\\limits_{i = 1}^{n} x_i\\right)^2} \\quad\\text{and}\\quad \\hat{\\beta}_1 = \\frac{n\\sum\\limits_{i = 1}^{n} x_iy_i - \\left(\\sum\\limits_{i = 1}^{n} x_i\\right)\\left(\\sum\\limits_{i = 1}^{n} y_i\\right)}{n\\sum\\limits_{i = 1}^{n} {x_i}^2 - \\left(\\sum\\limits_{i = 1}^{n} x_i\\right)^2}$$" ] }, { "cell_type": "markdown", "id": "c758b2bb-8640-49e3-8c02-6ed404fabe5c", "metadata": {}, "source": [ "Therefore the equation for the regression line can be quickly calculated using the formulas above." ] }, { "cell_type": "code", "execution_count": 4, "id": "89ff366e-c738-4117-8826-00a3e60e7e0f", "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEWCAYAAABrDZDcAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAA480lEQVR4nO3dd3hUZfbA8e9JARJaBCK9d5SOSCegiBQRWRR0FXFRxIoouOKurj911wKLi4K4qIhdFBGQIioQqiih10gXQgephpac3x/3xo0hZVKmJHM+zzOPd249c4Nz5t7z3vcVVcUYY0zwCvF3AMYYY/zLEoExxgQ5SwTGGBPkLBEYY0y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IeX20Az3v4Pc+beJ0+13GM6XTwOcx/bB+dJLTycReRKIBErhdDXwdarjoKqLRaSEiESl2fZ6oEGqi4gSIlJMVc/k4rNlZK+qLnOnPwIeBf6Dc6XxrojMAmZlFpc7PVNVE93pz4FvgX/gJISp7vySwPsiUhun64NwD+JrDfRxpz/kjx3fTVfVZGCziKR0Pb4SmCROZ2vTVXWtB8cw+YRdERhfmIEzOEwznF/tq0SkOs59+OvcX6WzcfoISnE27U5EpAjwJtBXVRsCb6fZJm1/KWnfhwCt3F/ITVS1Yg6TwA6giridFabSHCcxpRuLOmMjtMT5Au8JfONBXGdT7SABOOZeOfXjf8nyBWChe5V0E388JzlxPtW0uMdejDNyWAIwWUQG5PIYJoBYIjBe536pLcS5XZNSJC6B8yV30v3V2S2DzVNL+YI76v5i7ptmeT8AEWmH09vjyTTLvwUeSXkjIk2y8TF+p6pnccYQGCMioe6+BuBcpSxwV6siIq3d6TuApW7MJVV1DjAM5xZLduOaAjzp7ifl6qkk/+vieGCqdU/jFLTTs5z/FfH/DCzJ5JiISFXgkKq+jXPrKrDH4DXZYonA+MqnOF98Kbdv1gFrcO5vfwIsy3hTh6qewLkK2AjMw7ldkdo5EVkDvMX/bj+l9ijQwi2QbsbpLfIyIrIbGAMMFJF9ItIgndVG4tzm+VlEtgG3Arfo/3pxjAceEpEtwBXABJwv5Vkish5YCjyenbhcU3HrLKnmvQq85H721Ld7F+LcclorIv3S7OcR4B43lruAywZgTyMGWOceox9OXcMUENb7qDHGBDm7IjDGmCBnicAYY4KcJQJjjAlylgiMMSbIWSIwxpggZ4nAGGOCnCUCY4wJcv8PTy6NAtBx8CMAAAAASUVORK5CYII=\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Optimal Line: y = 2.5609865142187043 + -0.8545148050425098x\n", "Residual Sum of Squares: 5.467461888009383\n" ] } ], "source": [ "rss_func = lambda b_0_hat, b_1_hat: sum([(y_i - b_0_hat - b_1_hat * x_i)**2 for x_i, y_i in dataset])\n", "\n", "b_0_hat = (sum([x_i**2 for x_i, y_i in dataset]) * sum([y_i for x_i, y_i in dataset]) - sum([x_i for x_i, y_i in dataset]) * sum([x_i * y_i for x_i, y_i in dataset])) / (len(dataset) * sum([x_i**2 for x_i, y_i in dataset]) - sum([x_i for x_i, y_i in dataset])**2)\n", "b_1_hat = (len(dataset) * sum([x_i * y_i for x_i, y_i in dataset]) - sum([x_i for x_i, y_i in dataset]) * sum([y_i for x_i, y_i in dataset])) / (len(dataset) * sum([x_i**2 for x_i, y_i in dataset]) - sum([x_i for x_i, y_i in dataset])**2)\n", "\n", "x_vals = np.linspace(min([x_i for x_i, y_i in dataset]), max([x_i for x_i, y_i in dataset]), num=100)\n", "y_vals = b_0_hat + b_1_hat * x_vals\n", "\n", "plt.title(\"Optimal Line for Dataset\")\n", "plt.xlabel(\"Variable 1 Observations\")\n", "plt.ylabel(\"Variable 2 Observations\")\n", "plt.scatter(x=[p[0] for p in dataset], y=[p[1] for p in dataset])\n", "plt.plot(x_vals, y_vals)\n", "plt.show()\n", "\n", "print(\"Optimal Line: y = {} + {}x\".format(b_0_hat, b_1_hat))\n", "print(\"Residual Sum of Squares:\", rss_func(b_0_hat, b_1_hat))" ] }, { "cell_type": "markdown", "id": "cb86f6d4-770a-48e0-8d4c-8099ddba27eb", "metadata": {}, "source": [ "Since the parameters $\\hat{\\beta}_0$, $\\hat{\\beta}_1$ can be calculated directly using a couple of formulas, the best fit line for least squares has a **closed form solution**." ] }, { "cell_type": "markdown", "id": "b8873062-dd73-4dd2-8181-5b718c097d46", "metadata": {}, "source": [ "The runtime of finding the least squares regression line is $O(n)$ since I only have to loop through the entire dataset a constant number of times to get the regression line." ] }, { "cell_type": "markdown", "id": "4eef81c2-cb99-44da-a1a4-1ce8aaef1d57", "metadata": { "tags": [] }, "source": [ "### Matrix Calculation" ] }, { "cell_type": "markdown", "id": "60cc7313-3805-497c-bbb7-b6527ccd8f64", "metadata": {}, "source": [ "The parameters $\\hat{\\beta}_0$, $\\hat{\\beta}_1$ can also be quickly calculated using matrices. I want to minimize the squared residual sum. In matrix form, the squared residual sum function can be represented as:" ] }, { "cell_type": "markdown", "id": "bd182bf0-0729-40a2-8260-7bfdb99e72fe", "metadata": {}, "source": [ "$$RSS = \\hat{\\boldsymbol\\epsilon} \\cdot \\hat{\\boldsymbol\\epsilon} = \\hat{\\boldsymbol\\epsilon}^\\top\\hat{\\boldsymbol\\epsilon}$$" ] }, { "cell_type": "markdown", "id": "5d7b51b5-305a-4a7b-aa9f-d2af1f23be6d", "metadata": {}, "source": [ "Above, I am just taking the dot product of the residual vectors, which is the same as the matrix product of the $1 \\times n$ row vector $\\hat{\\boldsymbol\\epsilon}^\\top$ by the $n \\times 1$ column vector $\\hat{\\boldsymbol\\epsilon}$, which is essentially just taking the total sum of each squared residual term." ] }, { "cell_type": "markdown", "id": "741ea8f2-58ff-4c0a-afa6-cbb98da37724", "metadata": {}, "source": [ "The $RSS$ function can be written in terms of $\\mathbf{Y}$, $\\mathbf{X}$, and $\\hat{\\boldsymbol\\beta}$:" ] }, { "cell_type": "markdown", "id": "1005db87-da72-470b-81b3-51cbe0b421c4", "metadata": {}, "source": [ "$$RSS = (\\mathbf{Y} - \\mathbf{X}\\hat{\\boldsymbol\\beta})^\\top(\\mathbf{Y} - \\mathbf{X}\\hat{\\boldsymbol\\beta})$$" ] }, { "cell_type": "markdown", "id": "5618d9e3-c78b-4e4a-8c9f-5e5df938b176", "metadata": {}, "source": [ "Expanding and simplifying:" ] }, { "cell_type": "markdown", "id": "38a96dba-04b6-4604-8f83-3df88d5285e5", "metadata": {}, "source": [ "$$\n", "RSS = \\mathbf{Y}^\\top\\mathbf{Y} - \\mathbf{Y}^\\top\\mathbf{X}\\hat{\\boldsymbol\\beta} - \\hat{\\boldsymbol\\beta}^\\top\\mathbf{X}^\\top\\mathbf{Y} + \\hat{\\boldsymbol\\beta}^\\top\\mathbf{X}^\\top\\mathbf{X}\\hat{\\boldsymbol\\beta} \\\\\n", "RSS = \\mathbf{Y}^\\top\\mathbf{Y} - 2\\mathbf{Y}^\\top\\mathbf{X}\\hat{\\boldsymbol\\beta} + \\hat{\\boldsymbol\\beta}^\\top\\mathbf{X}^\\top\\mathbf{X}\\hat{\\boldsymbol\\beta}\n", "$$" ] }, { "cell_type": "markdown", "id": "e2d5093c-f380-4d5d-b406-94c6c3ac2571", "metadata": {}, "source": [ "Now, I can take the derivative of $RSS$ with respect to $\\hat{\\boldsymbol\\beta}$ and set that derivative equal to the zero vector in order to find the $\\hat{\\boldsymbol\\beta}$ vector that minimizes the $RSS$ function. This is akin to setting the gradient equal to $\\mathbf{0}$ in the previous section." ] }, { "cell_type": "markdown", "id": "5daffb76-b9c6-4625-a91e-7f1238993c0a", "metadata": {}, "source": [ "So how do I take the derivative of the whole $RSS$ function with respect to $\\hat{\\boldsymbol\\beta}$? There are two important concepts to apply here in order to differentiate the terms correctly." ] }, { "cell_type": "markdown", "id": "90ae2b07-5d76-43ca-b257-f720f834032a", "metadata": {}, "source": [ "The first concept is this: say I have a column vector $\\vec{a}$ and a another column vector $\\vec{b}$ of the same dimensions as $\\vec{a}$ and I want to take the derivative of the dot product with respect to $\\vec{b}$. The dot product can be written in any of the following forms:" ] }, { "cell_type": "markdown", "id": "8f68d63d-0ba6-4a99-b8d3-7b93e18f98df", "metadata": {}, "source": [ "$$\\vec{a} \\cdot \\vec{b} = \\vec{b} \\cdot \\vec{a} = a^\\top b = b^\\top a$$" ] }, { "cell_type": "markdown", "id": "606b4e83-63f4-41b1-8780-bf82a2865887", "metadata": {}, "source": [ "The derivative of this product with respect to column vector $\\vec{b}$ is always going to be column vector $\\vec{a}$ so this means:" ] }, { "cell_type": "markdown", "id": "fa9a8d50-ff44-4be0-9ed7-a29e2ae5bff0", "metadata": {}, "source": [ "$$\\frac{\\partial}{\\partial \\vec{b}}(a^\\top b) = \\frac{\\partial}{\\partial \\vec{b}}(b^\\top a) = \\vec{a}$$" ] }, { "cell_type": "markdown", "id": "b0187bb1-5259-499d-b239-d765d21598be", "metadata": {}, "source": [ "The second concept I'll apply is the $uv$ differentiation formula:" ] }, { "cell_type": "markdown", "id": "45cd789d-87b9-405d-ab54-e457a75e45ef", "metadata": {}, "source": [ "$$(uv)' = u'v + uv'$$" ] }, { "cell_type": "markdown", "id": "c109f8dc-6fda-4bb4-ba21-8f65470114b0", "metadata": {}, "source": [ "Now, I have the tools needed to take the derivative of $RSS$ with respect to $\\hat{\\boldsymbol\\beta}$. The derivative of the $RSS$ function with respect to $\\hat{\\boldsymbol\\beta}$ is:" ] }, { "cell_type": "markdown", "id": "f522755e-363b-45f9-abee-894a9e717624", "metadata": {}, "source": [ "$$\n", "RSS_{\\hat{\\boldsymbol\\beta}} = -2(\\mathbf{Y}^\\top\\mathbf{X})^\\top(\\hat{\\boldsymbol\\beta})' + (\\hat{\\boldsymbol\\beta}^\\top)'\\mathbf{X}^\\top\\mathbf{X}\\hat{\\boldsymbol\\beta} + (\\hat{\\boldsymbol\\beta}^\\top\\mathbf{X}^\\top\\mathbf{X})^\\top(\\hat{\\boldsymbol\\beta})' \\\\\n", "RSS_{\\hat{\\boldsymbol\\beta}} = -2\\mathbf{X}^\\top\\mathbf{Y} + \\mathbf{X}^\\top\\mathbf{X}\\hat{\\boldsymbol\\beta} + \\mathbf{X}^\\top\\mathbf{X}\\hat{\\boldsymbol\\beta} \\\\\n", "RSS_{\\hat{\\boldsymbol\\beta}} = -2\\mathbf{X}^\\top\\mathbf{Y} + 2\\mathbf{X}^\\top\\mathbf{X}\\hat{\\boldsymbol\\beta}\n", "$$" ] }, { "cell_type": "markdown", "id": "124e284b-14c0-4ea2-a8e6-fea3d6b263f6", "metadata": {}, "source": [ "Note: the original resource I used to figure out this derivation is this YouTube video linked [here](https://www.youtube.com/watch?v=g8qF61P741w&ab_channel=ShivankGoel)." ] }, { "cell_type": "markdown", "id": "e10afa43-7db5-4747-87e6-6e92a05b9054", "metadata": {}, "source": [ "Setting $RSS_{\\hat{\\boldsymbol\\beta}} = \\mathbf{0}$, I can now solve for $\\hat{\\boldsymbol\\beta}$:" ] }, { "cell_type": "markdown", "id": "de3d5b5a-3cc4-4432-8785-8bcbc8c472de", "metadata": {}, "source": [ "$$\n", "-2\\mathbf{X}^\\top\\mathbf{Y} + 2\\mathbf{X}^\\top\\mathbf{X}\\hat{\\boldsymbol\\beta} = \\mathbf{0} \\\\\n", "\\mathbf{X}^\\top\\mathbf{X}\\hat{\\boldsymbol\\beta} = \\mathbf{X}^\\top\\mathbf{Y} \\\\\n", "\\hat{\\boldsymbol\\beta} = (\\mathbf{X}^\\top\\mathbf{X})^{-1}\\mathbf{X}^\\top\\mathbf{Y}\n", "$$" ] }, { "cell_type": "markdown", "id": "be8edeff-3040-4e6e-8488-ddd33723a307", "metadata": {}, "source": [ "In order for the formula to work, it is implied that $\\mathbf{X}^\\top\\mathbf{X}$ is a **full rank** matrix so that the inverse exists. Note that $\\mathbf{X}^\\top\\mathbf{X}\\hat{\\boldsymbol\\beta} = \\mathbf{X}^\\top\\mathbf{Y}$ is the **normal equation**. It is called a normal equation because $\\mathbf{Y}-\\mathbf{X}\\hat{\\boldsymbol\\beta}$ is normal to the range of $\\mathbf{X}$ and $\\mathbf{X}^\\top\\mathbf{X}$ is a **normal matrix**. ([source](https://mathworld.wolfram.com/NormalEquation.html))" ] }, { "cell_type": "markdown", "id": "564b117e-c51c-4cfc-8702-51c2a0bec08e", "metadata": {}, "source": [ "So now I can find the $\\hat{\\beta}_0$, $\\hat{\\beta}_1$ parameters using matrix multiplication:" ] }, { "cell_type": "code", "execution_count": 5, "id": "e0790afe-14a7-40ac-95c8-abb27fe7c2b2", "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEWCAYAAABrDZDcAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAA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gQ5SwTGGBPkLBEYY0yQ+38F74G1qEGeAwAAAABJRU5ErkJggg==\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Optimal Line: y = 2.560986514218704 + -0.8545148050425094x\n", "Residual Sum of Squares: 5.467461888009382\n" ] } ], "source": [ "design_matrix = np.array([[1, x_i] for x_i, y_i in dataset])\n", "response_vector = np.array([y_i for x_i, y_i in dataset])\n", "\n", "estimated_parameters_vector = np.linalg.inv(design_matrix.T @ design_matrix) @ design_matrix.T @ response_vector\n", "\n", "x_vals = np.linspace(min([x_i for x_i, y_i in dataset]), max([x_i for x_i, y_i in dataset]), num=100)\n", "y_vals = estimated_parameters_vector[0] + estimated_parameters_vector[1] * x_vals\n", "\n", "plt.title(\"Optimal Line for Dataset\")\n", "plt.xlabel(\"Variable 1 Observations\")\n", "plt.ylabel(\"Variable 2 Observations\")\n", "plt.scatter(x=[p[0] for p in dataset], y=[p[1] for p in dataset])\n", "plt.plot(x_vals, y_vals)\n", "plt.show()\n", "\n", "print(\"Optimal Line: y = {} + {}x\".format(estimated_parameters_vector[0], estimated_parameters_vector[1]))\n", "print(\"Residual Sum of Squares:\", rss_func(estimated_parameters_vector[0], estimated_parameters_vector[1]))" ] }, { "cell_type": "markdown", "id": "b227bec5-7031-4b4a-bd6c-3917c996cd74", "metadata": {}, "source": [ "Expressing the formula for $\\hat{\\boldsymbol\\beta}$ in matrix form makes it really easy to extend my understanding of linear regression from simple linear regression to multiple linear regression. If I wanted to account for some more independent variables when predicting some dependent variable, I can increase the length of $\\hat{\\boldsymbol\\beta}$ to fit 1+ the number of independent variables I have and increase the number of columns of the design matrix $\\mathbf{X}$ to fit 1+ the number of independent variables I have. This way I can compute a regression hyperplane in some $n$-dimensional space." ] }, { "cell_type": "markdown", "id": "3c4e0e7b-5267-48f3-9ba1-e6f0aa1668c1", "metadata": {}, "source": [ "I'd imagine the runtime of this is also $O(n)$ assuming simple linear regression and not multiple linear regression, but I would have to revisit this statement if I ever end up learning about how numpy matrix transformations work under the hood." ] }, { "cell_type": "markdown", "id": "a38b313b-dee5-465a-a84b-37f52302e4a0", "metadata": {}, "source": [ "### Gradient Descent" ] }, { "cell_type": "markdown", "id": "6700fb01-ae9a-473b-b207-64d85101c3ba", "metadata": {}, "source": [ "The **gradient descent** algorithm can be applied to find the line of best fit. Although gradient descent might not give the exact values for parameters $\\hat{\\beta}_0$, $\\hat{\\beta}_1$ that are the solutions to the least squares best fit line problem, the values obtained should be very, very close to what the real values should actually be. The reason for this difference is due to the iterative \"trial and error\" approach that the gradient descent algorithm employs as well as the fact that there can be small rounding errors during the calculation process since the amount of computational memory a computer has is limited." ] }, { "cell_type": "markdown", "id": "0ad5db06-44f3-411a-9690-747039342086", "metadata": {}, "source": [ "As established earlier, the gradient for the residual sum of squares (rewritten here) is:" ] }, { "cell_type": "markdown", "id": "d18753ef-96e5-44b9-a082-0e97fe40659f", "metadata": {}, "source": [ "$$\n", "\\nabla RSS =\n", "\\begin{bmatrix}\n", " RSS_{\\hat{\\beta}_0} \\\\\n", " RSS_{\\hat{\\beta}_1}\n", "\\end{bmatrix}\n", "=\n", "\\begin{bmatrix}\n", " \\sum\\limits_{i = 1}^{n} -2(y_i - \\hat{\\beta}_0 - \\hat{\\beta}_1 x_i) \\\\\n", " \\sum\\limits_{i = 1}^{n} -2x_i(y_i - \\hat{\\beta}_0 - \\hat{\\beta}_1 x_i)\n", "\\end{bmatrix}\n", "$$" ] }, { "cell_type": "markdown", "id": "880b1498-47f6-4e7b-a180-10c13b8e04f9", "metadata": {}, "source": [ "The main formula for the gradient descent algorithm can be described as:" ] }, { "cell_type": "markdown", "id": "c9c0bc2a-3879-47c5-92c8-1281ff368661", "metadata": {}, "source": [ "$$\n", "\\begin{bmatrix}\n", " {\\hat{\\beta}_0}_{n+1} \\\\\n", " {\\hat{\\beta}_1}_{n+1}\n", "\\end{bmatrix}\n", "=\n", "\\begin{bmatrix}\n", " {\\hat{\\beta}_0}_n \\\\\n", " {\\hat{\\beta}_1}_n\n", "\\end{bmatrix}\n", "- \\eta\n", "\\nabla RSS ({\\hat{\\beta}_0}_n, {\\hat{\\beta}_1}_n)\n", "$$" ] }, { "cell_type": "markdown", "id": "998e093f-845e-41ff-b5d1-826dc1d58b3e", "metadata": {}, "source": [ "where $\\eta$ is the step size/**learning rate** and $n$ represents the number of iterations (not to be confused with $n$ in the residual sum of squares formula $RSS$ which represents the number of points). The idea behind this algorithm is that if I start with some random initial \"point\" $(\\hat{\\beta}_0, \\hat{\\beta}_1)$, I can calculate the \"slope\" of the $RSS$ function at that point. If the \"slope\" is negative, I need to increase my $\\hat{\\beta}_0$, $\\hat{\\beta}_1$ values by a little bit to move in the direction of the local minimum of the $RSS$ function. Likewise, if the \"slope\" is positive, I need to decrease my $\\hat{\\beta}_0$, $\\hat{\\beta}_0$ values a little bit to move in the direction of the local minimum. If the \"slope\" reaches 0, then I have found my minimum point $(\\hat{\\beta}_0, \\hat{\\beta}_1)$. The learning rate $\\eta$ is a small number (typically between 0 and 1) that scales the value of the \"slope\" down so that I don't take giant steps with each iteration because if the overall value of $\\eta\\nabla RSS$ is too big, I could overshoot and the $\\hat{\\beta}_0$ and $\\hat{\\beta}_1$ values might never converge onto single point. In general, if I pick a good initial learning rate $\\eta$ and a good initial starting point $({\\hat{\\beta}_0}_0, {\\hat{\\beta}_1}_0)$, then, with enough iterations, I can expect the gradient descent algorithm to converge onto a point $(\\hat{\\beta}_0, \\hat{\\beta}_1)$ that will minimize the $RSS$ function." ] }, { "cell_type": "code", "execution_count": 6, "id": "76f182dd-0303-4e81-badd-bbf05ada1fc3", "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEWCAYAAABrDZDcAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAAL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wCA3ltuB8wZgzyQWWO0eox9OXcMUE9b7qDHGBDm7IjDGmCBnicAYY4KcJQJjjAlylgiMMSbIWSIwxpggZ4nAGGOCnCUCY4wJcv8PUQuY6vqCaZgAAAAASUVORK5CYII=\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Optimal Line: y = 2.560986514218691 + -0.8545148050425041x\n", "Residual Sum of Squares: 5.467461888009381\n" ] } ], "source": [ "rss_func = lambda b_0_hat, b_1_hat: sum([(y_i - b_0_hat - b_1_hat * x_i)**2 for x_i, y_i in dataset])\n", "\n", "rss_b_0_hat = lambda b_0_hat, b_1_hat: sum([-2 * (y_i - b_0_hat - b_1_hat * x_i) for x_i, y_i in dataset])\n", "rss_b_1_hat = lambda b_0_hat, b_1_hat: sum([-2 * x_i * (y_i - b_0_hat - b_1_hat * x_i) for x_i, y_i in dataset])\n", "\n", "lr = 0.001\n", "b_0_hat = 0\n", "b_1_hat = 0\n", "\n", "for i in range(0, 100000):\n", " b_0_hat = b_0_hat - lr * rss_b_0_hat(b_0_hat, b_1_hat)\n", " b_1_hat = b_1_hat - lr * rss_b_1_hat(b_0_hat, b_1_hat)\n", "\n", "x_vals = np.linspace(min([x_i for x_i, y_i in dataset]), max([x_i for x_i, y_i in dataset]), num=100)\n", "y_vals = b_0_hat + b_1_hat * x_vals\n", "\n", "plt.title(\"Optimal Line for Dataset\")\n", "plt.xlabel(\"Variable 1 Observations\")\n", "plt.ylabel(\"Variable 2 Observations\")\n", "plt.scatter(x=[p[0] for p in dataset], y=[p[1] for p in dataset])\n", "plt.plot(x_vals, y_vals)\n", "plt.show()\n", "\n", "print(\"Optimal Line: y = {} + {}x\".format(b_0_hat, b_1_hat))\n", "print(\"Residual Sum of Squares:\", rss_func(b_0_hat, b_1_hat))" ] }, { "cell_type": "markdown", "id": "82b00efd-b519-48be-a129-6d0c68473758", "metadata": {}, "source": [ "The runtime of finding the least squares best fit line using gradient descent is proportional to the size of the dataset $n$. Since the gradient descent method requires me to set a predetermined number of iterations, the runtime of finding the best fit line is just $O(n)$." ] }, { "cell_type": "markdown", "id": "5cb5bf76-6ad6-4d59-b9f8-c671ed5bdf99", "metadata": {}, "source": [ "### Stochastic Gradient Descent" ] }, { "cell_type": "markdown", "id": "5717e65f-5652-4e8e-b46c-9de9d185deaa", "metadata": {}, "source": [ "What if I want to find the least squares best fit line given a huge dataset of points? Maybe I have millions of points, or billions points, or trillions of points, or more. Then, the methods listed above to find the least squares best fit line just might not useable simply because computers do not have enough internal memory to hold information on all the input data and all the intermediate calculations needed to calculate the residual sum of squares. I can use **stochastic gradient descent** (SGD) to try to solve problems where I am unable to process the data I have all at once." ] }, { "cell_type": "markdown", "id": "e0c93de0-81e3-43e0-bf0f-e5d241115e24", "metadata": {}, "source": [ "Just as like how the terms _gradient descent_ and _stochastic gradient descent_ are very similar, the algorithmic implementations, functions/variables used, and goal of the algorithms are very similar as well. Let me again rewrite the residual sum of squares and its gradient:" ] }, { "cell_type": "markdown", "id": "8a85d012-ec32-4d2d-9d17-46cec8e5800b", "metadata": {}, "source": [ "$$\n", "RSS = \\sum\\limits_{i = 1}^{n} (y_i - \\hat{\\beta}_0 - \\hat{\\beta}_1 x_i)^2 \\\\\n", "\\nabla RSS =\n", "\\begin{bmatrix}\n", " RSS_{\\hat{\\beta}_0} \\\\\n", " RSS_{\\hat{\\beta}_1}\n", "\\end{bmatrix}\n", "=\n", "\\begin{bmatrix}\n", " \\sum\\limits_{i = 1}^{n} -2(y_i - \\hat{\\beta}_0 - \\hat{\\beta}_1 x_i) \\\\\n", " \\sum\\limits_{i = 1}^{n} -2x_i(y_i - \\hat{\\beta}_0 - \\hat{\\beta}_1 x_i)\n", "\\end{bmatrix}\n", "$$" ] }, { "cell_type": "markdown", "id": "10ad8981-1af2-4853-9e97-27b67f47ab31", "metadata": {}, "source": [ "Since I can't (or won't) calculate $RSS$ seeing that it requires using all data points in my dataset, I need formulate a different function to minimize." ] }, { "cell_type": "markdown", "id": "446d3b38-3ac1-4a3e-98d9-0d47a87dfb99", "metadata": {}, "source": [ "With stochastic gradient descent, I'm only considering and processing one random (stochastic) point from my dataset at any given time. Therefore, the best I can do is minimize the squared distance between my predicted $\\hat y_i$ value and the $y_i$ value in my dataset (the \"true\" $y_i$ value) for some given $x_i$ in my dataset. The function that I have to optimize the parameters for is then expressed as:" ] }, { "cell_type": "markdown", "id": "681a27bd-2f34-48c4-ac2d-d3dfec681555", "metadata": {}, "source": [ "$$\n", "MSE = \\frac{1}{n} \\sum\\limits_{i = 1}^{n} (y_i - \\hat y_i)^2 \\\\\n", "MSE = \\frac{1}{n} \\sum\\limits_{i = 1}^{n} (y_i - \\hat{\\beta}_0 - \\hat{\\beta}_1 x_i)^2\n", "$$" ] }, { "cell_type": "markdown", "id": "baddc578-8c53-48a2-9a22-918658431180", "metadata": {}, "source": [ "where $MSE$ is the **mean squared error** (the average of all the squared errors considered) and $n$ is the number of datapoints at each processing step. The $n$ here is not to be confused with the $n$ that represents the number of points in my entire dataset. The $n$ here for stochastic gradient descent is $1$ since I am only processing one point at a time." ] }, { "cell_type": "markdown", "id": "ecc520cb-02cf-4f30-9623-3a87f1a572a9", "metadata": {}, "source": [ "The gradient for $MSE$ is:" ] }, { "cell_type": "markdown", "id": "ba588adb-4c7a-451f-86d0-c5d1d425642c", "metadata": {}, "source": [ "$$\n", "\\nabla MSE =\n", "\\begin{bmatrix}\n", " MSE_{\\hat{\\beta}_0} \\\\\n", " MSE_{\\hat{\\beta}_1}\n", "\\end{bmatrix}\n", "=\n", "\\begin{bmatrix}\n", " \\frac{1}{n} \\sum\\limits_{i = 1}^{n} -2(y_i - \\hat{\\beta}_0 - \\hat{\\beta}_1 x_i) \\\\\n", " \\frac{1}{n} \\sum\\limits_{i = 1}^{n} -2x_i(y_i - \\hat{\\beta}_0 - \\hat{\\beta}_1 x_i)\n", "\\end{bmatrix}\n", "$$" ] }, { "cell_type": "markdown", "id": "27adbfa2-5039-4028-8551-9e5ad516dd0a", "metadata": {}, "source": [ "I can see that $MSE$ is very similar to $RSS$. The only two major differences with $MSE$ is that I take the average of the sum of squares and I am only considering a small subset of my whole dataset." ] }, { "cell_type": "markdown", "id": "62b2cfd4-d1c4-4650-bff2-26be69273349", "metadata": {}, "source": [ "The update formula then for stochastic gradient descent is basically the same as gradient descent, but using $MSE$ instead of $RSS$:" ] }, { "cell_type": "markdown", "id": "2b059c41-369c-426b-9c18-fdad95b883f4", "metadata": {}, "source": [ "$$\n", "\\begin{bmatrix}\n", " {\\hat{\\beta}_0}_{n+1} \\\\\n", " {\\hat{\\beta}_1}_{n+1}\n", "\\end{bmatrix}\n", "=\n", "\\begin{bmatrix}\n", " {\\hat{\\beta}_0}_n \\\\\n", " {\\hat{\\beta}_1}_n\n", "\\end{bmatrix}\n", "- \\eta\n", "\\nabla MSE ({\\hat{\\beta}_0}_n, {\\hat{\\beta}_1}_n)\n", "$$" ] }, { "cell_type": "markdown", "id": "f09eec05-aad4-466f-97e0-d79f45306cde", "metadata": {}, "source": [ "Because stochastic gradient descent requires me to update the $\\hat{\\beta}_0$, $\\hat{\\beta}_1$ values after processing each data point in the dataset instead of updating the $\\hat{\\beta}_0$, $\\hat{\\beta}_1$ values by considering all the points simultaneously as is done in gradient descent, I can end up with different final $\\hat{\\beta}_0$, $\\hat{\\beta}_1$ values depending on what order I process the data points. In order for stochastic gradient descent to converge onto some more stable $\\hat{\\beta}_0$, $\\hat{\\beta}_1$ values, I have to run the SGD algorithm for several **epochs** (iterations over the whole input dataset), shuffling the order of data points processed with each new epoch." ] }, { "cell_type": "code", "execution_count": 7, "id": "c5aff5c9-bfc2-496f-9f75-efe77ec47d38", "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEWCAYAAABrDZDcAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK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U5ErkJggg==\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "Optimal Line: y = 2.560801714887752 + -0.8545126158373093x\n", "Residual Sum of Squares: 5.467462226031817\n" ] } ], "source": [ "mse_func = lambda x_i, y_i, b_0_hat, b_1_hat: (y_i - b_0_hat - b_1_hat * x_i)**2\n", "\n", "mse_b_0_hat = lambda x_i, y_i, b_0_hat, b_1_hat: -2 * (y_i - b_0_hat - b_1_hat * x_i)\n", "mse_b_1_hat = lambda x_i, y_i, b_0_hat, b_1_hat: -2 * x_i * (y_i - b_0_hat - b_1_hat * x_i)\n", "\n", "lr = 0.001\n", "b_0_hat = 0\n", "b_1_hat = 0\n", "\n", "for epoch in range(0, 100000):\n", " random.shuffle(dataset)\n", " for i in range(0, len(dataset)):\n", " b_0_hat = b_0_hat - lr * mse_b_0_hat(dataset[i][0], dataset[i][1], b_0_hat, b_1_hat)\n", " b_1_hat = b_1_hat - lr * mse_b_1_hat(dataset[i][0], dataset[i][1], b_0_hat, b_1_hat)\n", "\n", "x_vals = np.linspace(min([x_i for x_i, y_i in dataset]), max([x_i for x_i, y_i in dataset]), num=100)\n", "y_vals = b_0_hat + b_1_hat * x_vals\n", "\n", "plt.title(\"Optimal Line for Dataset\")\n", "plt.xlabel(\"Variable 1 Observations\")\n", "plt.ylabel(\"Variable 2 Observations\")\n", "plt.scatter(x=[p[0] for p in dataset], y=[p[1] for p in dataset])\n", "plt.plot(x_vals, y_vals)\n", "plt.show()\n", "\n", "rss_func = lambda b_0_hat, b_1_hat: sum([(y_i - b_0_hat - b_1_hat * x_i)**2 for x_i, y_i in dataset])\n", "\n", "print(\"Optimal Line: y = {} + {}x\".format(b_0_hat, b_1_hat))\n", "print(\"Residual Sum of Squares:\", rss_func(b_0_hat, b_1_hat))" ] }, { "cell_type": "markdown", "id": "49eac362-7fca-465b-9bf3-b0d5257bd0e4", "metadata": {}, "source": [ "My intuition behind stochastic gradient descent feels good enough here that I feel like I can use stochastic gradient descent comfortably in other optimization problems. If I want to later, I can write out a proof here showing that the SGD algorithm arrives at the same result as the gradient descent algorithm, or I can add a just add a link for the proof here." ] }, { "cell_type": "markdown", "id": "74f2bc20-decc-4dc6-87f9-4bc403e6231f", "metadata": {}, "source": [ "The runtime of finding the least squares best fit line using stochastic gradient descent is proportional to the size of the dataset $n$. Since the stochastic gradient descent method requires me to set a predetermined number of epochs, the runtime of finding the best fit line is just $O(n)$." ] }, { "cell_type": "markdown", "id": "fa866c5d-7181-448a-83c2-3825c3070d7c", "metadata": { "tags": [] }, "source": [ "# Appendix" ] }, { "cell_type": "markdown", "id": "8cb1791d-2754-4224-8c2e-1bc9016f1728", "metadata": { "tags": [] }, "source": [ "#### Versions Used" ] }, { "cell_type": "markdown", "id": "90ced5ba-c951-423d-bd6c-c5c24a6dc8a4", "metadata": {}, "source": [ "python 3.8.9 \n", "jupyterlab 3.3.4 \n", "matplotlib 3.5.1 \n", "numpy 1.21.5" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.9" } }, "nbformat": 4, "nbformat_minor": 5 }