aboutsummaryrefslogtreecommitdiff
path: root/linear_regression/polynomial.org
diff options
context:
space:
mode:
authormanzerbredes <manzerbredes@mailbox.org>2021-02-13 14:39:28 +0100
committermanzerbredes <manzerbredes@mailbox.org>2021-02-13 14:39:28 +0100
commit340299b7ace63f11136fe6315a23adce75cc2120 (patch)
treeb5b1923f2634c498ee7b9a6be8928784499801fb /linear_regression/polynomial.org
Add linear regression
Diffstat (limited to 'linear_regression/polynomial.org')
-rw-r--r--linear_regression/polynomial.org33
1 files changed, 33 insertions, 0 deletions
diff --git a/linear_regression/polynomial.org b/linear_regression/polynomial.org
new file mode 100644
index 0000000..7201122
--- /dev/null
+++ b/linear_regression/polynomial.org
@@ -0,0 +1,33 @@
+#+TITLE: Gradient Decent Based Polynomial Regression
+#+AUTHOR: Loic Guegan
+
+#+OPTIONS: toc:nil
+
+#+LATEX_HEADER: \usepackage{fullpage}
+#+latex_header: \hypersetup{colorlinks=true,linkcolor=blue}
+
+First, choose a polynomial function $h_w(x)$ according to the data complexity.
+In our case, we have:
+\begin{equation}
+h_w(x) = w_1 + w_2x + w_3x^2
+\end{equation}
+
+Then, we should define a cost function. A common approach is to use the *Mean Square Error*
+cost function:
+\begin{equation}\label{eq:cost}
+ J(w) = \frac{1}{2n} \sum_{i=0}^n (h_w(x^{(i)}) - \hat{y}^{(i)})^2
+\end{equation}
+
+Note that in Equation \ref{eq:cost} we average by $2n$ and not $n$. This is because it get simplify
+while doing the partial derivatives as we will see below. This is a pure cosmetic approach which do
+not impact the gradient decent (see [[https://math.stackexchange.com/questions/884887/why-divide-by-2m][here]] for more informations). The next step is to $min_w J(w)$
+for each weight $w_i$ (performing the gradient decent). Thus we compute each partial derivatives:
+\begin{align}
+ \frac{\partial J(w)}{\partial w_1}&=\frac{\partial J(w)}{\partial h_w(x)}\frac{\partial h_w(x)}{\partial w_1}\nonumber\\
+ &= \frac{1}{n} \sum_{i=0}^n (h_w(x^{(i)}) - \hat{y}^{(i)})\\
+ \text{similarly:}\nonumber\\
+ \frac{\partial J(w)}{\partial w_2}&= \frac{1}{n} \sum_{i=0}^n x(h_w(x^{(i)}) - \hat{y}^{(i)})\\
+ \frac{\partial J(w)}{\partial w_3}&= \frac{1}{n} \sum_{i=0}^n x^2(h_w(x^{(i)}) - \hat{y}^{(i)})
+\end{align}
+
+