From 9823ecab3dfe53ca8b50cdbbf03bf2a523a36b95 Mon Sep 17 00:00:00 2001 From: Luisa <103768169+luisa-li@users.noreply.github.com> Date: Fri, 30 Aug 2024 15:39:03 -0500 Subject: [PATCH] simplifications and fixes --- blog/home.css => blog.css | 8 ++ blog.html | 4 +- ...ent_introduction_to_linear_regression.html | 37 +++++---- blog/{blog.css => blogpost.css} | 78 ++++++++++++------ blog/statistics_for_evil.html | 20 +++-- blog/the_reading_itinerary.html | 8 +- styles.css => main.css | 0 index.html => main.html | 2 +- resources/luisaresume.pdf | Bin 101294 -> 0 bytes 9 files changed, 101 insertions(+), 56 deletions(-) rename blog/home.css => blog.css (87%) rename blog/{blog.css => blogpost.css} (62%) rename styles.css => main.css (100%) rename index.html => main.html (97%) delete mode 100644 resources/luisaresume.pdf diff --git a/blog/home.css b/blog.css similarity index 87% rename from blog/home.css rename to blog.css index 787e862..05d92d7 100644 --- a/blog/home.css +++ b/blog.css @@ -36,6 +36,14 @@ a:hover { flex-direction: column; } +.code-block { + font-family: monospace; + white-space: pre; + max-width: 80%; + overflow: auto; + text-align: left; +} + @media (max-width: 600px) { h1 { diff --git a/blog.html b/blog.html index cedc4c3..ea6364d 100644 --- a/blog.html +++ b/blog.html @@ -5,7 +5,7 @@
june 24, 2024
sick and tired of gentle introductions to *insert an ml concept*?
worry no more, for today, we will catapult you to the wolves of linear regression.
the derivation of the derivatives is relatively simple calculus, which actually took me way too long to do:
\[ MSE = \frac{1}{n} \sum^n_{i = 1} (y_i - \hat{y}_i)^2, \space e = (y_i - (mx_i + b))\]
-\[ \frac{\partial{e^2}}{\partial{b}} = \frac{\partial{(y_i - wx_i - b)}^2}{\partial{b}} = -1 \times 2(y_i - wx_i - b) = -2(y_i - wx_i - b) \]
+\[ \frac{\partial{e^2}}{\partial{b}} = \frac{\partial{(y_i - wx_i - b)}^2}{\partial{b}} \]
+\[ = -1 \times 2(y_i - wx_i - b) = -2(y_i - wx_i - b) \]
\[ \frac{\partial{MSE}}{\partial{b}} = \frac{1}{N} \sum^n_{i = 1} -2(y_i - wx_i - b)\]
-\[ \frac{\partial{e^2}}{\partial{w}} = \frac{\partial{(y_i - wx_i - b)}^2}{\partial{w}} = -x_i \times 2(y_i - wx_i - b) = -2x_i(y_i - wx_i - b) \]
+\[ \frac{\partial{e^2}}{\partial{w}} = \frac{\partial{(y_i - wx_i - b)}^2}{\partial{w}} \]
+\[ = -x_i \times 2(y_i - wx_i - b) = -2x_i(y_i - wx_i - b)\]
\[ \frac{\partial{MSE}}{\partial{w}} = \frac{1}{N} \sum^n_{i = 1} -2x_i(y_i - wx_i - b)\]
wielding one parameter in each hand, we can now improve our parameters by having them go a little bit towards the direction negative of their gradient:
@@ -107,23 +110,21 @@and... this is the actual algorithm for linear regression with stochastic gradient descent, this should be straightforward after all that buildup:
-- randomly initialize weights W and b in the correct shape - split the data into the train and test splits - for every epoch: - for every data point in the training set: - update the weights W - update the bias b - evaluate the model's predictions on the test set -+
the actual implementation of the above is left as an exercise for the reader...
-just kidding, you can find it here , written with just python and numpy.
+just kidding, you can find it here, written with just python and numpy.
-souces: d2l book, chapter 3 -