correcting typos
This commit is contained in:
@@ -68,6 +68,7 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
None,
|
||||
@@ -233,44 +234,45 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs007.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs008.html#from-ols-to-ridge-and-lasso" style="font-size: 80%;">From OLS to Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs011.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#simple-example-to-illustrate-ordinary-least-squares-ridge-and-lasso-regression" style="font-size: 80%;">Simple example to illustrate Ordinary Least Squares, Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#linking-the-regression-analysis-with-a-statistical-interpretation" style="font-size: 80%;">Linking the regression analysis with a statistical interpretation</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#expectation-value-and-variance-for-boldsymbol-beta" style="font-size: 80%;">Expectation value and variance for \( \boldsymbol{\beta} \)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#why-resampling-methods" style="font-size: 80%;">Why resampling methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#resampling-methods" style="font-size: 80%;">Resampling methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#resampling-approaches-can-be-computationally-expensive" style="font-size: 80%;">Resampling approaches can be computationally expensive</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#why-resampling-methods" style="font-size: 80%;">Why resampling methods ?</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#statistical-analysis" style="font-size: 80%;">Statistical analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#resampling-methods" style="font-size: 80%;">Resampling methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#resampling-methods-jackknife-and-bootstrap" style="font-size: 80%;">Resampling methods: Jackknife and Bootstrap</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#resampling-methods-jackknife" style="font-size: 80%;">Resampling methods: Jackknife</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#jackknife-code-example" style="font-size: 80%;">Jackknife code example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#resampling-methods-bootstrap" style="font-size: 80%;">Resampling methods: Bootstrap</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#resampling-methods-bootstrap-background" style="font-size: 80%;">Resampling methods: Bootstrap background</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#resampling-methods-more-bootstrap-background" style="font-size: 80%;">Resampling methods: More Bootstrap background</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#resampling-methods-bootstrap-approach" style="font-size: 80%;">Resampling methods: Bootstrap approach</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.html#resampling-methods-bootstrap-steps" style="font-size: 80%;">Resampling methods: Bootstrap steps</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#code-example-for-the-bootstrap-method" style="font-size: 80%;">Code example for the Bootstrap method</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#various-steps-in-cross-validation" style="font-size: 80%;">Various steps in cross-validation</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#how-to-set-up-the-cross-validation-for-ridge-and-or-lasso" style="font-size: 80%;">How to set up the cross-validation for Ridge and/or Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#cross-validation-in-brief" style="font-size: 80%;">Cross-validation in brief</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#code-example-for-cross-validation-and-k-fold-cross-validation" style="font-size: 80%;">Code Example for Cross-validation and \( k \)-fold Cross-validation</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#the-bias-variance-tradeoff" style="font-size: 80%;">The bias-variance tradeoff</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#example-code-for-bias-variance-tradeoff" style="font-size: 80%;">Example code for Bias-Variance tradeoff</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#understanding-what-happens" style="font-size: 80%;">Understanding what happens</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#summing-up" style="font-size: 80%;">Summing up</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#another-example-from-scikit-learn-s-repository" style="font-size: 80%;">Another Example from Scikit-Learn's Repository</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#more-examples-on-bootstrap-and-cross-validation-and-errors" style="font-size: 80%;">More examples on bootstrap and cross-validation and errors</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#the-same-example-but-now-with-cross-validation" style="font-size: 80%;">The same example but now with cross-validation</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#cross-validation-with-ridge" style="font-size: 80%;">Cross-validation with Ridge</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs011.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#simple-example-to-illustrate-ordinary-least-squares-ridge-and-lasso-regression" style="font-size: 80%;">Simple example to illustrate Ordinary Least Squares, Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#linking-the-regression-analysis-with-a-statistical-interpretation" style="font-size: 80%;">Linking the regression analysis with a statistical interpretation</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#expectation-value-and-variance-for-boldsymbol-beta" style="font-size: 80%;">Expectation value and variance for \( \boldsymbol{\beta} \)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#why-resampling-methods" style="font-size: 80%;">Why resampling methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#resampling-methods" style="font-size: 80%;">Resampling methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#resampling-approaches-can-be-computationally-expensive" style="font-size: 80%;">Resampling approaches can be computationally expensive</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#why-resampling-methods" style="font-size: 80%;">Why resampling methods ?</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#statistical-analysis" style="font-size: 80%;">Statistical analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#resampling-methods" style="font-size: 80%;">Resampling methods</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#resampling-methods-jackknife-and-bootstrap" style="font-size: 80%;">Resampling methods: Jackknife and Bootstrap</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#resampling-methods-jackknife" style="font-size: 80%;">Resampling methods: Jackknife</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#jackknife-code-example" style="font-size: 80%;">Jackknife code example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#resampling-methods-bootstrap" style="font-size: 80%;">Resampling methods: Bootstrap</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#resampling-methods-bootstrap-background" style="font-size: 80%;">Resampling methods: Bootstrap background</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#resampling-methods-more-bootstrap-background" style="font-size: 80%;">Resampling methods: More Bootstrap background</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.html#resampling-methods-bootstrap-approach" style="font-size: 80%;">Resampling methods: Bootstrap approach</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#resampling-methods-bootstrap-steps" style="font-size: 80%;">Resampling methods: Bootstrap steps</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#code-example-for-the-bootstrap-method" style="font-size: 80%;">Code example for the Bootstrap method</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#various-steps-in-cross-validation" style="font-size: 80%;">Various steps in cross-validation</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#how-to-set-up-the-cross-validation-for-ridge-and-or-lasso" style="font-size: 80%;">How to set up the cross-validation for Ridge and/or Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#cross-validation-in-brief" style="font-size: 80%;">Cross-validation in brief</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#code-example-for-cross-validation-and-k-fold-cross-validation" style="font-size: 80%;">Code Example for Cross-validation and \( k \)-fold Cross-validation</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#the-bias-variance-tradeoff" style="font-size: 80%;">The bias-variance tradeoff</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#example-code-for-bias-variance-tradeoff" style="font-size: 80%;">Example code for Bias-Variance tradeoff</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#understanding-what-happens" style="font-size: 80%;">Understanding what happens</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#summing-up" style="font-size: 80%;">Summing up</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#another-example-from-scikit-learn-s-repository" style="font-size: 80%;">Another Example from Scikit-Learn's Repository</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#more-examples-on-bootstrap-and-cross-validation-and-errors" style="font-size: 80%;">More examples on bootstrap and cross-validation and errors</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#the-same-example-but-now-with-cross-validation" style="font-size: 80%;">The same example but now with cross-validation</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#cross-validation-with-ridge" style="font-size: 80%;">Cross-validation with Ridge</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -329,7 +331,7 @@ MathJax.Hub.Config({
|
||||
<li><a href="._week36-bs008.html">9</a></li>
|
||||
<li><a href="._week36-bs009.html">10</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs047.html">48</a></li>
|
||||
<li><a href="._week36-bs048.html">49</a></li>
|
||||
<li><a href="._week36-bs001.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
@@ -189,7 +189,7 @@ $$
|
||||
$$
|
||||
<p> <br>
|
||||
|
||||
Since the matrices here have dimension \( p\times p \), with \( p \) corresponding to the singular values, we defined earlier the matrix
|
||||
Since the matrices here have dimension \( p\times p \), with \( p \) corresponding to the singular values, we defined last week the matrix
|
||||
<p> <br>
|
||||
$$
|
||||
\boldsymbol{\Sigma}^T\boldsymbol{\Sigma} = \begin{bmatrix} \tilde{\boldsymbol{\Sigma}} & \boldsymbol{0}\\ \end{bmatrix}\begin{bmatrix} \tilde{\boldsymbol{\Sigma}} \\ \boldsymbol{0}\\ \end{bmatrix},
|
||||
@@ -447,6 +447,11 @@ modified diagonal term added to \( \boldsymbol{X}^T\boldsymbol{X} \). The conseq
|
||||
particular for our discussion of the bias-variance tradeoff are rather
|
||||
interesting. We will see that for specific values of \( \lambda \), we may
|
||||
even reduce the variance of the optimal parameters \( \boldsymbol{\beta} \). These topics and other related ones, will be discussed after the more linear algebra oriented analysis here.
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
<h2 id="svd-analysis">SVD analysis </h2>
|
||||
|
||||
<p>
|
||||
Using our insights about the SVD of the design matrix \( \boldsymbol{X} \)
|
||||
@@ -569,7 +574,7 @@ $$
|
||||
and reordering we have
|
||||
<p> <br>
|
||||
$$
|
||||
\boldsymbol{X}^T\boldsymbol{X}\boldsymbol{\beta})+\lambda sgn(\boldsymbol{\beta})=2\boldsymbol{X}^T(\boldsymbol{y}.
|
||||
\boldsymbol{X}^T\boldsymbol{X}\boldsymbol{\beta}+\lambda sgn(\boldsymbol{\beta})=2\boldsymbol{X}^T\boldsymbol{y}.
|
||||
$$
|
||||
<p> <br>
|
||||
|
||||
@@ -585,7 +590,7 @@ Let us assume that our design matrix is given by unit (identity) matrix, that is
|
||||
diagonal. In this case we have an equal number of rows and columns \( n=p \).
|
||||
|
||||
<p>
|
||||
Our model approximation is just \( \tild{\boldsymbol{y}}=\boldsymbol{\beta} \) and the mean squared error and thereby the cost function for ordinary least sqquares (OLS) is then (we drop the term \( 1/n \))
|
||||
Our model approximation is just \( \tilde{\boldsymbol{y}}=\boldsymbol{\beta} \) and the mean squared error and thereby the cost function for ordinary least sqquares (OLS) is then (we drop the term \( 1/n \))
|
||||
<p> <br>
|
||||
$$
|
||||
C(\boldsymbol{\beta})=\sum_{i=0}^{p-1}(y_i-\beta_i)^2,
|
||||
@@ -644,7 +649,7 @@ which leads to
|
||||
$$
|
||||
\hat{\boldsymbol{\beta}}_i^{\mathrm{Lasso}} = \left\{\begin{array}{ccc}y_i-\frac{\lambda}{2} &\mathrm{if} & y_i> \frac{\lambda}{2}\\
|
||||
y_i+\frac{\lambda}{2} &\mathrm{if} & y_i < -\frac{\lambda}{2}\\
|
||||
0 &\mathrm{if} & \verty_i\vert\le \frac{\lambda}{2}\\
|
||||
0 &\mathrm{if} & \verty_i\vert\le \frac{\lambda}{2}\end{array}\right.\\.
|
||||
$$
|
||||
<p> <br>
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ div { text-align: justify; text-justify: inter-word; }
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
None,
|
||||
@@ -280,7 +281,7 @@ $$
|
||||
\boldsymbol{X}^T\boldsymbol{X}=\boldsymbol{V}\boldsymbol{\Sigma}^T\boldsymbol{U}^T\boldsymbol{U}\boldsymbol{\Sigma}\boldsymbol{V}^T=\boldsymbol{V}\boldsymbol{\Sigma}^T\boldsymbol{\Sigma}\boldsymbol{V}^T.
|
||||
$$
|
||||
|
||||
Since the matrices here have dimension \( p\times p \), with \( p \) corresponding to the singular values, we defined earlier the matrix
|
||||
Since the matrices here have dimension \( p\times p \), with \( p \) corresponding to the singular values, we defined last week the matrix
|
||||
$$
|
||||
\boldsymbol{\Sigma}^T\boldsymbol{\Sigma} = \begin{bmatrix} \tilde{\boldsymbol{\Sigma}} & \boldsymbol{0}\\ \end{bmatrix}\begin{bmatrix} \tilde{\boldsymbol{\Sigma}} \\ \boldsymbol{0}\\ \end{bmatrix},
|
||||
$$
|
||||
@@ -497,6 +498,11 @@ particular for our discussion of the bias-variance tradeoff are rather
|
||||
interesting. We will see that for specific values of \( \lambda \), we may
|
||||
even reduce the variance of the optimal parameters \( \boldsymbol{\beta} \). These topics and other related ones, will be discussed after the more linear algebra oriented analysis here.
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="svd-analysis">SVD analysis </h2>
|
||||
|
||||
<p>
|
||||
Using our insights about the SVD of the design matrix \( \boldsymbol{X} \)
|
||||
We have already analyzed the OLS solutions in terms of the eigenvectors (the columns) of the right singular value matrix \( \boldsymbol{U} \) as
|
||||
@@ -599,7 +605,7 @@ $$
|
||||
|
||||
and reordering we have
|
||||
$$
|
||||
\boldsymbol{X}^T\boldsymbol{X}\boldsymbol{\beta})+\lambda sgn(\boldsymbol{\beta})=2\boldsymbol{X}^T(\boldsymbol{y}.
|
||||
\boldsymbol{X}^T\boldsymbol{X}\boldsymbol{\beta}+\lambda sgn(\boldsymbol{\beta})=2\boldsymbol{X}^T\boldsymbol{y}.
|
||||
$$
|
||||
|
||||
This equation does not lead to a nice analytical equation as in Ridge regression or ordinary least squares. This equation can however be solved by using standard convex optimization algorithms using for example the Python package <a href="https://cvxopt.org/" target="_blank">CVXOPT</a>. We will discuss this later.
|
||||
@@ -614,7 +620,7 @@ Let us assume that our design matrix is given by unit (identity) matrix, that is
|
||||
diagonal. In this case we have an equal number of rows and columns \( n=p \).
|
||||
|
||||
<p>
|
||||
Our model approximation is just \( \tild{\boldsymbol{y}}=\boldsymbol{\beta} \) and the mean squared error and thereby the cost function for ordinary least sqquares (OLS) is then (we drop the term \( 1/n \))
|
||||
Our model approximation is just \( \tilde{\boldsymbol{y}}=\boldsymbol{\beta} \) and the mean squared error and thereby the cost function for ordinary least sqquares (OLS) is then (we drop the term \( 1/n \))
|
||||
$$
|
||||
C(\boldsymbol{\beta})=\sum_{i=0}^{p-1}(y_i-\beta_i)^2,
|
||||
$$
|
||||
@@ -660,7 +666,7 @@ which leads to
|
||||
$$
|
||||
\hat{\boldsymbol{\beta}}_i^{\mathrm{Lasso}} = \left\{\begin{array}{ccc}y_i-\frac{\lambda}{2} &\mathrm{if} & y_i> \frac{\lambda}{2}\\
|
||||
y_i+\frac{\lambda}{2} &\mathrm{if} & y_i < -\frac{\lambda}{2}\\
|
||||
0 &\mathrm{if} & \verty_i\vert\le \frac{\lambda}{2}\\
|
||||
0 &\mathrm{if} & \verty_i\vert\le \frac{\lambda}{2}\end{array}\right.\\.
|
||||
$$
|
||||
|
||||
<p>
|
||||
|
||||
@@ -93,6 +93,7 @@ div { text-align: justify; text-justify: inter-word; }
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
None,
|
||||
@@ -285,7 +286,7 @@ $$
|
||||
\boldsymbol{X}^T\boldsymbol{X}=\boldsymbol{V}\boldsymbol{\Sigma}^T\boldsymbol{U}^T\boldsymbol{U}\boldsymbol{\Sigma}\boldsymbol{V}^T=\boldsymbol{V}\boldsymbol{\Sigma}^T\boldsymbol{\Sigma}\boldsymbol{V}^T.
|
||||
$$
|
||||
|
||||
Since the matrices here have dimension \( p\times p \), with \( p \) corresponding to the singular values, we defined earlier the matrix
|
||||
Since the matrices here have dimension \( p\times p \), with \( p \) corresponding to the singular values, we defined last week the matrix
|
||||
$$
|
||||
\boldsymbol{\Sigma}^T\boldsymbol{\Sigma} = \begin{bmatrix} \tilde{\boldsymbol{\Sigma}} & \boldsymbol{0}\\ \end{bmatrix}\begin{bmatrix} \tilde{\boldsymbol{\Sigma}} \\ \boldsymbol{0}\\ \end{bmatrix},
|
||||
$$
|
||||
@@ -502,6 +503,11 @@ particular for our discussion of the bias-variance tradeoff are rather
|
||||
interesting. We will see that for specific values of \( \lambda \), we may
|
||||
even reduce the variance of the optimal parameters \( \boldsymbol{\beta} \). These topics and other related ones, will be discussed after the more linear algebra oriented analysis here.
|
||||
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
|
||||
<h2 id="svd-analysis">SVD analysis </h2>
|
||||
|
||||
<p>
|
||||
Using our insights about the SVD of the design matrix \( \boldsymbol{X} \)
|
||||
We have already analyzed the OLS solutions in terms of the eigenvectors (the columns) of the right singular value matrix \( \boldsymbol{U} \) as
|
||||
@@ -604,7 +610,7 @@ $$
|
||||
|
||||
and reordering we have
|
||||
$$
|
||||
\boldsymbol{X}^T\boldsymbol{X}\boldsymbol{\beta})+\lambda sgn(\boldsymbol{\beta})=2\boldsymbol{X}^T(\boldsymbol{y}.
|
||||
\boldsymbol{X}^T\boldsymbol{X}\boldsymbol{\beta}+\lambda sgn(\boldsymbol{\beta})=2\boldsymbol{X}^T\boldsymbol{y}.
|
||||
$$
|
||||
|
||||
This equation does not lead to a nice analytical equation as in Ridge regression or ordinary least squares. This equation can however be solved by using standard convex optimization algorithms using for example the Python package <a href="https://cvxopt.org/" target="_blank">CVXOPT</a>. We will discuss this later.
|
||||
@@ -619,7 +625,7 @@ Let us assume that our design matrix is given by unit (identity) matrix, that is
|
||||
diagonal. In this case we have an equal number of rows and columns \( n=p \).
|
||||
|
||||
<p>
|
||||
Our model approximation is just \( \tild{\boldsymbol{y}}=\boldsymbol{\beta} \) and the mean squared error and thereby the cost function for ordinary least sqquares (OLS) is then (we drop the term \( 1/n \))
|
||||
Our model approximation is just \( \tilde{\boldsymbol{y}}=\boldsymbol{\beta} \) and the mean squared error and thereby the cost function for ordinary least sqquares (OLS) is then (we drop the term \( 1/n \))
|
||||
$$
|
||||
C(\boldsymbol{\beta})=\sum_{i=0}^{p-1}(y_i-\beta_i)^2,
|
||||
$$
|
||||
@@ -665,7 +671,7 @@ which leads to
|
||||
$$
|
||||
\hat{\boldsymbol{\beta}}_i^{\mathrm{Lasso}} = \left\{\begin{array}{ccc}y_i-\frac{\lambda}{2} &\mathrm{if} & y_i> \frac{\lambda}{2}\\
|
||||
y_i+\frac{\lambda}{2} &\mathrm{if} & y_i < -\frac{\lambda}{2}\\
|
||||
0 &\mathrm{if} & \verty_i\vert\le \frac{\lambda}{2}\\
|
||||
0 &\mathrm{if} & \verty_i\vert\le \frac{\lambda}{2}\end{array}\right.\\.
|
||||
$$
|
||||
|
||||
<p>
|
||||
|
||||
Binary file not shown.
@@ -46,7 +46,7 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Since the matrices here have dimension $p\\times p$, with $p$ corresponding to the singular values, we defined earlier the matrix"
|
||||
"Since the matrices here have dimension $p\\times p$, with $p$ corresponding to the singular values, we defined last week the matrix"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -455,6 +455,8 @@
|
||||
"interesting. We will see that for specific values of $\\lambda$, we may\n",
|
||||
"even reduce the variance of the optimal parameters $\\boldsymbol{\\beta}$. These topics and other related ones, will be discussed after the more linear algebra oriented analysis here.\n",
|
||||
"\n",
|
||||
"## SVD analysis\n",
|
||||
"\n",
|
||||
"Using our insights about the SVD of the design matrix $\\boldsymbol{X}$ \n",
|
||||
"We have already analyzed the OLS solutions in terms of the eigenvectors (the columns) of the right singular value matrix $\\boldsymbol{U}$ as"
|
||||
]
|
||||
@@ -634,7 +636,7 @@
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"$$\n",
|
||||
"\\boldsymbol{X}^T\\boldsymbol{X}\\boldsymbol{\\beta})+\\lambda sgn(\\boldsymbol{\\beta})=2\\boldsymbol{X}^T(\\boldsymbol{y}.\n",
|
||||
"\\boldsymbol{X}^T\\boldsymbol{X}\\boldsymbol{\\beta}+\\lambda sgn(\\boldsymbol{\\beta})=2\\boldsymbol{X}^T\\boldsymbol{y}.\n",
|
||||
"$$"
|
||||
]
|
||||
},
|
||||
@@ -652,7 +654,7 @@
|
||||
"Let us assume that our design matrix is given by unit (identity) matrix, that is a square diagonal matrix with ones only along the\n",
|
||||
"diagonal. In this case we have an equal number of rows and columns $n=p$.\n",
|
||||
"\n",
|
||||
"Our model approximation is just $\\tild{\\boldsymbol{y}}=\\boldsymbol{\\beta}$ and the mean squared error and thereby the cost function for ordinary least sqquares (OLS) is then (we drop the term $1/n$)"
|
||||
"Our model approximation is just $\\tilde{\\boldsymbol{y}}=\\boldsymbol{\\beta}$ and the mean squared error and thereby the cost function for ordinary least sqquares (OLS) is then (we drop the term $1/n$)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -762,7 +764,7 @@
|
||||
"$$\n",
|
||||
"\\hat{\\boldsymbol{\\beta}}_i^{\\mathrm{Lasso}} = \\left\\{\\begin{array}{ccc}y_i-\\frac{\\lambda}{2} &\\mathrm{if} & y_i> \\frac{\\lambda}{2}\\\\\n",
|
||||
" y_i+\\frac{\\lambda}{2} &\\mathrm{if} & y_i< -\\frac{\\lambda}{2}\\\\\n",
|
||||
"\t\t\t\t\t\t\t 0 &\\mathrm{if} & \\verty_i\\vert\\le \\frac{\\lambda}{2}\\\\\n",
|
||||
"\t\t\t\t\t\t\t 0 &\\mathrm{if} & \\verty_i\\vert\\le \\frac{\\lambda}{2}\\end{array}\\right.\\\\.\n",
|
||||
"$$"
|
||||
]
|
||||
},
|
||||
|
||||
@@ -26,7 +26,7 @@ We used the SVD to analyse the matrix to invert in ordinary lineat regression
|
||||
\bm{X}^T\bm{X}=\bm{V}\bm{\Sigma}^T\bm{U}^T\bm{U}\bm{\Sigma}\bm{V}^T=\bm{V}\bm{\Sigma}^T\bm{\Sigma}\bm{V}^T.
|
||||
\]
|
||||
!et
|
||||
Since the matrices here have dimension $p\times p$, with $p$ corresponding to the singular values, we defined earlier the matrix
|
||||
Since the matrices here have dimension $p\times p$, with $p$ corresponding to the singular values, we defined last week the matrix
|
||||
!bt
|
||||
\[
|
||||
\bm{\Sigma}^T\bm{\Sigma} = \begin{bmatrix} \tilde{\bm{\Sigma}} & \bm{0}\\ \end{bmatrix}\begin{bmatrix} \tilde{\bm{\Sigma}} \\ \bm{0}\\ \end{bmatrix},
|
||||
@@ -251,6 +251,9 @@ particular for our discussion of the bias-variance tradeoff are rather
|
||||
interesting. We will see that for specific values of $\lambda$, we may
|
||||
even reduce the variance of the optimal parameters $\bm{\beta}$. These topics and other related ones, will be discussed after the more linear algebra oriented analysis here.
|
||||
|
||||
!split
|
||||
===== SVD analysis =====
|
||||
|
||||
Using our insights about the SVD of the design matrix $\bm{X}$
|
||||
We have already analyzed the OLS solutions in terms of the eigenvectors (the columns) of the right singular value matrix $\bm{U}$ as
|
||||
!bt
|
||||
@@ -352,7 +355,7 @@ we have that the derivative of the cost function is
|
||||
and reordering we have
|
||||
!bt
|
||||
\[
|
||||
\bm{X}^T\bm{X}\bm{\beta})+\lambda sgn(\bm{\beta})=2\bm{X}^T(\bm{y}.
|
||||
\bm{X}^T\bm{X}\bm{\beta}+\lambda sgn(\bm{\beta})=2\bm{X}^T\bm{y}.
|
||||
\]
|
||||
!et
|
||||
This equation does not lead to a nice analytical equation as in Ridge regression or ordinary least squares. This equation can however be solved by using standard convex optimization algorithms using for example the Python package "CVXOPT":"https://cvxopt.org/". We will discuss this later.
|
||||
@@ -366,7 +369,7 @@ This equation does not lead to a nice analytical equation as in Ridge regression
|
||||
Let us assume that our design matrix is given by unit (identity) matrix, that is a square diagonal matrix with ones only along the
|
||||
diagonal. In this case we have an equal number of rows and columns $n=p$.
|
||||
|
||||
Our model approximation is just $\tild{\bm{y}}=\bm{\beta}$ and the mean squared error and thereby the cost function for ordinary least sqquares (OLS) is then (we drop the term $1/n$)
|
||||
Our model approximation is just $\tilde{\bm{y}}=\bm{\beta}$ and the mean squared error and thereby the cost function for ordinary least sqquares (OLS) is then (we drop the term $1/n$)
|
||||
!bt
|
||||
\[
|
||||
C(\bm{\beta})=\sum_{i=0}^{p-1}(y_i-\beta_i)^2,
|
||||
@@ -416,7 +419,7 @@ which leads to
|
||||
\[
|
||||
\hat{\bm{\beta}}_i^{\mathrm{Lasso}} = \left\{\begin{array}{ccc}y_i-\frac{\lambda}{2} &\mathrm{if} & y_i> \frac{\lambda}{2}\\
|
||||
y_i+\frac{\lambda}{2} &\mathrm{if} & y_i< -\frac{\lambda}{2}\\
|
||||
0 &\mathrm{if} & \verty_i\vert\le \frac{\lambda}{2}\\
|
||||
0 &\mathrm{if} & \verty_i\vert\le \frac{\lambda}{2}\end{array}\right.\\.
|
||||
\]
|
||||
!et
|
||||
|
||||
|
||||
Reference in New Issue
Block a user