From ee68e6816a6cfe6fa6840c64725ce4745bf7a69b Mon Sep 17 00:00:00 2001 From: Morten Hjorth-Jensen Date: Thu, 23 Sep 2021 09:17:15 +0200 Subject: [PATCH] more updates --- doc/pub/week38/html/._week38-bs014.html | 3 ++- doc/pub/week38/html/._week38-bs016.html | 9 +++++++++ doc/pub/week38/html/week38-reveal.html | 11 ++++++++++- doc/pub/week38/html/week38-solarized.html | 12 +++++++++++- doc/pub/week38/html/week38.html | 12 +++++++++++- doc/pub/week38/ipynb/ipynb-week38-src.tar.gz | Bin 192 -> 192 bytes doc/pub/week38/ipynb/week38.ipynb | 9 ++++++++- doc/src/week38/week38.do.txt | 8 +++++++- 8 files changed, 58 insertions(+), 6 deletions(-) diff --git a/doc/pub/week38/html/._week38-bs014.html b/doc/pub/week38/html/._week38-bs014.html index 4c330102a..affee3cad 100644 --- a/doc/pub/week38/html/._week38-bs014.html +++ b/doc/pub/week38/html/._week38-bs014.html @@ -423,6 +423,7 @@ MathJax.Hub.Config({

This code shows a simple first-order fit to a data set using the above transformed data, where we consider the role of the intercept first, by either excluding it or including it (code example thanks to Øyvind Sigmundson Schøyen). Here our scaling of the data is done by subtracting the mean values only. Note also that we do not split the data into training and test. +

@@ -502,7 +503,7 @@ intercept = np. ypredictOwn = X @ beta ypredictSKL = skl.predict(X) print(f"MSE with Manual intercept") -print(MSE(y,ypredictOwn)) +print(MSE(y,ypredictOwn+intercept)) print(f"MSE with Sklearn intercept") print(MSE(y,ypredictSKL)) diff --git a/doc/pub/week38/html/._week38-bs016.html b/doc/pub/week38/html/._week38-bs016.html index bf1accacd..c70295620 100644 --- a/doc/pub/week38/html/._week38-bs016.html +++ b/doc/pub/week38/html/._week38-bs016.html @@ -508,6 +508,15 @@ plt.ylabel(' plt.legend() plt.show() +

+We see here, when compared to the code which includes explicitely the +intercept column, that our MSE value is actually smaller. This is +because the regularization term does not include the intercept value \( \beta_0 \) in the +fitting. This applies to Lasso regularization as well. + +

+If we stay with ordinary least squares, there is no dependence on the value of the intercept when we perform the fitting. +

diff --git a/doc/pub/week38/html/week38-reveal.html b/doc/pub/week38/html/week38-reveal.html index 9e09c6fa9..433918261 100644 --- a/doc/pub/week38/html/week38-reveal.html +++ b/doc/pub/week38/html/week38-reveal.html @@ -676,6 +676,7 @@ What does this mean? And why do we insist on all this? Let us look at some examp

This code shows a simple first-order fit to a data set using the above transformed data, where we consider the role of the intercept first, by either excluding it or including it (code example thanks to Øyvind Sigmundson Schøyen). Here our scaling of the data is done by subtracting the mean values only. Note also that we do not split the data into training and test. +

@@ -755,7 +756,7 @@ intercept = np.mean(y_offset - X_offset @ beta) ypredictOwn = X @ beta ypredictSKL = skl.predict(X) print(f"MSE with Manual intercept") -print(MSE(y,ypredictOwn)) +print(MSE(y,ypredictOwn+intercept)) print(f"MSE with Sklearn intercept") print(MSE(y,ypredictSKL)) @@ -954,6 +955,14 @@ plt.ylabel('MSE') plt.legend() plt.show() +

+We see here, when compared to the code which includes explicitely the +intercept column, that our MSE value is actually smaller. This is +because the regularization term does not include the intercept value \( \beta_0 \) in the +fitting. This applies to Lasso regularization as well. + +

+If we stay with ordinary least squares, there is no dependence on the value of the intercept when we perform the fitting. diff --git a/doc/pub/week38/html/week38-solarized.html b/doc/pub/week38/html/week38-solarized.html index d4666dff6..c3c51e05f 100644 --- a/doc/pub/week38/html/week38-solarized.html +++ b/doc/pub/week38/html/week38-solarized.html @@ -810,6 +810,7 @@ What does this mean? And why do we insist on all this? Let us look at some examp

This code shows a simple first-order fit to a data set using the above transformed data, where we consider the role of the intercept first, by either excluding it or including it (code example thanks to Øyvind Sigmundson Schøyen). Here our scaling of the data is done by subtracting the mean values only. Note also that we do not split the data into training and test. +

@@ -889,7 +890,7 @@ intercept = np.mean(y_offset - X_offset @ beta) ypredictOwn = X @ beta ypredictSKL = skl.predict(X) print(f"MSE with Manual intercept") -print(MSE(y,ypredictOwn)) +print(MSE(y,ypredictOwn+intercept)) print(f"MSE with Sklearn intercept") print(MSE(y,ypredictSKL)) @@ -1088,6 +1089,15 @@ plt.ylabel('MSE') plt.legend() plt.show() +

+We see here, when compared to the code which includes explicitely the +intercept column, that our MSE value is actually smaller. This is +because the regularization term does not include the intercept value \( \beta_0 \) in the +fitting. This applies to Lasso regularization as well. + +

+If we stay with ordinary least squares, there is no dependence on the value of the intercept when we perform the fitting. +











diff --git a/doc/pub/week38/html/week38.html b/doc/pub/week38/html/week38.html index ec13a9371..0ce1a3258 100644 --- a/doc/pub/week38/html/week38.html +++ b/doc/pub/week38/html/week38.html @@ -815,6 +815,7 @@ What does this mean? And why do we insist on all this? Let us look at some examp

This code shows a simple first-order fit to a data set using the above transformed data, where we consider the role of the intercept first, by either excluding it or including it (code example thanks to Øyvind Sigmundson Schøyen). Here our scaling of the data is done by subtracting the mean values only. Note also that we do not split the data into training and test. +

@@ -894,7 +895,7 @@ intercept = np. ypredictOwn = X @ beta ypredictSKL = skl.predict(X) print(f"MSE with Manual intercept") -print(MSE(y,ypredictOwn)) +print(MSE(y,ypredictOwn+intercept)) print(f"MSE with Sklearn intercept") print(MSE(y,ypredictSKL)) @@ -1093,6 +1094,15 @@ plt.ylabel(' plt.legend() plt.show() +

+We see here, when compared to the code which includes explicitely the +intercept column, that our MSE value is actually smaller. This is +because the regularization term does not include the intercept value \( \beta_0 \) in the +fitting. This applies to Lasso regularization as well. + +

+If we stay with ordinary least squares, there is no dependence on the value of the intercept when we perform the fitting. +











diff --git a/doc/pub/week38/ipynb/ipynb-week38-src.tar.gz b/doc/pub/week38/ipynb/ipynb-week38-src.tar.gz index a57f336d8c0a990810958deaa8a76dd624df173c..2db2f457a61c9d789f3135daeaccb3daeed820cb 100644 GIT binary patch literal 192 zcmV;x06+g9iwFSkDNJDi1MSaC3c@fD2H>uHia9|^nm*hLcHu%0@d7EG+E|;^Bt?6B z`v6@jZi)!`Hb0XL!^|ODZ+2N=@77xkAtZ?+7&A@cDM>ij6G~&C5e?b!n#L&*%3?-5 zAj_@v(izM3uu4;%Q5ux*`i8c${4i%e1)ljQj+HR5-S@Uq5~Q-2D^&jZ literal 192 zcmV;x06+g9iwFQGC`@4h1MSaC4uUWc24L2lVopG&P{6H;EL@lv;{{46Qjr$h66N;t zNOYxfLySqk&7Wx}lbJ)d-t4l#-mSM7L`*1!G1DZT62rNk5E28SB#eevq$wbY;t)N+ zjAeRQrK!$b8ZO`U4Q*xlVa|LCJo8T+D`8-}?`@?dNM(7hR1G)I>u42-wwE~+ uiktBZG{1I2b6~OuRusYtCE3MqwK{3mn85$_F^=On&etA