adding notes to scikit-learn
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,36 +371,32 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0000"></a>
|
||||
<!-- ------------------- main content ---------------------- -->
|
||||
|
||||
|
||||
|
||||
<div class="jumbotron">
|
||||
<center><h1>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</h1></center> <!-- document title -->
|
||||
<center>
|
||||
<h1>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</h1>
|
||||
</center> <!-- document title -->
|
||||
|
||||
<p>
|
||||
<!-- author(s): Morten Hjorth-Jensen -->
|
||||
|
||||
<center>
|
||||
<b>Morten Hjorth-Jensen</b> [1, 2]
|
||||
</center>
|
||||
|
||||
<p>
|
||||
<!-- institution(s) -->
|
||||
<center>
|
||||
[1] <b>Department of Physics, University of Oslo</b>
|
||||
</center>
|
||||
<center>
|
||||
[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b>
|
||||
</center>
|
||||
<br>
|
||||
<center>
|
||||
<h4>Nov 3, 2021</h4>
|
||||
</center> <!-- date -->
|
||||
<br>
|
||||
|
||||
<center>[1] <b>Department of Physics, University of Oslo</b></center>
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p>
|
||||
<center><h4>Sep 28, 2021</h4></center> <!-- date -->
|
||||
<br>
|
||||
<p>
|
||||
|
||||
|
||||
<p><a href="._week35-bs001.html" class="btn btn-primary btn-lg">Read »</a></p>
|
||||
@@ -434,25 +422,18 @@ MathJax.Hub.Config({
|
||||
<li><a href="._week35-bs001.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright --> © 1999-2021, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,14 +371,10 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0001"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="plans-for-week-35-august-30-september-3" class="anchor">Plans for week 35, August 30 -September 3 </h2>
|
||||
|
||||
<ul>
|
||||
@@ -396,7 +384,6 @@ MathJax.Hub.Config({
|
||||
<li> <a href="https://www.uio.no/studier/emner/matnat/fys/FYS-STK3155/h21/forelesningsvideoer/LectureSeptember3.mp4?vrtx=view-as-webpage" target="_self">Video of lecture Friday</a></li>
|
||||
<li> <a href="http://databookuw.com/page-2/page-4/" target="_self">Video series on the SVD</a>. Highly recommended.</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -417,25 +404,18 @@ MathJax.Hub.Config({
|
||||
<li><a href="._week35-bs002.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,26 +371,19 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0002"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="thursday-september-2" class="anchor">Thursday September 2 </h2>
|
||||
|
||||
<p>
|
||||
The main topics on Thursday are:
|
||||
|
||||
<p>The main topics on Thursday are:</p>
|
||||
<ol>
|
||||
<li> Repetition from last week on linear regression</li>
|
||||
<li> Discussion of how to prepare data and examples of applications of linear regression</li>
|
||||
<li> Mathematical interpretations of Linear Regression</li>
|
||||
<li> Start discussing Ridge and Lasso regression and Singular Value Decomposition</li>
|
||||
</ol>
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -420,25 +405,18 @@ The main topics on Thursday are:
|
||||
<li><a href="._week35-bs003.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,22 +371,15 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0003"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="why-linear-regression-aka-ordinary-least-squares-and-family-repeat-from-last-week" class="anchor">Why Linear Regression (aka Ordinary Least Squares and family), repeat from last week </h2>
|
||||
|
||||
<p>
|
||||
We need first a reminder from last week about linear regression.
|
||||
|
||||
<p>
|
||||
Fitting a continuous function with linear parameterization in terms of the parameters \( \boldsymbol{\beta} \).
|
||||
<p>We need first a reminder from last week about linear regression. </p>
|
||||
|
||||
<p>Fitting a continuous function with linear parameterization in terms of the parameters \( \boldsymbol{\beta} \).</p>
|
||||
<ul>
|
||||
<li> Method of choice for fitting a continuous function!</li>
|
||||
<li> Gives an excellent introduction to central Machine Learning features with <b>understandable pedagogical</b> links to other methods like <b>Neural Networks</b>, <b>Support Vector Machines</b> etc</li>
|
||||
@@ -406,11 +391,10 @@ Fitting a continuous function with linear parameterization in terms of the param
|
||||
<li> Allows for <b>easy</b> hands-on understanding of gradient descent methods</li>
|
||||
<li> and many more features</li>
|
||||
</ul>
|
||||
|
||||
For more discussions of Ridge and Lasso regression, <a href="https://arxiv.org/abs/1509.09169" target="_self">Wessel van Wieringen's</a> article is highly recommended.
|
||||
<p>For more discussions of Ridge and Lasso regression, <a href="https://arxiv.org/abs/1509.09169" target="_self">Wessel van Wieringen's</a> article is highly recommended.
|
||||
Similarly, <a href="https://arxiv.org/abs/1803.08823" target="_self">Mehta et al's article</a> is also recommended.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -433,25 +417,18 @@ Similarly, <a href="https://arxiv.org/abs/1803.08823" target="_self">Mehta et al
|
||||
<li><a href="._week35-bs004.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,38 +371,30 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0004"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="regression-analysis-overarching-aims" class="anchor">Regression analysis, overarching aims </h2>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
|
||||
<p>
|
||||
Regression modeling deals with the description of the sampling distribution of a given random variable \( y \) and how it varies as function of another variable or a set of such variables \( \boldsymbol{x} =[x_0, x_1,\dots, x_{n-1}]^T \).
|
||||
The first variable is called the <b>dependent</b>, the <b>outcome</b> or the <b>response</b> variable while the set of variables \( \boldsymbol{x} \) is called the independent variable, or the predictor variable or the explanatory variable.
|
||||
|
||||
<p>
|
||||
A regression model aims at finding a likelihood function \( p(\boldsymbol{y}\vert \boldsymbol{x}) \), that is the conditional distribution for \( \boldsymbol{y} \) with a given \( \boldsymbol{x} \). The estimation of \( p(\boldsymbol{y}\vert \boldsymbol{x}) \) is made using a data set with
|
||||
<p>Regression modeling deals with the description of the sampling distribution of a given random variable \( y \) and how it varies as function of another variable or a set of such variables \( \boldsymbol{x} =[x_0, x_1,\dots, x_{n-1}]^T \).
|
||||
The first variable is called the <b>dependent</b>, the <b>outcome</b> or the <b>response</b> variable while the set of variables \( \boldsymbol{x} \) is called the independent variable, or the predictor variable or the explanatory variable.
|
||||
</p>
|
||||
|
||||
<p>A regression model aims at finding a likelihood function \( p(\boldsymbol{y}\vert \boldsymbol{x}) \), that is the conditional distribution for \( \boldsymbol{y} \) with a given \( \boldsymbol{x} \). The estimation of \( p(\boldsymbol{y}\vert \boldsymbol{x}) \) is made using a data set with </p>
|
||||
<ul>
|
||||
<li> \( n \) cases \( i = 0, 1, 2, \dots, n-1 \)</li>
|
||||
<li> Response (target, dependent or outcome) variable \( y_i \) with \( i = 0, 1, 2, \dots, n-1 \)</li>
|
||||
<li> \( p \) so-called explanatory (independent or predictor) variables \( \boldsymbol{x}_i=[x_{i0}, x_{i1}, \dots, x_{ip-1}] \) with \( i = 0, 1, 2, \dots, n-1 \) and explanatory variables running from \( 0 \) to \( p-1 \). See below for more explicit examples.</li>
|
||||
</ul>
|
||||
|
||||
The goal of the regression analysis is to extract/exploit relationship between \( \boldsymbol{y} \) and \( \boldsymbol{x} \) in or to infer causal dependencies, approximations to the likelihood functions, functional relationships and to make predictions, making fits and many other things.
|
||||
<p> The goal of the regression analysis is to extract/exploit relationship between \( \boldsymbol{y} \) and \( \boldsymbol{x} \) in or to infer causal dependencies, approximations to the likelihood functions, functional relationships and to make predictions, making fits and many other things.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -434,25 +418,18 @@ A regression model aims at finding a likelihood function \( p(\boldsymbol{y}\ver
|
||||
<li><a href="._week35-bs005.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,26 +371,21 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0005"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="regression-analysis-overarching-aims-ii" class="anchor">Regression analysis, overarching aims II </h2>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
|
||||
<p>
|
||||
Consider an experiment in which \( p \) characteristics of \( n \) samples are
|
||||
<p>Consider an experiment in which \( p \) characteristics of \( n \) samples are
|
||||
measured. The data from this experiment, for various explanatory variables \( p \) are normally represented by a matrix
|
||||
\( \mathbf{X} \).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The matrix \( \mathbf{X} \) is called the <em>design
|
||||
<p>The matrix \( \mathbf{X} \) is called the <em>design
|
||||
matrix</em>. Additional information of the samples is available in the
|
||||
form of \( \boldsymbol{y} \) (also as above). The variable \( \boldsymbol{y} \) is
|
||||
generally referred to as the <em>response variable</em>. The aim of
|
||||
@@ -408,17 +395,14 @@ f(\mathbf{X}_{i,\ast}) \). When no prior knowledge on the form of
|
||||
\( f(\cdot) \) is available, it is common to assume a linear relationship
|
||||
between \( \boldsymbol{X} \) and \( \boldsymbol{y} \). This assumption gives rise to
|
||||
the <em>linear regression model</em> where \( \boldsymbol{\beta} = [\beta_0, \ldots,
|
||||
\beta_{p-1}]^{T} \) are the <em>regression parameters</em>.
|
||||
\beta_{p-1}]^{T} \) are the <em>regression parameters</em>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Linear regression gives us a set of analytical equations for the parameters \( \beta_j \).
|
||||
|
||||
<p>
|
||||
<p>Linear regression gives us a set of analytical equations for the parameters \( \beta_j \).</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -443,25 +427,18 @@ Linear regression gives us a set of analytical equations for the parameters \( \
|
||||
<li><a href="._week35-bs006.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,42 +371,37 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0006"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="examples" class="anchor">Examples </h2>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
In order to understand the relation among the predictors \( p \), the set of data \( n \) and the target (outcome, output etc) \( \boldsymbol{y} \),
|
||||
consider the model we discussed for describing nuclear binding energies.
|
||||
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
<p>In order to understand the relation among the predictors \( p \), the set of data \( n \) and the target (outcome, output etc) \( \boldsymbol{y} \),
|
||||
consider the model we discussed for describing nuclear binding energies.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
There we assumed that we could parametrize the data using a polynomial approximation based on the liquid drop model.
|
||||
<p>There we assumed that we could parametrize the data using a polynomial approximation based on the liquid drop model.
|
||||
Assuming
|
||||
</p>
|
||||
$$
|
||||
BE(A) = a_0+a_1A+a_2A^{2/3}+a_3A^{-1/3}+a_4A^{-1},
|
||||
$$
|
||||
|
||||
we have five predictors, that is the intercept, the \( A \) dependent term, the \( A^{2/3} \) term and the \( A^{-1/3} \) and \( A^{-1} \) terms.
|
||||
<p>we have five predictors, that is the intercept, the \( A \) dependent term, the \( A^{2/3} \) term and the \( A^{-1/3} \) and \( A^{-1} \) terms.
|
||||
This gives \( p=0,1,2,3,4 \). Furthermore we have \( n \) entries for each predictor. It means that our design matrix is a
|
||||
\( p\times n \) matrix \( \boldsymbol{X} \).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Here the predictors are based on a model we have made. A popular data set which is widely encountered in ML applications is the
|
||||
so-called <a href="https://www.sciencedirect.com/science/article/pii/S0957417407006719?via%3Dihub" target="_self">credit card default data from Taiwan</a>. The data set contains data on \( n=30000 \) credit card holders with predictors like gender, marital status, age, profession, education, etc. In total there are \( 24 \) such predictors or attributes leading to a design matrix of dimensionality \( 24 \times 30000 \). This is however a classification problem and we will come back to it when we discuss Logistic Regression.
|
||||
|
||||
<p>
|
||||
<p>Here the predictors are based on a model we have made. A popular data set which is widely encountered in ML applications is the
|
||||
so-called <a href="https://www.sciencedirect.com/science/article/pii/S0957417407006719?via%3Dihub" target="_self">credit card default data from Taiwan</a>. The data set contains data on \( n=30000 \) credit card holders with predictors like gender, marital status, age, profession, education, etc. In total there are \( 24 \) such predictors or attributes leading to a design matrix of dimensionality \( 24 \times 30000 \). This is however a classification problem and we will come back to it when we discuss Logistic Regression.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -440,25 +427,18 @@ so-called <a href="https://www.sciencedirect.com/science/article/pii/S0957417407
|
||||
<li><a href="._week35-bs007.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,34 +371,26 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0007"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="general-linear-models" class="anchor">General linear models </h2>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
Before we proceed let us study a case from linear algebra where we aim at fitting a set of data \( \boldsymbol{y}=[y_0,y_1,\dots,y_{n-1}] \). We could think of these data as a result of an experiment or a complicated numerical experiment. These data are functions of a series of variables \( \boldsymbol{x}=[x_0,x_1,\dots,x_{n-1}] \), that is \( y_i = y(x_i) \) with \( i=0,1,2,\dots,n-1 \). The variables \( x_i \) could represent physical quantities like time, temperature, position etc. We assume that \( y(x) \) is a smooth function.
|
||||
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
<p>Before we proceed let us study a case from linear algebra where we aim at fitting a set of data \( \boldsymbol{y}=[y_0,y_1,\dots,y_{n-1}] \). We could think of these data as a result of an experiment or a complicated numerical experiment. These data are functions of a series of variables \( \boldsymbol{x}=[x_0,x_1,\dots,x_{n-1}] \), that is \( y_i = y(x_i) \) with \( i=0,1,2,\dots,n-1 \). The variables \( x_i \) could represent physical quantities like time, temperature, position etc. We assume that \( y(x) \) is a smooth function. </p>
|
||||
|
||||
<p>
|
||||
Since obtaining these data points may not be trivial, we want to use these data to fit a function which can allow us to make predictions for values of \( y \) which are not in the present set. The perhaps simplest approach is to assume we can parametrize our function in terms of a polynomial of degree \( n-1 \) with \( n \) points, that is
|
||||
<p>Since obtaining these data points may not be trivial, we want to use these data to fit a function which can allow us to make predictions for values of \( y \) which are not in the present set. The perhaps simplest approach is to assume we can parametrize our function in terms of a polynomial of degree \( n-1 \) with \( n \) points, that is</p>
|
||||
$$
|
||||
y=y(x) \rightarrow y(x_i)=\tilde{y}_i+\epsilon_i=\sum_{j=0}^{n-1} \beta_j x_i^j+\epsilon_i,
|
||||
$$
|
||||
|
||||
where \( \epsilon_i \) is the error in our approximation.
|
||||
|
||||
<p>
|
||||
<p>where \( \epsilon_i \) is the error in our approximation. </p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -433,25 +417,18 @@ where \( \epsilon_i \) is the error in our approximation.
|
||||
<li><a href="._week35-bs008.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,19 +371,15 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0008"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="rewriting-the-fitting-procedure-as-a-linear-algebra-problem" class="anchor">Rewriting the fitting procedure as a linear algebra problem </h2>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
For every set of values \( y_i,x_i \) we have thus the corresponding set of equations
|
||||
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
<p>For every set of values \( y_i,x_i \) we have thus the corresponding set of equations</p>
|
||||
$$
|
||||
\begin{align*}
|
||||
y_0&=\beta_0+\beta_1x_0^1+\beta_2x_0^2+\dots+\beta_{n-1}x_0^{n-1}+\epsilon_0\\
|
||||
@@ -405,7 +393,6 @@ $$
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -433,25 +420,18 @@ $$
|
||||
<li><a href="._week35-bs009.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,34 +371,30 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0009"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="rewriting-the-fitting-procedure-as-a-linear-algebra-problem-more-details" class="anchor">Rewriting the fitting procedure as a linear algebra problem, more details </h2>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
Defining the vectors
|
||||
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
<p>Defining the vectors</p>
|
||||
$$
|
||||
\boldsymbol{y} = [y_0,y_1, y_2,\dots, y_{n-1}]^T,
|
||||
$$
|
||||
|
||||
and
|
||||
<p>and</p>
|
||||
$$
|
||||
\boldsymbol{\beta} = [\beta_0,\beta_1, \beta_2,\dots, \beta_{n-1}]^T,
|
||||
$$
|
||||
|
||||
and
|
||||
<p>and</p>
|
||||
$$
|
||||
\boldsymbol{\epsilon} = [\epsilon_0,\epsilon_1, \epsilon_2,\dots, \epsilon_{n-1}]^T,
|
||||
$$
|
||||
|
||||
and the design matrix
|
||||
<p>and the design matrix</p>
|
||||
$$
|
||||
\boldsymbol{X}=
|
||||
\begin{bmatrix}
|
||||
@@ -418,17 +406,16 @@ $$
|
||||
\end{bmatrix}
|
||||
$$
|
||||
|
||||
we can rewrite our equations as
|
||||
<p>we can rewrite our equations as</p>
|
||||
$$
|
||||
\boldsymbol{y} = \boldsymbol{X}\boldsymbol{\beta}+\boldsymbol{\epsilon}.
|
||||
$$
|
||||
|
||||
The above design matrix is called a <a href="https://en.wikipedia.org/wiki/Vandermonde_matrix" target="_self">Vandermonde matrix</a>.
|
||||
<p>The above design matrix is called a <a href="https://en.wikipedia.org/wiki/Vandermonde_matrix" target="_self">Vandermonde matrix</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -457,25 +444,18 @@ The above design matrix is called a <a href="https://en.wikipedia.org/wiki/Vande
|
||||
<li><a href="._week35-bs010.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,25 +371,21 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0010"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="generalizing-the-fitting-procedure-as-a-linear-algebra-problem" class="anchor">Generalizing the fitting procedure as a linear algebra problem </h2>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
|
||||
<p>
|
||||
We are obviously not limited to the above polynomial expansions. We
|
||||
<p>We are obviously not limited to the above polynomial expansions. We
|
||||
could replace the various powers of \( x \) with elements of Fourier
|
||||
series or instead of \( x_i^j \) we could have \( \cos{(j x_i)} \) or \( \sin{(j
|
||||
x_i)} \), or time series or other orthogonal functions. For every set
|
||||
of values \( y_i,x_i \) we can then generalize the equations to
|
||||
</p>
|
||||
|
||||
$$
|
||||
\begin{align*}
|
||||
@@ -411,13 +399,12 @@ y_{n-1}&=\beta_0x_{n-1,0}+\beta_1x_{n-1,2}+\beta_2x_{n-1,2}+\dots+\beta_{n-1}x_{
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
<p>
|
||||
|
||||
<b>Note that we have \( p=n \) here. The matrix is symmetric. This is generally not the case!</b>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -447,25 +434,18 @@ $$
|
||||
<li><a href="._week35-bs011.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,19 +371,15 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0011"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="generalizing-the-fitting-procedure-as-a-linear-algebra-problem" class="anchor">Generalizing the fitting procedure as a linear algebra problem </h2>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
We redefine in turn the matrix \( \boldsymbol{X} \) as
|
||||
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
<p>We redefine in turn the matrix \( \boldsymbol{X} \) as</p>
|
||||
$$
|
||||
\boldsymbol{X}=
|
||||
\begin{bmatrix}
|
||||
@@ -403,17 +391,16 @@ x_{n-1,0}& x_{n-1,1} &x_{n-1,2}& \dots & \dots &x_{n-1,n-1}\\
|
||||
\end{bmatrix}
|
||||
$$
|
||||
|
||||
and without loss of generality we rewrite again our equations as
|
||||
<p>and without loss of generality we rewrite again our equations as</p>
|
||||
$$
|
||||
\boldsymbol{y} = \boldsymbol{X}\boldsymbol{\beta}+\boldsymbol{\epsilon}.
|
||||
$$
|
||||
|
||||
The left-hand side of this equation is kwown. Our error vector \( \boldsymbol{\epsilon} \) and the parameter vector \( \boldsymbol{\beta} \) are our unknow quantities. How can we obtain the optimal set of \( \beta_i \) values?
|
||||
<p>The left-hand side of this equation is kwown. Our error vector \( \boldsymbol{\epsilon} \) and the parameter vector \( \boldsymbol{\beta} \) are our unknow quantities. How can we obtain the optimal set of \( \beta_i \) values? </p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -443,25 +430,18 @@ The left-hand side of this equation is kwown. Our error vector \( \boldsymbol{\e
|
||||
<li><a href="._week35-bs012.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,19 +371,15 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0012"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="optimizing-our-parameters" class="anchor">Optimizing our parameters </h2>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
We have defined the matrix \( \boldsymbol{X} \) via the equations
|
||||
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
<p>We have defined the matrix \( \boldsymbol{X} \) via the equations</p>
|
||||
$$
|
||||
\begin{align*}
|
||||
y_0&=\beta_0x_{00}+\beta_1x_{01}+\beta_2x_{02}+\dots+\beta_{n-1}x_{0n-1}+\epsilon_0\\
|
||||
@@ -404,17 +392,14 @@ y_{n-1}&=\beta_0x_{n-1,0}+\beta_1x_{n-1,2}+\beta_2x_{n-1,2}+\dots+\beta_{n-1}x_{
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
<p>
|
||||
As we noted above, we stayed with a system with the design matrix
|
||||
<p>As we noted above, we stayed with a system with the design matrix
|
||||
\( \boldsymbol{X}\in {\mathbb{R}}^{n\times n} \), that is we have \( p=n \). For reasons to come later (algorithmic arguments) we will hereafter define
|
||||
our matrix as \( \boldsymbol{X}\in {\mathbb{R}}^{n\times p} \), with the predictors refering to the column numbers and the entries \( n \) being the row elements.
|
||||
|
||||
<p>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -444,25 +429,18 @@ our matrix as \( \boldsymbol{X}\in {\mathbb{R}}^{n\times p} \), with the predict
|
||||
<li><a href="._week35-bs013.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,25 +371,23 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0013"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="our-model-for-the-nuclear-binding-energies" class="anchor">Our model for the nuclear binding energies </h2>
|
||||
|
||||
<p>
|
||||
In our <a href="https://compphysics.github.io/MachineLearning/doc/pub/How2ReadData/html/How2ReadData.html" target="_self">introductory notes</a> we looked at the so-called <a href="https://en.wikipedia.org/wiki/Semi-empirical_mass_formula" target="_self">liquid drop model</a>. Let us remind ourselves about what we did by looking at the code.
|
||||
<p>In our <a href="https://compphysics.github.io/MachineLearning/doc/pub/How2ReadData/html/How2ReadData.html" target="_self">introductory notes</a> we looked at the so-called <a href="https://en.wikipedia.org/wiki/Semi-empirical_mass_formula" target="_self">liquid drop model</a>. Let us remind ourselves about what we did by looking at the code.</p>
|
||||
|
||||
<p>
|
||||
We restate the parts of the code we are most interested in.
|
||||
<p>
|
||||
<p>We restate the parts of the code we are most interested in.</p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #408080; font-style: italic"># Common imports</span>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #408080; font-style: italic"># Common imports</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">pandas</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">pd</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">matplotlib.pyplot</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">plt</span>
|
||||
@@ -466,16 +456,28 @@ DesignMatrix <span style="color: #666666">=</span> pd<span style="color: #666666
|
||||
DesignMatrix<span style="color: #666666">.</span>index <span style="color: #666666">=</span> A
|
||||
DesignMatrix<span style="color: #666666">.</span>columns <span style="color: #666666">=</span> [<span style="color: #BA2121">'1'</span>, <span style="color: #BA2121">'A'</span>, <span style="color: #BA2121">'A^(2/3)'</span>, <span style="color: #BA2121">'A^(-1/3)'</span>, <span style="color: #BA2121">'1/A'</span>]
|
||||
display(DesignMatrix)
|
||||
</pre></div>
|
||||
<p>
|
||||
With \( \boldsymbol{\beta}\in {\mathbb{R}}^{p\times 1} \), it means that we will hereafter write our equations for the approximation as
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>With \( \boldsymbol{\beta}\in {\mathbb{R}}^{p\times 1} \), it means that we will hereafter write our equations for the approximation as</p>
|
||||
$$
|
||||
\boldsymbol{\tilde{y}}= \boldsymbol{X}\boldsymbol{\beta},
|
||||
$$
|
||||
|
||||
throughout these lectures.
|
||||
<p>throughout these lectures. </p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -505,25 +507,18 @@ throughout these lectures.
|
||||
<li><a href="._week35-bs014.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,49 +371,44 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0014"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="optimizing-our-parameters-more-details" class="anchor">Optimizing our parameters, more details </h2>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
With the above we use the design matrix to define the approximation \( \boldsymbol{\tilde{y}} \) via the unknown quantity \( \boldsymbol{\beta} \) as
|
||||
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
<p>With the above we use the design matrix to define the approximation \( \boldsymbol{\tilde{y}} \) via the unknown quantity \( \boldsymbol{\beta} \) as</p>
|
||||
$$
|
||||
\boldsymbol{\tilde{y}}= \boldsymbol{X}\boldsymbol{\beta},
|
||||
$$
|
||||
|
||||
and in order to find the optimal parameters \( \beta_i \) instead of solving the above linear algebra problem, we define a function which gives a measure of the spread between the values \( y_i \) (which represent hopefully the exact values) and the parameterized values \( \tilde{y}_i \), namely
|
||||
<p>and in order to find the optimal parameters \( \beta_i \) instead of solving the above linear algebra problem, we define a function which gives a measure of the spread between the values \( y_i \) (which represent hopefully the exact values) and the parameterized values \( \tilde{y}_i \), namely</p>
|
||||
$$
|
||||
C(\boldsymbol{\beta})=\frac{1}{n}\sum_{i=0}^{n-1}\left(y_i-\tilde{y}_i\right)^2=\frac{1}{n}\left\{\left(\boldsymbol{y}-\boldsymbol{\tilde{y}}\right)^T\left(\boldsymbol{y}-\boldsymbol{\tilde{y}}\right)\right\},
|
||||
$$
|
||||
|
||||
or using the matrix \( \boldsymbol{X} \) and in a more compact matrix-vector notation as
|
||||
<p>or using the matrix \( \boldsymbol{X} \) and in a more compact matrix-vector notation as</p>
|
||||
$$
|
||||
C(\boldsymbol{\beta})=\frac{1}{n}\left\{\left(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\right)^T\left(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\right)\right\}.
|
||||
$$
|
||||
|
||||
This function is one possible way to define the so-called cost function.
|
||||
<p>This function is one possible way to define the so-called cost function.</p>
|
||||
|
||||
<p>
|
||||
It is also common to define
|
||||
<p>It is also common to define
|
||||
the function \( C \) as
|
||||
</p>
|
||||
|
||||
$$
|
||||
C(\boldsymbol{\beta})=\frac{1}{2n}\sum_{i=0}^{n-1}\left(y_i-\tilde{y}_i\right)^2,
|
||||
$$
|
||||
|
||||
since when taking the first derivative with respect to the unknown parameters \( \beta \), the factor of \( 2 \) cancels out.
|
||||
<p>since when taking the first derivative with respect to the unknown parameters \( \beta \), the factor of \( 2 \) cancels out. </p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -451,25 +438,18 @@ since when taking the first derivative with respect to the unknown parameters \(
|
||||
<li><a href="._week35-bs015.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,33 +371,28 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0015"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="interpretations-and-optimizing-our-parameters" class="anchor">Interpretations and optimizing our parameters </h2>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
|
||||
<p>
|
||||
The function
|
||||
<p>The function </p>
|
||||
$$
|
||||
C(\boldsymbol{\beta})=\frac{1}{n}\left\{\left(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\right)^T\left(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\right)\right\},
|
||||
$$
|
||||
|
||||
can be linked to the variance of the quantity \( y_i \) if we interpret the latter as the mean value.
|
||||
<p>can be linked to the variance of the quantity \( y_i \) if we interpret the latter as the mean value.
|
||||
When linking (see the discussion below) with the maximum likelihood approach below, we will indeed interpret \( y_i \) as a mean value
|
||||
</p>
|
||||
$$
|
||||
y_{i}=\langle y_i \rangle = \beta_0x_{i,0}+\beta_1x_{i,1}+\beta_2x_{i,2}+\dots+\beta_{n-1}x_{i,n-1}+\epsilon_i,
|
||||
$$
|
||||
|
||||
<p>
|
||||
where \( \langle y_i \rangle \) is the mean value. Keep in mind also that
|
||||
<p>where \( \langle y_i \rangle \) is the mean value. Keep in mind also that
|
||||
till now we have treated \( y_i \) as the exact value. Normally, the
|
||||
response (dependent or outcome) variable \( y_i \) the outcome of a
|
||||
numerical experiment or another type of experiment and is thus only an
|
||||
@@ -413,35 +400,32 @@ approximation to the true value. It is then always accompanied by an
|
||||
error estimate, often limited to a statistical error estimate given by
|
||||
the standard deviation discussed earlier. In the discussion here we
|
||||
will treat \( y_i \) as our exact value for the response variable.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
In order to find the parameters \( \beta_i \) we will then minimize the spread of \( C(\boldsymbol{\beta}) \), that is we are going to solve the problem
|
||||
<p>In order to find the parameters \( \beta_i \) we will then minimize the spread of \( C(\boldsymbol{\beta}) \), that is we are going to solve the problem</p>
|
||||
$$
|
||||
{\displaystyle \min_{\boldsymbol{\beta}\in
|
||||
{\mathbb{R}}^{p}}}\frac{1}{n}\left\{\left(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\right)^T\left(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\right)\right\}.
|
||||
$$
|
||||
|
||||
In practical terms it means we will require
|
||||
<p>In practical terms it means we will require</p>
|
||||
$$
|
||||
\frac{\partial C(\boldsymbol{\beta})}{\partial \beta_j} = \frac{\partial }{\partial \beta_j}\left[ \frac{1}{n}\sum_{i=0}^{n-1}\left(y_i-\beta_0x_{i,0}-\beta_1x_{i,1}-\beta_2x_{i,2}-\dots-\beta_{n-1}x_{i,n-1}\right)^2\right]=0,
|
||||
$$
|
||||
|
||||
which results in
|
||||
<p>which results in</p>
|
||||
$$
|
||||
\frac{\partial C(\boldsymbol{\beta})}{\partial \beta_j} = -\frac{2}{n}\left[ \sum_{i=0}^{n-1}x_{ij}\left(y_i-\beta_0x_{i,0}-\beta_1x_{i,1}-\beta_2x_{i,2}-\dots-\beta_{n-1}x_{i,n-1}\right)\right]=0,
|
||||
$$
|
||||
|
||||
or in a matrix-vector form as
|
||||
<p>or in a matrix-vector form as</p>
|
||||
$$
|
||||
\frac{\partial C(\boldsymbol{\beta})}{\partial \boldsymbol{\beta}} = 0 = \boldsymbol{X}^T\left( \boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\right).
|
||||
$$
|
||||
|
||||
<p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -471,25 +455,18 @@ $$
|
||||
<li><a href="._week35-bs016.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,35 +371,30 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0016"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="interpretations-and-optimizing-our-parameters" class="anchor">Interpretations and optimizing our parameters </h2>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
We can rewrite
|
||||
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
<p>We can rewrite</p>
|
||||
$$
|
||||
\frac{\partial C(\boldsymbol{\beta})}{\partial \boldsymbol{\beta}} = 0 = \boldsymbol{X}^T\left( \boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\right),
|
||||
$$
|
||||
|
||||
as
|
||||
<p>as</p>
|
||||
$$
|
||||
\boldsymbol{X}^T\boldsymbol{y} = \boldsymbol{X}^T\boldsymbol{X}\boldsymbol{\beta},
|
||||
$$
|
||||
|
||||
and if the matrix \( \boldsymbol{X}^T\boldsymbol{X} \) is invertible we have the solution
|
||||
<p>and if the matrix \( \boldsymbol{X}^T\boldsymbol{X} \) is invertible we have the solution</p>
|
||||
$$
|
||||
\boldsymbol{\beta} =\left(\boldsymbol{X}^T\boldsymbol{X}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
We note also that since our design matrix is defined as \( \boldsymbol{X}\in
|
||||
<p>We note also that since our design matrix is defined as \( \boldsymbol{X}\in
|
||||
{\mathbb{R}}^{n\times p} \), the product \( \boldsymbol{X}^T\boldsymbol{X} \in
|
||||
{\mathbb{R}}^{p\times p} \). In the above case we have that \( p \ll n \),
|
||||
in our case \( p=5 \) meaning that we end up with inverting a small
|
||||
@@ -416,21 +403,20 @@ matrices to invert. The methods discussed here and for many other
|
||||
supervised learning algorithms like classification with logistic
|
||||
regression or support vector machines, exhibit dimensionalities which
|
||||
allow for the usage of direct linear algebra methods such as <b>LU</b> decomposition or <b>Singular Value Decomposition</b> (SVD) for finding the inverse of the matrix
|
||||
\( \boldsymbol{X}^T\boldsymbol{X} \).
|
||||
\( \boldsymbol{X}^T\boldsymbol{X} \).
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
<b>Small question</b>: Do you think the example we have at hand here (the nuclear binding energies) can lead to problems in inverting the matrix \( \boldsymbol{X}^T\boldsymbol{X} \)? What kind of problems can we expect?
|
||||
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
<p><b>Small question</b>: Do you think the example we have at hand here (the nuclear binding energies) can lead to problems in inverting the matrix \( \boldsymbol{X}^T\boldsymbol{X} \)? What kind of problems can we expect? </p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -460,25 +446,18 @@ allow for the usage of direct linear algebra methods such as <b>LU</b> decomposi
|
||||
<li><a href="._week35-bs017.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,19 +371,15 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0017"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="some-useful-matrix-and-vector-expressions" class="anchor">Some useful matrix and vector expressions </h2>
|
||||
|
||||
<p>
|
||||
The following matrix and vector relation will be useful here and for the rest of the course. Vectors are always written as boldfaced lower case letters and
|
||||
<p>The following matrix and vector relation will be useful here and for the rest of the course. Vectors are always written as boldfaced lower case letters and
|
||||
matrices as upper case boldfaced letters.
|
||||
</p>
|
||||
|
||||
$$
|
||||
\frac{\partial (\boldsymbol{b}^T\boldsymbol{a})}{\partial \boldsymbol{a}} = \boldsymbol{b},
|
||||
@@ -409,7 +397,7 @@ $$
|
||||
\frac{\partial \log{\vert\boldsymbol{A}\vert}}{\partial \boldsymbol{A}} = (\boldsymbol{A}^{-1})^T.
|
||||
$$
|
||||
|
||||
<p>
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -439,25 +427,18 @@ $$
|
||||
<li><a href="._week35-bs018.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,47 +371,40 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0018"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="meet-the-hessian-matrix" class="anchor">Meet the Hessian Matrix </h2>
|
||||
|
||||
<p>
|
||||
A very important matrix we will meet again and again in Machine
|
||||
<p>A very important matrix we will meet again and again in Machine
|
||||
Learning is the Hessian. It is given by the second derivative of the
|
||||
cost function with respect to the parameter \( \beta \). Using the above
|
||||
expression for derivatives of vectors and matrices, we find that the
|
||||
second derivative of the cost function is,
|
||||
</p>
|
||||
|
||||
$$
|
||||
\frac{\partial}{\partial \boldsymbol{\beta}^T}\frac{\partial C(\boldsymbol{\beta})}{\partial \boldsymbol{\beta}} =\frac{\partial}{\partial \boldsymbol{\beta}}\left[-\frac{2}{n}\boldsymbol{X}^T\left( \boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\right)\right]=\frac{2}{n}\boldsymbol{X}^T\boldsymbol{X}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
The Hessian matrix plays an important role and is defined here as
|
||||
<p>The Hessian matrix plays an important role and is defined here as</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{H}=\boldsymbol{X}^T\boldsymbol{X}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
For ordinary least squares, it is inversely proportional (derivation
|
||||
<p>For ordinary least squares, it is inversely proportional (derivation
|
||||
next week) with the variance of the optimal parameters
|
||||
\( \hat{\boldsymbol{\beta}} \). Furthermore, we will see later this week that is
|
||||
(beside \( 1/n \)) equal to the covariance matrix. It plays also a very
|
||||
important role in optmization algorithms and Principal Component
|
||||
Analysis as a way to reduce the dimensionality of a machine learning
|
||||
problem.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Linear algebra question:</b> Can we use the Hessian matrix to say something about properties of the cost function (our optmization problem)? (hint: think about convex or concave problems and how to relate these to a matrix!).
|
||||
<p><b>Linear algebra question:</b> Can we use the Hessian matrix to say something about properties of the cost function (our optmization problem)? (hint: think about convex or concave problems and how to relate these to a matrix!). </p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -449,25 +434,18 @@ problem.
|
||||
<li><a href="._week35-bs019.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,41 +371,34 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0019"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="interpretations-and-optimizing-our-parameters" class="anchor">Interpretations and optimizing our parameters </h2>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
The residuals \( \boldsymbol{\epsilon} \) are in turn given by
|
||||
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
<p>The residuals \( \boldsymbol{\epsilon} \) are in turn given by</p>
|
||||
$$
|
||||
\boldsymbol{\epsilon} = \boldsymbol{y}-\boldsymbol{\tilde{y}} = \boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta},
|
||||
$$
|
||||
|
||||
and with
|
||||
<p>and with </p>
|
||||
$$
|
||||
\boldsymbol{X}^T\left( \boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\right)= 0,
|
||||
$$
|
||||
|
||||
we have
|
||||
<p>we have</p>
|
||||
$$
|
||||
\boldsymbol{X}^T\boldsymbol{\epsilon}=\boldsymbol{X}^T\left( \boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\right)= 0,
|
||||
$$
|
||||
|
||||
meaning that the solution for \( \boldsymbol{\beta} \) is the one which minimizes the residuals. Later we will link this with the maximum likelihood approach.
|
||||
|
||||
<p>
|
||||
<p>meaning that the solution for \( \boldsymbol{\beta} \) is the one which minimizes the residuals. Later we will link this with the maximum likelihood approach.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -443,25 +428,18 @@ meaning that the solution for \( \boldsymbol{\beta} \) is the one which minimize
|
||||
<li><a href="._week35-bs020.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,41 +371,75 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0020"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="own-code-for-ordinary-least-squares" class="anchor">Own code for Ordinary Least Squares </h2>
|
||||
|
||||
<p>
|
||||
It is rather straightforward to implement the matrix inversion and obtain the parameters \( \boldsymbol{\beta} \). After having defined the matrix \( \boldsymbol{X} \) we simply need to
|
||||
<p>It is rather straightforward to implement the matrix inversion and obtain the parameters \( \boldsymbol{\beta} \). After having defined the matrix \( \boldsymbol{X} \) we simply need to
|
||||
write
|
||||
<p>
|
||||
</p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #408080; font-style: italic"># matrix inversion to find beta</span>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #408080; font-style: italic"># matrix inversion to find beta</span>
|
||||
beta <span style="color: #666666">=</span> np<span style="color: #666666">.</span>linalg<span style="color: #666666">.</span>inv(X<span style="color: #666666">.</span>T<span style="color: #666666">.</span>dot(X))<span style="color: #666666">.</span>dot(X<span style="color: #666666">.</span>T)<span style="color: #666666">.</span>dot(Energies)
|
||||
<span style="color: #408080; font-style: italic"># and then make the prediction</span>
|
||||
ytilde <span style="color: #666666">=</span> X <span style="color: #666666">@</span> beta
|
||||
</pre></div>
|
||||
<p>
|
||||
Alternatively, you can use the least squares functionality in <b>Numpy</b> as
|
||||
<p>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>Alternatively, you can use the least squares functionality in <b>Numpy</b> as</p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span>fit <span style="color: #666666">=</span> np<span style="color: #666666">.</span>linalg<span style="color: #666666">.</span>lstsq(X, Energies, rcond <span style="color: #666666">=</span><span style="color: #008000; font-weight: bold">None</span>)[<span style="color: #666666">0</span>]
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;">fit <span style="color: #666666">=</span> np<span style="color: #666666">.</span>linalg<span style="color: #666666">.</span>lstsq(X, Energies, rcond <span style="color: #666666">=</span><span style="color: #008000; font-weight: bold">None</span>)[<span style="color: #666666">0</span>]
|
||||
ytildenp <span style="color: #666666">=</span> np<span style="color: #666666">.</span>dot(fit,X<span style="color: #666666">.</span>T)
|
||||
</pre></div>
|
||||
<p>
|
||||
And finally we plot our fit with and compare with data
|
||||
<p>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>And finally we plot our fit with and compare with data</p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span>Masses[<span style="color: #BA2121">'Eapprox'</span>] <span style="color: #666666">=</span> ytilde
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;">Masses[<span style="color: #BA2121">'Eapprox'</span>] <span style="color: #666666">=</span> ytilde
|
||||
<span style="color: #408080; font-style: italic"># Generate a plot comparing the experimental with the fitted values values.</span>
|
||||
fig, ax <span style="color: #666666">=</span> plt<span style="color: #666666">.</span>subplots()
|
||||
ax<span style="color: #666666">.</span>set_xlabel(<span style="color: #BA2121">r'$A = N + Z$'</span>)
|
||||
@@ -425,8 +451,22 @@ ax<span style="color: #666666">.</span>plot(Masses[<span style="color: #BA2121">
|
||||
ax<span style="color: #666666">.</span>legend()
|
||||
save_fig(<span style="color: #BA2121">"Masses2016OLS"</span>)
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
<p>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -456,25 +496,18 @@ plt<span style="color: #666666">.</span>show()
|
||||
<li><a href="._week35-bs021.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,53 +371,118 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0021"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="adding-error-analysis-and-training-set-up" class="anchor">Adding error analysis and training set up </h2>
|
||||
|
||||
<p>
|
||||
We can easily test our fit by computing the \( R2 \) score that we discussed in connection with the functionality of <b>Scikit-Learn</b> in the introductory slides.
|
||||
<p>We can easily test our fit by computing the \( R2 \) score that we discussed in connection with the functionality of <b>Scikit-Learn</b> in the introductory slides.
|
||||
Since we are not using <b>Scikit-Learn</b> here we can define our own \( R2 \) function as
|
||||
<p>
|
||||
</p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">R2</span>(y_data, y_model):
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">R2</span>(y_data, y_model):
|
||||
<span style="color: #008000; font-weight: bold">return</span> <span style="color: #666666">1</span> <span style="color: #666666">-</span> np<span style="color: #666666">.</span>sum((y_data <span style="color: #666666">-</span> y_model) <span style="color: #666666">**</span> <span style="color: #666666">2</span>) <span style="color: #666666">/</span> np<span style="color: #666666">.</span>sum((y_data <span style="color: #666666">-</span> np<span style="color: #666666">.</span>mean(y_data)) <span style="color: #666666">**</span> <span style="color: #666666">2</span>)
|
||||
</pre></div>
|
||||
<p>
|
||||
and we would be using it as
|
||||
<p>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>and we would be using it as </p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000">print</span>(R2(Energies,ytilde))
|
||||
</pre></div>
|
||||
<p>
|
||||
We can easily add our <b>MSE</b> score as
|
||||
<p>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #008000">print</span>(R2(Energies,ytilde))
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>We can easily add our <b>MSE</b> score as</p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">MSE</span>(y_data,y_model):
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">MSE</span>(y_data,y_model):
|
||||
n <span style="color: #666666">=</span> np<span style="color: #666666">.</span>size(y_model)
|
||||
<span style="color: #008000; font-weight: bold">return</span> np<span style="color: #666666">.</span>sum((y_data<span style="color: #666666">-</span>y_model)<span style="color: #666666">**2</span>)<span style="color: #666666">/</span>n
|
||||
|
||||
<span style="color: #008000">print</span>(MSE(Energies,ytilde))
|
||||
</pre></div>
|
||||
<p>
|
||||
and finally the relative error as
|
||||
<p>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>and finally the relative error as</p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">RelativeError</span>(y_data,y_model):
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">RelativeError</span>(y_data,y_model):
|
||||
<span style="color: #008000; font-weight: bold">return</span> <span style="color: #008000">abs</span>((y_data<span style="color: #666666">-</span>y_model)<span style="color: #666666">/</span>y_data)
|
||||
<span style="color: #008000">print</span>(RelativeError(Energies, ytilde))
|
||||
</pre></div>
|
||||
<p>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -455,25 +512,18 @@ and finally the relative error as
|
||||
<li><a href="._week35-bs022.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,23 +371,17 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0022"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="splitting-our-data-in-training-and-test-data" class="anchor">Splitting our Data in Training and Test data </h2>
|
||||
|
||||
<p>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
|
||||
<p>
|
||||
It is normal in essentially all Machine Learning studies to split the
|
||||
<p>It is normal in essentially all Machine Learning studies to split the
|
||||
data in a training set and a test set (sometimes also an additional
|
||||
validation set). <b>Scikit-Learn</b> has an own function for this. There
|
||||
is no explicit recipe for how much data should be included as training
|
||||
@@ -405,13 +391,11 @@ postpone a discussion of this splitting to the end of these notes and
|
||||
our discussion of the so-called <b>bias-variance</b> tradeoff. Here we
|
||||
limit ourselves to repeat the above equation of state fitting example
|
||||
but now splitting the data into a training set and a test set.
|
||||
|
||||
<p>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -441,25 +425,18 @@ but now splitting the data into a training set and a test set.
|
||||
<li><a href="._week35-bs023.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,20 +371,20 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0023"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="examples" class="anchor">Examples </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">os</span>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">os</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">pandas</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">pd</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">matplotlib.pyplot</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">plt</span>
|
||||
@@ -430,8 +422,22 @@ ypredict <span style="color: #666666">=</span> X_test <span style="color: #66666
|
||||
<span style="color: #008000">print</span>(R2(y_test,ypredict))
|
||||
<span style="color: #008000">print</span>(<span style="color: #BA2121">"Test MSE"</span>)
|
||||
<span style="color: #008000">print</span>(MSE(y_test,ypredict))
|
||||
</pre></div>
|
||||
<p>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -461,25 +467,18 @@ ypredict <span style="color: #666666">=</span> X_test <span style="color: #66666
|
||||
<li><a href="._week35-bs024.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,20 +371,20 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0024"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="making-your-own-test-train-splitting" class="anchor">Making your own test-train splitting </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #408080; font-style: italic"># equivalently in numpy</span>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #408080; font-style: italic"># equivalently in numpy</span>
|
||||
<span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">train_test_split_numpy</span>(inputs, labels, train_size, test_size):
|
||||
n_inputs <span style="color: #666666">=</span> <span style="color: #008000">len</span>(inputs)
|
||||
inputs_shuffled <span style="color: #666666">=</span> inputs<span style="color: #666666">.</span>copy()
|
||||
@@ -406,13 +398,26 @@ MathJax.Hub.Config({
|
||||
Y_train, Y_test <span style="color: #666666">=</span> labels_shuffled[:train_end], labels_shuffled[train_end:]
|
||||
|
||||
<span style="color: #008000; font-weight: bold">return</span> X_train, X_test, Y_train, Y_test
|
||||
</pre></div>
|
||||
<p>
|
||||
But since <b>scikit-learn</b> has its own function for doing this and since
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>But since <b>scikit-learn</b> has its own function for doing this and since
|
||||
it interfaces easily with <b>tensorflow</b> and other libraries, we
|
||||
normally recommend using the latter functionality.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -442,25 +447,18 @@ normally recommend using the latter functionality.
|
||||
<li><a href="._week35-bs025.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,27 +371,21 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0025"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="the-boston-housing-data-example" class="anchor">The Boston housing data example </h2>
|
||||
|
||||
<p>
|
||||
The Boston housing
|
||||
<p>The Boston housing
|
||||
data set was originally a part of UCI Machine Learning Repository
|
||||
and has been removed now. The data set is now included in <b>Scikit-Learn</b>'s
|
||||
library. There are 506 samples and 13 feature (predictor) variables
|
||||
in this data set. The objective is to predict the value of prices of
|
||||
the house using the features (predictors) listed here.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The features/predictors are
|
||||
|
||||
<p>The features/predictors are</p>
|
||||
<ol>
|
||||
<li> CRIM: Per capita crime rate by town</li>
|
||||
<li> ZN: Proportion of residential land zoned for lots over 25000 square feet</li>
|
||||
@@ -415,7 +401,6 @@ The features/predictors are
|
||||
<li> LSTAT: Percentage of lower status of the population</li>
|
||||
<li> MEDV: Median value of owner-occupied homes in USD 1000s</li>
|
||||
</ol>
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -445,25 +430,18 @@ The features/predictors are
|
||||
<li><a href="._week35-bs026.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,86 +371,188 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0026"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="housing-data-the-code" class="anchor">Housing data, the code </h2>
|
||||
We start by importing the libraries
|
||||
<p>
|
||||
<p>We start by importing the libraries</p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">matplotlib.pyplot</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">plt</span>
|
||||
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">pandas</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">pd</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">seaborn</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">sns</span>
|
||||
</pre></div>
|
||||
<p>
|
||||
and load the Boston Housing DataSet from <b>Scikit-Learn</b>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>and load the Boston Housing DataSet from <b>Scikit-Learn</b></p>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.datasets</span> <span style="color: #008000; font-weight: bold">import</span> load_boston
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.datasets</span> <span style="color: #008000; font-weight: bold">import</span> load_boston
|
||||
|
||||
boston_dataset <span style="color: #666666">=</span> load_boston()
|
||||
|
||||
<span style="color: #408080; font-style: italic"># boston_dataset is a dictionary</span>
|
||||
<span style="color: #408080; font-style: italic"># let's check what it contains</span>
|
||||
boston_dataset<span style="color: #666666">.</span>keys()
|
||||
</pre></div>
|
||||
<p>
|
||||
Then we invoke Pandas
|
||||
<p>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>Then we invoke Pandas</p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span>boston <span style="color: #666666">=</span> pd<span style="color: #666666">.</span>DataFrame(boston_dataset<span style="color: #666666">.</span>data, columns<span style="color: #666666">=</span>boston_dataset<span style="color: #666666">.</span>feature_names)
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;">boston <span style="color: #666666">=</span> pd<span style="color: #666666">.</span>DataFrame(boston_dataset<span style="color: #666666">.</span>data, columns<span style="color: #666666">=</span>boston_dataset<span style="color: #666666">.</span>feature_names)
|
||||
boston<span style="color: #666666">.</span>head()
|
||||
boston[<span style="color: #BA2121">'MEDV'</span>] <span style="color: #666666">=</span> boston_dataset<span style="color: #666666">.</span>target
|
||||
</pre></div>
|
||||
<p>
|
||||
and preprocess the data
|
||||
<p>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>and preprocess the data</p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #408080; font-style: italic"># check for missing values in all the columns</span>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #408080; font-style: italic"># check for missing values in all the columns</span>
|
||||
boston<span style="color: #666666">.</span>isnull()<span style="color: #666666">.</span>sum()
|
||||
</pre></div>
|
||||
<p>
|
||||
We can then visualize the data
|
||||
<p>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>We can then visualize the data</p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #408080; font-style: italic"># set the size of the figure</span>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #408080; font-style: italic"># set the size of the figure</span>
|
||||
sns<span style="color: #666666">.</span>set(rc<span style="color: #666666">=</span>{<span style="color: #BA2121">'figure.figsize'</span>:(<span style="color: #666666">11.7</span>,<span style="color: #666666">8.27</span>)})
|
||||
|
||||
<span style="color: #408080; font-style: italic"># plot a histogram showing the distribution of the target values</span>
|
||||
sns<span style="color: #666666">.</span>distplot(boston[<span style="color: #BA2121">'MEDV'</span>], bins<span style="color: #666666">=30</span>)
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
<p>
|
||||
It is now useful to look at the correlation matrix
|
||||
<p>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>It is now useful to look at the correlation matrix</p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #408080; font-style: italic"># compute the pair wise correlation for all columns </span>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #408080; font-style: italic"># compute the pair wise correlation for all columns </span>
|
||||
correlation_matrix <span style="color: #666666">=</span> boston<span style="color: #666666">.</span>corr()<span style="color: #666666">.</span>round(<span style="color: #666666">2</span>)
|
||||
<span style="color: #408080; font-style: italic"># use the heatmap function from seaborn to plot the correlation matrix</span>
|
||||
<span style="color: #408080; font-style: italic"># annot = True to print the values inside the square</span>
|
||||
sns<span style="color: #666666">.</span>heatmap(data<span style="color: #666666">=</span>correlation_matrix, annot<span style="color: #666666">=</span><span style="color: #008000; font-weight: bold">True</span>)
|
||||
</pre></div>
|
||||
<p>
|
||||
From the above coorelation plot we can see that <b>MEDV</b> is strongly correlated to <b>LSTAT</b> and <b>RM</b>. We see also that <b>RAD</b> and <b>TAX</b> are stronly correlated, but we don't include this in our features together to avoid multi-colinearity
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>From the above coorelation plot we can see that <b>MEDV</b> is strongly correlated to <b>LSTAT</b> and <b>RM</b>. We see also that <b>RAD</b> and <b>TAX</b> are stronly correlated, but we don't include this in our features together to avoid multi-colinearity</p>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span>plt<span style="color: #666666">.</span>figure(figsize<span style="color: #666666">=</span>(<span style="color: #666666">20</span>, <span style="color: #666666">5</span>))
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;">plt<span style="color: #666666">.</span>figure(figsize<span style="color: #666666">=</span>(<span style="color: #666666">20</span>, <span style="color: #666666">5</span>))
|
||||
|
||||
features <span style="color: #666666">=</span> [<span style="color: #BA2121">'LSTAT'</span>, <span style="color: #BA2121">'RM'</span>]
|
||||
target <span style="color: #666666">=</span> boston[<span style="color: #BA2121">'MEDV'</span>]
|
||||
@@ -471,22 +565,56 @@ target <span style="color: #666666">=</span> boston[<span style="color: #BA2121"
|
||||
plt<span style="color: #666666">.</span>title(col)
|
||||
plt<span style="color: #666666">.</span>xlabel(col)
|
||||
plt<span style="color: #666666">.</span>ylabel(<span style="color: #BA2121">'MEDV'</span>)
|
||||
</pre></div>
|
||||
<p>
|
||||
Now we start training our model
|
||||
<p>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>Now we start training our model</p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span>X <span style="color: #666666">=</span> pd<span style="color: #666666">.</span>DataFrame(np<span style="color: #666666">.</span>c_[boston[<span style="color: #BA2121">'LSTAT'</span>], boston[<span style="color: #BA2121">'RM'</span>]], columns <span style="color: #666666">=</span> [<span style="color: #BA2121">'LSTAT'</span>,<span style="color: #BA2121">'RM'</span>])
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;">X <span style="color: #666666">=</span> pd<span style="color: #666666">.</span>DataFrame(np<span style="color: #666666">.</span>c_[boston[<span style="color: #BA2121">'LSTAT'</span>], boston[<span style="color: #BA2121">'RM'</span>]], columns <span style="color: #666666">=</span> [<span style="color: #BA2121">'LSTAT'</span>,<span style="color: #BA2121">'RM'</span>])
|
||||
Y <span style="color: #666666">=</span> boston[<span style="color: #BA2121">'MEDV'</span>]
|
||||
</pre></div>
|
||||
<p>
|
||||
We split the data into training and test sets
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>We split the data into training and test sets</p>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.model_selection</span> <span style="color: #008000; font-weight: bold">import</span> train_test_split
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.model_selection</span> <span style="color: #008000; font-weight: bold">import</span> train_test_split
|
||||
|
||||
<span style="color: #408080; font-style: italic"># splits the training and test data set in 80% : 20%</span>
|
||||
<span style="color: #408080; font-style: italic"># assign random_state to any value.This ensures consistency.</span>
|
||||
@@ -495,13 +623,30 @@ X_train, X_test, Y_train, Y_test <span style="color: #666666">=</span> train_tes
|
||||
<span style="color: #008000">print</span>(X_test<span style="color: #666666">.</span>shape)
|
||||
<span style="color: #008000">print</span>(Y_train<span style="color: #666666">.</span>shape)
|
||||
<span style="color: #008000">print</span>(Y_test<span style="color: #666666">.</span>shape)
|
||||
</pre></div>
|
||||
<p>
|
||||
Then we use the linear regression functionality from <b>Scikit-Learn</b>
|
||||
<p>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>Then we use the linear regression functionality from <b>Scikit-Learn</b></p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.linear_model</span> <span style="color: #008000; font-weight: bold">import</span> LinearRegression
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.linear_model</span> <span style="color: #008000; font-weight: bold">import</span> LinearRegression
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.metrics</span> <span style="color: #008000; font-weight: bold">import</span> mean_squared_error, r2_score
|
||||
|
||||
lin_model <span style="color: #666666">=</span> LinearRegression()
|
||||
@@ -532,16 +677,45 @@ r2 <span style="color: #666666">=</span> r2_score(Y_test, y_test_predict)
|
||||
<span style="color: #008000">print</span>(<span style="color: #BA2121">"--------------------------------------"</span>)
|
||||
<span style="color: #008000">print</span>(<span style="color: #BA2121">'RMSE is </span><span style="color: #BB6688; font-weight: bold">{}</span><span style="color: #BA2121">'</span><span style="color: #666666">.</span>format(rmse))
|
||||
<span style="color: #008000">print</span>(<span style="color: #BA2121">'R2 score is </span><span style="color: #BB6688; font-weight: bold">{}</span><span style="color: #BA2121">'</span><span style="color: #666666">.</span>format(r2))
|
||||
</pre></div>
|
||||
<p>
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #408080; font-style: italic"># plotting the y_test vs y_pred</span>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #408080; font-style: italic"># plotting the y_test vs y_pred</span>
|
||||
<span style="color: #408080; font-style: italic"># ideally should have been a straight line</span>
|
||||
plt<span style="color: #666666">.</span>scatter(Y_test, y_test_predict)
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
<p>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -571,25 +745,18 @@ plt<span style="color: #666666">.</span>show()
|
||||
<li><a href="._week35-bs027.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,47 +371,40 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0027"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="reducing-the-number-of-degrees-of-freedom-overarching-view" class="anchor">Reducing the number of degrees of freedom, overarching view </h2>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
|
||||
<p>
|
||||
Many Machine Learning problems involve thousands or even millions of
|
||||
<p>Many Machine Learning problems involve thousands or even millions of
|
||||
features for each training instance. Not only does this make training
|
||||
extremely slow, it can also make it much harder to find a good
|
||||
solution, as we will see. This problem is often referred to as the
|
||||
curse of dimensionality. Fortunately, in real-world problems, it is
|
||||
often possible to reduce the number of features considerably, turning
|
||||
an intractable problem into a tractable one.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Later we will discuss some of the most popular dimensionality reduction
|
||||
<p>Later we will discuss some of the most popular dimensionality reduction
|
||||
techniques: the principal component analysis (PCA), Kernel PCA, and
|
||||
Locally Linear Embedding (LLE).
|
||||
Locally Linear Embedding (LLE).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Principal component analysis and its various variants deal with the
|
||||
<p>Principal component analysis and its various variants deal with the
|
||||
problem of fitting a low-dimensional <a href="https://en.wikipedia.org/wiki/Affine_space" target="_self">affine
|
||||
subspace</a> to a set of of
|
||||
data points in a high-dimensional space. With its family of methods it
|
||||
is one of the most used tools in data modeling, compression and
|
||||
visualization.
|
||||
|
||||
<p>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -449,25 +434,18 @@ visualization.
|
||||
<li><a href="._week35-bs028.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,42 +371,35 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0028"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="preprocessing-our-data" class="anchor">Preprocessing our data </h2>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
|
||||
<p>
|
||||
Before we proceed however, we will discuss how to preprocess our
|
||||
<p>Before we proceed however, we will discuss how to preprocess our
|
||||
data. Till now and in connection with our previous examples we have
|
||||
not met so many cases where we are too sensitive to the scaling of our
|
||||
data. Normally the data may need a rescaling and/or may be sensitive
|
||||
to extreme values. Scaling the data renders our inputs much more
|
||||
suitable for the algorithms we want to employ.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For data sets gathered for real world applications, it is rather normal that
|
||||
<p>For data sets gathered for real world applications, it is rather normal that
|
||||
different features have very different units and
|
||||
numerical scales. For example, a data set detailing health habits may include
|
||||
features such as <b>age</b> in the range \( 0-80 \), and <b>caloric intake</b> of order \( 2000 \).
|
||||
Many machine learning methods sensitive to the scales of the features and may perform poorly if they
|
||||
are very different scales. Therefore, it is typical to scale
|
||||
the features in a way to avoid such outlier values.
|
||||
|
||||
<p>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -444,25 +429,18 @@ the features in a way to avoid such outlier values.
|
||||
<li><a href="._week35-bs029.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,18 +371,13 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0029"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="functionality-in-scikit-learn" class="anchor">Functionality in Scikit-Learn </h2>
|
||||
|
||||
<p>
|
||||
<b>Scikit-Learn</b> has several functions which allow us to rescale the
|
||||
<p><b>Scikit-Learn</b> has several functions which allow us to rescale the
|
||||
data, normally resulting in much better results in terms of various
|
||||
accuracy scores. The <b>StandardScaler</b> function in <b>Scikit-Learn</b>
|
||||
ensures that for each feature/predictor we study the mean value is
|
||||
@@ -399,8 +386,8 @@ matrix). This scaling has the drawback that it does not ensure that
|
||||
we have a particular maximum or minimum in our data set. Another
|
||||
function included in <b>Scikit-Learn</b> is the <b>MinMaxScaler</b> which
|
||||
ensures that all features are exactly between \( 0 \) and \( 1 \). The
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -430,25 +417,18 @@ ensures that all features are exactly between \( 0 \) and \( 1 \). The
|
||||
<li><a href="._week35-bs030.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,30 +371,25 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0030"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="more-preprocessing" class="anchor">More preprocessing </h2>
|
||||
|
||||
<p>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
The <b>Normalizer</b> scales each data
|
||||
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
<p>The <b>Normalizer</b> scales each data
|
||||
point such that the feature vector has a euclidean length of one. In other words, it
|
||||
projects a data point on the circle (or sphere in the case of higher dimensions) with a
|
||||
radius of 1. This means every data point is scaled by a different number (by the
|
||||
inverse of it’s length).
|
||||
This normalization is often used when only the direction (or angle) of the data matters,
|
||||
not the length of the feature vector.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The <b>RobustScaler</b> works similarly to the StandardScaler in that it
|
||||
<p>The <b>RobustScaler</b> works similarly to the StandardScaler in that it
|
||||
ensures statistical properties for each feature that guarantee that
|
||||
they are on the same scale. However, the RobustScaler uses the median
|
||||
and quartiles, instead of mean and variance. This makes the
|
||||
@@ -410,13 +397,11 @@ RobustScaler ignore data points that are very different from the rest
|
||||
(like measurement errors). These odd data points are also called
|
||||
outliers, and might often lead to trouble for other scaling
|
||||
techniques.
|
||||
|
||||
<p>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -446,25 +431,18 @@ techniques.
|
||||
<li><a href="._week35-bs031.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,28 +371,24 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0031"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="frequently-used-scaling-functions" class="anchor">Frequently used scaling functions </h2>
|
||||
|
||||
<p>
|
||||
Many features are often scaled using standardization to improve performance. In <b>Scikit-Learn</b> this is given by the <b>StandardScaler</b> function as discussed above. It is easy however to write your own.
|
||||
<p>Many features are often scaled using standardization to improve performance. In <b>Scikit-Learn</b> this is given by the <b>StandardScaler</b> function as discussed above. It is easy however to write your own.
|
||||
Mathematically, this involves subtracting the mean and divide by the standard deviation over the data set, for each feature:
|
||||
</p>
|
||||
|
||||
$$
|
||||
x_j^{(i)} \rightarrow \frac{x_j^{(i)} - \overline{x}_j}{\sigma(x_j)},
|
||||
$$
|
||||
|
||||
where \( \overline{x}_j \) and \( \sigma(x_j) \) are the mean and standard deviation, respectively, of the feature \( x_j \).
|
||||
<p>where \( \overline{x}_j \) and \( \sigma(x_j) \) are the mean and standard deviation, respectively, of the feature \( x_j \).
|
||||
This ensures that each feature has zero mean and unit standard deviation. For data sets where we do not have the standard deviation or don't wish to calculate it, it is then common to simply set it to one.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -430,25 +418,18 @@ This ensures that each feature has zero mean and unit standard deviation. For d
|
||||
<li><a href="._week35-bs032.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,26 +371,26 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0032"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="example-of-own-standard-scaling" class="anchor">Example of own Standard scaling </h2>
|
||||
|
||||
<p>
|
||||
Let us consider the following vanilla example where we use both
|
||||
<p>Let us consider the following vanilla example where we use both
|
||||
<b>Scikit-Learn</b> and write our own function as well. We produce a
|
||||
simple test design matrix with random numbers. Each column could then
|
||||
represent a specific feature whose mean value is subracted.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">sklearn.linear_model</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">skl</span>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">sklearn.linear_model</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">skl</span>
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.metrics</span> <span style="color: #008000; font-weight: bold">import</span> mean_squared_error
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.model_selection</span> <span style="color: #008000; font-weight: bold">import</span> train_test_split
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.preprocessing</span> <span style="color: #008000; font-weight: bold">import</span> MinMaxScaler, StandardScaler, Normalizer
|
||||
@@ -421,11 +413,23 @@ scaler <span style="color: #666666">=</span> StandardScaler(with_std<span style=
|
||||
scaler<span style="color: #666666">.</span>fit(X)
|
||||
Xscaled <span style="color: #666666">=</span> scaler<span style="color: #666666">.</span>transform(X)
|
||||
display(XPandas<span style="color: #666666">-</span>Xscaled)
|
||||
</pre></div>
|
||||
<p>
|
||||
Small exercise: perform the standard scaling by including the standard deviation and compare with what Scikit-Learn gives.
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>Small exercise: perform the standard scaling by including the standard deviation and compare with what Scikit-Learn gives.</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -455,25 +459,18 @@ Small exercise: perform the standard scaling by including the standard deviation
|
||||
<li><a href="._week35-bs033.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,29 +371,24 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0033"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="min-max-scaling" class="anchor">Min-Max Scaling </h2>
|
||||
|
||||
<p>
|
||||
Another commonly used scaling method is min-max scaling. This is very
|
||||
<p>Another commonly used scaling method is min-max scaling. This is very
|
||||
useful for when we want the features to lie in a certain interval. To
|
||||
scale the feature \( x_j \) to the interval \( [a, b] \), we can apply the
|
||||
transformation
|
||||
</p>
|
||||
|
||||
$$
|
||||
x_j^{(i)} \rightarrow (b-a)\frac{x_j^{(i)} - \min(x_j)}{\max(x_j) - \min(x_j)} - a
|
||||
$$
|
||||
|
||||
where \( \min(x_j) \) and \( \max(x_j) \) return the minimum and maximum value of \( x_j \) over the data set, respectively.
|
||||
<p>where \( \min(x_j) \) and \( \max(x_j) \) return the minimum and maximum value of \( x_j \) over the data set, respectively.</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -431,25 +418,18 @@ where \( \min(x_j) \) and \( \max(x_j) \) return the minimum and maximum value o
|
||||
<li><a href="._week35-bs034.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,40 +371,56 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0034"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="testing-the-means-squared-error-as-function-of-complexity" class="anchor">Testing the Means Squared Error as function of Complexity </h2>
|
||||
One of
|
||||
<p>One of
|
||||
the aims is to reproduce Figure 2.11 of <a href="https://github.com/CompPhysics/MLErasmus/blob/master/doc/Textbooks/elementsstat.pdf" target="_self">Hastie et al</a>.
|
||||
We will also use Ridge and Lasso regression.
|
||||
We will also use Ridge and Lasso regression.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Our data is defined by \( x\in [-3,3] \) with a total of for example \( 100 \) data points.
|
||||
<p>
|
||||
<p>Our data is defined by \( x\in [-3,3] \) with a total of for example \( 100 \) data points.</p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span>np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>seed()
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;">np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>seed()
|
||||
n <span style="color: #666666">=</span> <span style="color: #666666">100</span>
|
||||
maxdegree <span style="color: #666666">=</span> <span style="color: #666666">14</span>
|
||||
<span style="color: #408080; font-style: italic"># Make data set.</span>
|
||||
x <span style="color: #666666">=</span> np<span style="color: #666666">.</span>linspace(<span style="color: #666666">-3</span>, <span style="color: #666666">3</span>, n)<span style="color: #666666">.</span>reshape(<span style="color: #666666">-1</span>, <span style="color: #666666">1</span>)
|
||||
y <span style="color: #666666">=</span> np<span style="color: #666666">.</span>exp(<span style="color: #666666">-</span>x<span style="color: #666666">**2</span>) <span style="color: #666666">+</span> <span style="color: #666666">1.5</span> <span style="color: #666666">*</span> np<span style="color: #666666">.</span>exp(<span style="color: #666666">-</span>(x<span style="color: #666666">-2</span>)<span style="color: #666666">**2</span>)<span style="color: #666666">+</span> np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>normal(<span style="color: #666666">0</span>, <span style="color: #666666">0.1</span>, x<span style="color: #666666">.</span>shape)
|
||||
</pre></div>
|
||||
<p>
|
||||
where \( y \) is the function we want to fit with a given polynomial.
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Write a first code which sets up a design matrix \( X \) defined by a fifth-order polynomial. Scale your data and split it in training and test data.
|
||||
<p>
|
||||
<p>where \( y \) is the function we want to fit with a given polynomial.</p>
|
||||
|
||||
<p>Write a first code which sets up a design matrix \( X \) defined by a fifth-order polynomial. Scale your data and split it in training and test data. </p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">matplotlib.pyplot</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">plt</span>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">matplotlib.pyplot</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">plt</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.linear_model</span> <span style="color: #008000; font-weight: bold">import</span> LinearRegression, Ridge, Lasso
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">sklearn.preprocessing</span> <span style="color: #008000; font-weight: bold">import</span> PolynomialFeatures
|
||||
@@ -448,8 +456,22 @@ plt<span style="color: #666666">.</span>plot(polydegree, TestError, label<span s
|
||||
plt<span style="color: #666666">.</span>plot(polydegree, TrainError, label<span style="color: #666666">=</span><span style="color: #BA2121">'Train Error'</span>)
|
||||
plt<span style="color: #666666">.</span>legend()
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
<p>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -479,25 +501,18 @@ plt<span style="color: #666666">.</span>show()
|
||||
<li><a href="._week35-bs035.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,20 +371,20 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0035"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="more-preprocessing-examples-franke-function-and-regression" class="anchor">More preprocessing examples, Franke function and regression </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #408080; font-style: italic"># Common imports</span>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #408080; font-style: italic"># Common imports</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">os</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">pandas</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">pd</span>
|
||||
@@ -484,8 +476,22 @@ clf <span style="color: #666666">=</span> skl<span style="color: #666666">.</spa
|
||||
|
||||
<span style="color: #008000">print</span>(<span style="color: #BA2121">"MSE after scaling: </span><span style="color: #BB6688; font-weight: bold">{:.2f}</span><span style="color: #BA2121">"</span><span style="color: #666666">.</span>format(mean_squared_error(clf<span style="color: #666666">.</span>predict(X_test_scaled), y_test)))
|
||||
<span style="color: #008000">print</span>(<span style="color: #BA2121">"R2 score for scaled data: </span><span style="color: #BB6688; font-weight: bold">{:.2f}</span><span style="color: #BA2121">"</span><span style="color: #666666">.</span>format(clf<span style="color: #666666">.</span>score(X_test_scaled,y_test)))
|
||||
</pre></div>
|
||||
<p>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -515,25 +521,18 @@ clf <span style="color: #666666">=</span> skl<span style="color: #666666">.</spa
|
||||
<li><a href="._week35-bs036.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,53 +371,42 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0036"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="mathematical-interpretation-of-ordinary-least-squares" class="anchor">Mathematical Interpretation of Ordinary Least Squares </h2>
|
||||
|
||||
<p>
|
||||
What is presented here is a mathematical analysis of various regression algorithms (ordinary least squares, Ridge and Lasso Regression). The analysis is based on an important algorithm in linear algebra, the so-called Singular Value Decomposition (SVD).
|
||||
<p>What is presented here is a mathematical analysis of various regression algorithms (ordinary least squares, Ridge and Lasso Regression). The analysis is based on an important algorithm in linear algebra, the so-called Singular Value Decomposition (SVD). </p>
|
||||
|
||||
<p>
|
||||
We have shown that in ordinary least squares the optimal parameters \( \beta \) are given by
|
||||
<p>We have shown that in ordinary least squares the optimal parameters \( \beta \) are given by</p>
|
||||
|
||||
$$
|
||||
\hat{\boldsymbol{\beta}} = \left(\boldsymbol{X}^T\boldsymbol{X}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
The <b>hat</b> over \( \boldsymbol{\beta} \) means we have the optimal parameters after minimization of the cost function.
|
||||
<p>The <b>hat</b> over \( \boldsymbol{\beta} \) means we have the optimal parameters after minimization of the cost function.</p>
|
||||
|
||||
<p>
|
||||
This means that our best model is defined as
|
||||
<p>This means that our best model is defined as</p>
|
||||
|
||||
$$
|
||||
\tilde{\boldsymbol{y}}=\boldsymbol{X}\hat{\boldsymbol{\beta}} = \boldsymbol{X}\left(\boldsymbol{X}^T\boldsymbol{X}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
We now define a matrix
|
||||
<p>We now define a matrix</p>
|
||||
$$
|
||||
\boldsymbol{A}=\boldsymbol{X}\left(\boldsymbol{X}^T\boldsymbol{X}\right)^{-1}\boldsymbol{X}^T.
|
||||
$$
|
||||
|
||||
<p>
|
||||
We can rewrite
|
||||
<p>We can rewrite</p>
|
||||
$$
|
||||
\tilde{\boldsymbol{y}}=\boldsymbol{X}\hat{\boldsymbol{\beta}} = \boldsymbol{A}\boldsymbol{y}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
The matrix \( \boldsymbol{A} \) has the important property that \( \boldsymbol{A}^2=\boldsymbol{A} \). This is the definition of a projection matrix.
|
||||
<p>The matrix \( \boldsymbol{A} \) has the important property that \( \boldsymbol{A}^2=\boldsymbol{A} \). This is the definition of a projection matrix.
|
||||
We can then interpret our optimal model \( \tilde{\boldsymbol{y}} \) as being represented by an orthogonal projection of \( \boldsymbol{y} \) onto a space defined by the column vectors of \( \boldsymbol{X} \). In our case here the matrix \( \boldsymbol{A} \) is a square matrix. If it is a general rectangular matrix we have an oblique projection matrix.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -455,25 +436,18 @@ We can then interpret our optimal model \( \tilde{\boldsymbol{y}} \) as being re
|
||||
<li><a href="._week35-bs037.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,26 +371,19 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0037"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="residual-error" class="anchor">Residual Error </h2>
|
||||
|
||||
<p>
|
||||
We have defined the residual error as
|
||||
<p>We have defined the residual error as</p>
|
||||
$$
|
||||
\boldsymbol{\epsilon}=\boldsymbol{y}-\tilde{\boldsymbol{y}}=\left[\boldsymbol{I}-\boldsymbol{X}\left(\boldsymbol{X}^T\boldsymbol{X}\right)^{-1}\boldsymbol{X}^T\right]\boldsymbol{y}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
The residual errors are then the projections of \( \boldsymbol{y} \) onto the orthogonal component of the space defined by the column vectors of \( \boldsymbol{X} \).
|
||||
<p>The residual errors are then the projections of \( \boldsymbol{y} \) onto the orthogonal component of the space defined by the column vectors of \( \boldsymbol{X} \).</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -428,25 +413,18 @@ The residual errors are then the projections of \( \boldsymbol{y} \) onto the or
|
||||
<li><a href="._week35-bs038.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,38 +371,30 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0038"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="simple-case" class="anchor">Simple case </h2>
|
||||
|
||||
<p>
|
||||
If the matrix \( \boldsymbol{X} \) is an orthogonal (or unitary in case of complex values) matrix, we have
|
||||
<p>If the matrix \( \boldsymbol{X} \) is an orthogonal (or unitary in case of complex values) matrix, we have</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{X}^T\boldsymbol{X}=\boldsymbol{X}\boldsymbol{X}^T = \boldsymbol{I}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
In this case the matrix \( \boldsymbol{A} \) becomes
|
||||
<p>In this case the matrix \( \boldsymbol{A} \) becomes</p>
|
||||
$$
|
||||
\boldsymbol{A}=\boldsymbol{X}\left(\boldsymbol{X}^T\boldsymbol{X}\right)^{-1}\boldsymbol{X}^T)=\boldsymbol{I},
|
||||
$$
|
||||
|
||||
and we have the obvious case
|
||||
<p>and we have the obvious case</p>
|
||||
$$
|
||||
\boldsymbol{\epsilon}=\boldsymbol{y}-\tilde{\boldsymbol{y}}=0.
|
||||
$$
|
||||
|
||||
<p>
|
||||
This serves also as a useful test of our codes.
|
||||
<p>This serves also as a useful test of our codes. </p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -440,25 +424,18 @@ This serves also as a useful test of our codes.
|
||||
<li><a href="._week35-bs039.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,62 +371,54 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0039"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="the-singular-value-decomposition" class="anchor">The singular value decomposition </h2>
|
||||
|
||||
<p>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
<!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
|
||||
<p>
|
||||
The examples we have looked at so far are cases where we normally can
|
||||
<p>The examples we have looked at so far are cases where we normally can
|
||||
invert the matrix \( \boldsymbol{X}^T\boldsymbol{X} \). Using a polynomial expansion where we fit of various functions leads to
|
||||
row vectors of the design matrix which are essentially orthogonal due
|
||||
to the polynomial character of our model. Obtaining the inverse of the
|
||||
design matrix is then often done via a so-called LU, QR or Cholesky
|
||||
decomposition.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
As we will also see in the first project,
|
||||
<p>As we will also see in the first project,
|
||||
this may
|
||||
however not the be case in general and a standard matrix inversion
|
||||
algorithm based on say LU, QR or Cholesky decomposition may lead to singularities. We will see examples of this below.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
There is however a way to circumvent this problem and also
|
||||
<p>There is however a way to circumvent this problem and also
|
||||
gain some insights about the ordinary least squares approach, and
|
||||
later shrinkage methods like Ridge and Lasso regressions.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
This is given by the <b>Singular Value Decomposition</b> (SVD) algorithm,
|
||||
<p>This is given by the <b>Singular Value Decomposition</b> (SVD) algorithm,
|
||||
perhaps the most powerful linear algebra algorithm. The SVD provides
|
||||
a numerically stable matrix decomposition that is used in a large
|
||||
swath oc applications and the decomposition is always stable
|
||||
numerically.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
In machine learning it plays a central role in dealing with for
|
||||
<p>In machine learning it plays a central role in dealing with for
|
||||
example design matrices that may be near singular or singular.
|
||||
Furthermore, as we will see here, the singular values can be related
|
||||
to the covariance matrix (and thereby the correlation matrix) and in
|
||||
turn the variance of a given quantity. It plays also an important role
|
||||
in the principal component analysis where high-dimensional data can be
|
||||
reduced to the statistically relevant features.
|
||||
|
||||
<p>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -464,25 +448,18 @@ reduced to the statistically relevant features.
|
||||
<li><a href="._week35-bs040.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,23 +371,19 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0040"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="linear-regression-problems" class="anchor">Linear Regression Problems </h2>
|
||||
|
||||
<p>
|
||||
One of the typical problems we encounter with linear regression, in particular
|
||||
<p>One of the typical problems we encounter with linear regression, in particular
|
||||
when the matrix \( \boldsymbol{X} \) (our so-called design matrix) is high-dimensional,
|
||||
are problems with near singular or singular matrices. The column vectors of \( \boldsymbol{X} \)
|
||||
may be linearly dependent, normally referred to as super-collinearity.
|
||||
This means that the matrix may be rank deficient and it is basically impossible to
|
||||
to model the data using linear regression. As an example, consider the matrix
|
||||
</p>
|
||||
$$
|
||||
\begin{align*}
|
||||
\mathbf{X} & = \left[
|
||||
@@ -411,16 +399,16 @@ $$
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
<p>
|
||||
The columns of \( \boldsymbol{X} \) are linearly dependent. We see this easily since the
|
||||
<p>The columns of \( \boldsymbol{X} \) are linearly dependent. We see this easily since the
|
||||
the first column is the row-wise sum of the other two columns. The rank (more correct,
|
||||
the column rank) of a matrix is the dimension of the space spanned by the
|
||||
column vectors. Hence, the rank of \( \mathbf{X} \) is equal to the number
|
||||
of linearly independent columns. In this particular case the matrix has rank 2.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Super-collinearity of an \( (n \times p) \)-dimensional design matrix \( \mathbf{X} \) implies
|
||||
<p>Super-collinearity of an \( (n \times p) \)-dimensional design matrix \( \mathbf{X} \) implies
|
||||
that the inverse of the matrix \( \boldsymbol{X}^T\boldsymbol{X} \) (the matrix we need to invert to solve the linear regression equations) is non-invertible. If we have a square matrix that does not have an inverse, we say this matrix singular. The example here demonstrates this
|
||||
</p>
|
||||
$$
|
||||
\begin{align*}
|
||||
\boldsymbol{X} & = \left[
|
||||
@@ -432,10 +420,10 @@ $$
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
We see easily that \( \mbox{det}(\boldsymbol{X}) = x_{11} x_{22} - x_{12} x_{21} = 1 \times (-1) - 1 \times (-1) = 0 \). Hence, \( \mathbf{X} \) is singular and its inverse is undefined.
|
||||
<p>We see easily that \( \mbox{det}(\boldsymbol{X}) = x_{11} x_{22} - x_{12} x_{21} = 1 \times (-1) - 1 \times (-1) = 0 \). Hence, \( \mathbf{X} \) is singular and its inverse is undefined.
|
||||
This is equivalent to saying that the matrix \( \boldsymbol{X} \) has at least an eigenvalue which is zero.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -465,25 +453,18 @@ This is equivalent to saying that the matrix \( \boldsymbol{X} \) has at least a
|
||||
<li><a href="._week35-bs041.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,18 +371,13 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0041"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="fixing-the-singularity" class="anchor">Fixing the singularity </h2>
|
||||
|
||||
<p>
|
||||
If our design matrix \( \boldsymbol{X} \) which enters the linear regression problem
|
||||
<p>If our design matrix \( \boldsymbol{X} \) which enters the linear regression problem</p>
|
||||
$$
|
||||
\begin{align}
|
||||
\boldsymbol{\beta} & = (\boldsymbol{X}^{T} \boldsymbol{X})^{-1} \boldsymbol{X}^{T} \boldsymbol{y},
|
||||
@@ -398,21 +385,20 @@ $$
|
||||
\end{align}
|
||||
$$
|
||||
|
||||
has linearly dependent column vectors, we will not be able to compute the inverse
|
||||
<p>has linearly dependent column vectors, we will not be able to compute the inverse
|
||||
of \( \boldsymbol{X}^T\boldsymbol{X} \) and we cannot find the parameters (estimators) \( \beta_i \).
|
||||
The estimators are only well-defined if \( (\boldsymbol{X}^{T}\boldsymbol{X})^{-1} \) exits.
|
||||
This is more likely to happen when the matrix \( \boldsymbol{X} \) is high-dimensional. In this case it is likely to encounter a situation where
|
||||
the regression parameters \( \beta_i \) cannot be estimated.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
A cheap <em>ad hoc</em> approach is simply to add a small diagonal component to the matrix to invert, that is we change
|
||||
<p>A cheap <em>ad hoc</em> approach is simply to add a small diagonal component to the matrix to invert, that is we change</p>
|
||||
$$
|
||||
\boldsymbol{X}^{T} \boldsymbol{X} \rightarrow \boldsymbol{X}^{T} \boldsymbol{X}+\lambda \boldsymbol{I},
|
||||
$$
|
||||
|
||||
where \( \boldsymbol{I} \) is the identity matrix. When we discuss <b>Ridge</b> regression this is actually what we end up evaluating. The parameter \( \lambda \) is called a hyperparameter. More about this later.
|
||||
<p>where \( \boldsymbol{I} \) is the identity matrix. When we discuss <b>Ridge</b> regression this is actually what we end up evaluating. The parameter \( \lambda \) is called a hyperparameter. More about this later. </p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -442,25 +428,18 @@ where \( \boldsymbol{I} \) is the identity matrix. When we discuss <b>Ridge</b>
|
||||
<li><a href="._week35-bs042.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,40 +371,35 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0042"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="basic-math-of-the-svd" class="anchor">Basic math of the SVD </h2>
|
||||
|
||||
<p>
|
||||
From standard linear algebra we know that a square matrix \( \boldsymbol{X} \) can be diagonalized if and only it is
|
||||
<p>From standard linear algebra we know that a square matrix \( \boldsymbol{X} \) can be diagonalized if and only it is
|
||||
a so-called <a href="https://en.wikipedia.org/wiki/Normal_matrix" target="_self">normal matrix</a>, that is if \( \boldsymbol{X}\in {\mathbb{R}}^{n\times n} \)
|
||||
we have \( \boldsymbol{X}\boldsymbol{X}^T=\boldsymbol{X}^T\boldsymbol{X} \) or if \( \boldsymbol{X}\in {\mathbb{C}}^{n\times n} \) we have \( \boldsymbol{X}\boldsymbol{X}^{\dagger}=\boldsymbol{X}^{\dagger}\boldsymbol{X} \).
|
||||
The matrix has then a set of eigenpairs
|
||||
</p>
|
||||
|
||||
$$
|
||||
(\lambda_1,\boldsymbol{u}_1),\dots, (\lambda_n,\boldsymbol{u}_n),
|
||||
$$
|
||||
|
||||
and the eigenvalues are given by the diagonal matrix
|
||||
<p>and the eigenvalues are given by the diagonal matrix</p>
|
||||
$$
|
||||
\boldsymbol{\Sigma}=\mathrm{Diag}(\lambda_1, \dots,\lambda_n).
|
||||
$$
|
||||
|
||||
The matrix \( \boldsymbol{X} \) can be written in terms of an orthogonal/unitary transformation \( \boldsymbol{U} \)
|
||||
<p>The matrix \( \boldsymbol{X} \) can be written in terms of an orthogonal/unitary transformation \( \boldsymbol{U} \)</p>
|
||||
$$
|
||||
\boldsymbol{X} = \boldsymbol{U}\boldsymbol{\Sigma}\boldsymbol{V}^T,
|
||||
$$
|
||||
|
||||
with \( \boldsymbol{U}\boldsymbol{U}^T=\boldsymbol{I} \) or \( \boldsymbol{U}\boldsymbol{U}^{\dagger}=\boldsymbol{I} \).
|
||||
<p>with \( \boldsymbol{U}\boldsymbol{U}^T=\boldsymbol{I} \) or \( \boldsymbol{U}\boldsymbol{U}^{\dagger}=\boldsymbol{I} \).</p>
|
||||
|
||||
<p>
|
||||
Not all square matrices are diagonalizable. A matrix like the one discussed above
|
||||
<p>Not all square matrices are diagonalizable. A matrix like the one discussed above</p>
|
||||
$$
|
||||
\boldsymbol{X} = \begin{bmatrix}
|
||||
1& -1 \\
|
||||
@@ -420,10 +407,10 @@ $$
|
||||
\end{bmatrix}
|
||||
$$
|
||||
|
||||
is not diagonalizable, it is a so-called <a href="https://en.wikipedia.org/wiki/Defective_matrix" target="_self">defective matrix</a>. It is easy to see that the condition
|
||||
\( \boldsymbol{X}\boldsymbol{X}^T=\boldsymbol{X}^T\boldsymbol{X} \) is not fulfilled.
|
||||
<p>is not diagonalizable, it is a so-called <a href="https://en.wikipedia.org/wiki/Defective_matrix" target="_self">defective matrix</a>. It is easy to see that the condition
|
||||
\( \boldsymbol{X}\boldsymbol{X}^T=\boldsymbol{X}^T\boldsymbol{X} \) is not fulfilled.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -453,25 +440,18 @@ is not diagonalizable, it is a so-called <a href="https://en.wikipedia.org/wiki/
|
||||
<li><a href="._week35-bs043.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,18 +371,13 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0043"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="the-svd-a-fantastic-algorithm" class="anchor">The SVD, a Fantastic Algorithm </h2>
|
||||
|
||||
<p>
|
||||
However, and this is the strength of the SVD algorithm, any general
|
||||
<p>However, and this is the strength of the SVD algorithm, any general
|
||||
matrix \( \boldsymbol{X} \) can be decomposed in terms of a diagonal matrix and
|
||||
two orthogonal/unitary matrices. The <a href="https://en.wikipedia.org/wiki/Singular_value_decomposition" target="_self">Singular Value Decompostion
|
||||
(SVD) theorem</a>
|
||||
@@ -399,30 +386,29 @@ terms of a diagonal matrix \( \boldsymbol{\Sigma} \) of dimensionality \( m\time
|
||||
and two orthognal matrices \( \boldsymbol{U} \) and \( \boldsymbol{V} \), where the first has
|
||||
dimensionality \( m \times m \) and the last dimensionality \( n\times n \).
|
||||
We have then
|
||||
</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{X} = \boldsymbol{U}\boldsymbol{\Sigma}\boldsymbol{V}^T
|
||||
$$
|
||||
|
||||
<p>
|
||||
As an example, the above defective matrix can be decomposed as
|
||||
<p>As an example, the above defective matrix can be decomposed as</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{X} = \frac{1}{\sqrt{2}}\begin{bmatrix} 1& 1 \\ 1& -1\\ \end{bmatrix} \begin{bmatrix} 2& 0 \\ 0& 0\\ \end{bmatrix} \frac{1}{\sqrt{2}}\begin{bmatrix} 1& -1 \\ 1& 1\\ \end{bmatrix}=\boldsymbol{U}\boldsymbol{\Sigma}\boldsymbol{V}^T,
|
||||
$$
|
||||
|
||||
<p>
|
||||
with eigenvalues \( \sigma_1=2 \) and \( \sigma_2=0 \).
|
||||
The SVD exits always!
|
||||
<p>with eigenvalues \( \sigma_1=2 \) and \( \sigma_2=0 \).
|
||||
The SVD exits always!
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The SVD
|
||||
<p>The SVD
|
||||
decomposition (singular values) gives eigenvalues
|
||||
\( \sigma_i\geq\sigma_{i+1} \) for all \( i \) and for dimensions larger than \( i=p \), the
|
||||
eigenvalues (singular values) are zero.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
In the general case, where our design matrix \( \boldsymbol{X} \) has dimension
|
||||
<p>In the general case, where our design matrix \( \boldsymbol{X} \) has dimension
|
||||
\( n\times p \), the matrix is thus decomposed into an \( n\times n \)
|
||||
orthogonal matrix \( \boldsymbol{U} \), a \( p\times p \) orthogonal matrix \( \boldsymbol{V} \)
|
||||
and a diagonal matrix \( \boldsymbol{\Sigma} \) with \( r=\mathrm{min}(n,p) \)
|
||||
@@ -432,11 +418,10 @@ assuming that \( n > p \). In our regression examples for the nuclear
|
||||
masses and the equation of state this is indeed the case, while for
|
||||
the Ising model we have \( p > n \). These are often cases that lead to
|
||||
near singular or singular matrices.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The columns of \( \boldsymbol{U} \) are called the left singular vectors while the columns of \( \boldsymbol{V} \) are the right singular vectors.
|
||||
<p>The columns of \( \boldsymbol{U} \) are called the left singular vectors while the columns of \( \boldsymbol{V} \) are the right singular vectors.</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -466,25 +451,18 @@ The columns of \( \boldsymbol{U} \) are called the left singular vectors while t
|
||||
<li><a href="._week35-bs044.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,37 +371,32 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0044"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="economy-size-svd" class="anchor">Economy-size SVD </h2>
|
||||
|
||||
<p>
|
||||
If we assume that \( n > p \), then our matrix \( \boldsymbol{U} \) has dimension \( n
|
||||
<p>If we assume that \( n > p \), then our matrix \( \boldsymbol{U} \) has dimension \( n
|
||||
\times n \). The last \( n-p \) columns of \( \boldsymbol{U} \) become however
|
||||
irrelevant in our calculations since they are multiplied with the
|
||||
zeros in \( \boldsymbol{\Sigma} \).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The economy-size decomposition removes extra rows or columns of zeros
|
||||
<p>The economy-size decomposition removes extra rows or columns of zeros
|
||||
from the diagonal matrix of singular values, \( \boldsymbol{\Sigma} \), along with the columns
|
||||
in either \( \boldsymbol{U} \) or \( \boldsymbol{V} \) that multiply those zeros in the expression.
|
||||
Removing these zeros and columns can improve execution time
|
||||
and reduce storage requirements without compromising the accuracy of
|
||||
the decomposition.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If \( n > p \), we keep only the first \( p \) columns of \( \boldsymbol{U} \) and \( \boldsymbol{\Sigma} \) has dimension \( p\times p \).
|
||||
<p>If \( n > p \), we keep only the first \( p \) columns of \( \boldsymbol{U} \) and \( \boldsymbol{\Sigma} \) has dimension \( p\times p \).
|
||||
If \( p > n \), then only the first \( n \) columns of \( \boldsymbol{V} \) are computed and \( \boldsymbol{\Sigma} \) has dimension \( n\times n \).
|
||||
The \( n=p \) case is obvious, we retain the full SVD.
|
||||
In general the economy-size SVD leads to less FLOPS and still conserving the desired accuracy.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -439,25 +426,18 @@ In general the economy-size SVD leads to less FLOPS and still conserving the des
|
||||
<li><a href="._week35-bs045.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,20 +371,20 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0045"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="codes-for-the-svd" class="anchor">Codes for the SVD </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<span style="color: #408080; font-style: italic"># SVD inversion</span>
|
||||
<span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">SVD</span>(A):
|
||||
<span style="color: #BA2121; font-style: italic">''' Takes as input a numpy matrix A and returns inv(A) based on singular value decomposition (SVD).</span>
|
||||
@@ -421,9 +413,22 @@ X <span style="color: #666666">=</span> np<span style="color: #666666">.</span>a
|
||||
C <span style="color: #666666">=</span> SVD(X)
|
||||
<span style="color: #408080; font-style: italic"># Print the difference between the original matrix and the SVD one</span>
|
||||
<span style="color: #008000">print</span>(C<span style="color: #666666">-</span>X)
|
||||
</pre></div>
|
||||
<p>
|
||||
The matrix \( \boldsymbol{X} \) has columns that are linearly dependent. The first
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>The matrix \( \boldsymbol{X} \) has columns that are linearly dependent. The first
|
||||
column is the row-wise sum of the other two columns. The rank of a
|
||||
matrix (the column rank) is the dimension of space spanned by the
|
||||
column vectors. The rank of the matrix is the number of linearly
|
||||
@@ -431,8 +436,8 @@ independent columns, in this case just \( 2 \). We see this from the
|
||||
singular values when running the above code. Running the standard
|
||||
inversion algorithm for matrix inversion with \( \boldsymbol{X}^T\boldsymbol{X} \) results
|
||||
in the program terminating due to a singular matrix.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -462,25 +467,18 @@ in the program terminating due to a singular matrix.
|
||||
<li><a href="._week35-bs046.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,33 +371,28 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0046"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="note-about-svd-calculations" class="anchor">Note about SVD Calculations </h2>
|
||||
|
||||
<p>
|
||||
The \( U \), \( S \), and \( V \) matrices returned from the <b>svd()</b> function
|
||||
<p>The \( U \), \( S \), and \( V \) matrices returned from the <b>svd()</b> function
|
||||
cannot be multiplied directly.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
As you can see from the code, the \( S \) vector must be converted into a
|
||||
<p>As you can see from the code, the \( S \) vector must be converted into a
|
||||
diagonal matrix. This may cause a problem as the size of the matrices
|
||||
do not fit the rules of matrix multiplication, where the number of
|
||||
columns in a matrix must match the number of rows in the subsequent
|
||||
matrix.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If you wish to include the zero singular values, you will need to
|
||||
<p>If you wish to include the zero singular values, you will need to
|
||||
resize the matrices and set up a diagonal matrix as done in the above
|
||||
example
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -435,25 +422,18 @@ example
|
||||
<li><a href="._week35-bs047.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,23 +371,16 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0047"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="friday-september-3" class="anchor">Friday September 3 </h2>
|
||||
|
||||
<p>
|
||||
<a href="https://www.uio.no/studier/emner/matnat/fys/FYS-STK4155/h20/forelesningsvideoer/LectureSeptember11.mp4?vrtx=view-as-webpage" target="_self">Video of Lecture from 2020</a> and <a href="https://github.com/CompPhysics/MachineLearning/blob/master/doc/HandWrittenNotes/NotesSeptember11.pdf" target="_self">handwritten notes</a>
|
||||
<p><a href="https://www.uio.no/studier/emner/matnat/fys/FYS-STK4155/h20/forelesningsvideoer/LectureSeptember11.mp4?vrtx=view-as-webpage" target="_self">Video of Lecture from 2020</a> and <a href="https://github.com/CompPhysics/MachineLearning/blob/master/doc/HandWrittenNotes/NotesSeptember11.pdf" target="_self">handwritten notes</a></p>
|
||||
|
||||
<p>
|
||||
More material will be added here, see handwritten notes also. Note that this material will be cleaned up after the lecture of Friday September 3. See the handwritten notes from Friday's lecture at <a href="https://github.com/CompPhysics/MachineLearning/tree/master/doc/HandWrittenNotes/2021" target="_self"><tt>https://github.com/CompPhysics/MachineLearning/tree/master/doc/HandWrittenNotes/2021</tt></a>.
|
||||
<p>More material will be added here, see handwritten notes also. Note that this material will be cleaned up after the lecture of Friday September 3. See the handwritten notes from Friday's lecture at <a href="https://github.com/CompPhysics/MachineLearning/tree/master/doc/HandWrittenNotes/2021" target="_self"><tt>https://github.com/CompPhysics/MachineLearning/tree/master/doc/HandWrittenNotes/2021</tt></a>.</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -425,25 +410,18 @@ More material will be added here, see handwritten notes also. Note that this m
|
||||
<li><a href="._week35-bs048.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,21 +371,15 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0048"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="mathematics-of-the-svd-and-implications" class="anchor">Mathematics of the SVD and implications </h2>
|
||||
|
||||
<p>
|
||||
Let us take a closer look at the mathematics of the SVD and the various implications for machine learning studies.
|
||||
<p>Let us take a closer look at the mathematics of the SVD and the various implications for machine learning studies.</p>
|
||||
|
||||
<p>
|
||||
Our starting point is our design matrix \( \boldsymbol{X} \) of dimension \( n\times p \)
|
||||
<p>Our starting point is our design matrix \( \boldsymbol{X} \) of dimension \( n\times p \)</p>
|
||||
$$
|
||||
\boldsymbol{X}=\begin{bmatrix}
|
||||
x_{0,0} & x_{0,1} & x_{0,2}& \dots & \dots x_{0,p-1}\\
|
||||
@@ -405,28 +391,23 @@ x_{n-1,0} & x_{n-1,1} & x_{n-1,2}& \dots & \dots x_{n-1,p-1}\\
|
||||
\end{bmatrix}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
We can SVD decompose our matrix as
|
||||
<p>We can SVD decompose our matrix as</p>
|
||||
$$
|
||||
\boldsymbol{X}=\boldsymbol{U}\boldsymbol{\Sigma}\boldsymbol{V}^T,
|
||||
$$
|
||||
|
||||
where \( \boldsymbol{U} \) is an orthogonal matrix of dimension \( n\times n \), meaning that \( \boldsymbol{U}\boldsymbol{U}^T=\boldsymbol{U}^T\boldsymbol{U}=\boldsymbol{I}_n \). Here \( \boldsymbol{I}_n \) is the unit matrix of dimension \( n \times n \).
|
||||
<p>where \( \boldsymbol{U} \) is an orthogonal matrix of dimension \( n\times n \), meaning that \( \boldsymbol{U}\boldsymbol{U}^T=\boldsymbol{U}^T\boldsymbol{U}=\boldsymbol{I}_n \). Here \( \boldsymbol{I}_n \) is the unit matrix of dimension \( n \times n \).</p>
|
||||
|
||||
<p>
|
||||
Similarly, \( \boldsymbol{V} \) is an orthogonal matrix of dimension \( p\times p \), meaning that \( \boldsymbol{V}\boldsymbol{V}^T=\boldsymbol{V}^T\boldsymbol{V}=\boldsymbol{I}_p \). Here \( \boldsymbol{I}_n \) is the unit matrix of dimension \( p \times p \).
|
||||
<p>Similarly, \( \boldsymbol{V} \) is an orthogonal matrix of dimension \( p\times p \), meaning that \( \boldsymbol{V}\boldsymbol{V}^T=\boldsymbol{V}^T\boldsymbol{V}=\boldsymbol{I}_p \). Here \( \boldsymbol{I}_n \) is the unit matrix of dimension \( p \times p \).</p>
|
||||
|
||||
<p>
|
||||
Finally \( \boldsymbol{\Sigma} \) contains the singular values \( \sigma_i \). This matrix has dimension \( n\times p \) and the singular values \( \sigma_i \) are all positive. The non-zero values are ordered in descending order, that is
|
||||
<p>Finally \( \boldsymbol{\Sigma} \) contains the singular values \( \sigma_i \). This matrix has dimension \( n\times p \) and the singular values \( \sigma_i \) are all positive. The non-zero values are ordered in descending order, that is</p>
|
||||
|
||||
$$
|
||||
\sigma_0 > \sigma_1 > \sigma_2 > \dots > \sigma_{p-1} > 0.
|
||||
$$
|
||||
|
||||
<p>
|
||||
All values beyond \( p-1 \) are all zero.
|
||||
<p>All values beyond \( p-1 \) are all zero.</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -456,25 +437,18 @@ All values beyond \( p-1 \) are all zero.
|
||||
<li><a href="._week35-bs049.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,18 +371,13 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0049"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="example-matrix" class="anchor">Example Matrix </h2>
|
||||
|
||||
<p>
|
||||
As an example, consider the following \( 3\times 2 \) example for the matrix \( \boldsymbol{\Sigma} \)
|
||||
<p>As an example, consider the following \( 3\times 2 \) example for the matrix \( \boldsymbol{\Sigma} \)</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{\Sigma}=
|
||||
@@ -401,8 +388,7 @@ $$
|
||||
\end{bmatrix}
|
||||
$$
|
||||
|
||||
<p>
|
||||
The singular values are \( \sigma_0=2 \) and \( \sigma_1=1 \). It is common to rewrite the matrix \( \boldsymbol{\Sigma} \) as
|
||||
<p>The singular values are \( \sigma_0=2 \) and \( \sigma_1=1 \). It is common to rewrite the matrix \( \boldsymbol{\Sigma} \) as</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{\Sigma}=
|
||||
@@ -412,8 +398,7 @@ $$
|
||||
\end{bmatrix},
|
||||
$$
|
||||
|
||||
<p>
|
||||
where
|
||||
<p>where</p>
|
||||
$$
|
||||
\boldsymbol{\tilde{\Sigma}}=
|
||||
\begin{bmatrix}
|
||||
@@ -422,7 +407,7 @@ $$
|
||||
\end{bmatrix},
|
||||
$$
|
||||
|
||||
contains only the singular values. Note also (and we will use this below) that
|
||||
<p>contains only the singular values. Note also (and we will use this below) that</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{\Sigma}^T\boldsymbol{\Sigma}=
|
||||
@@ -432,7 +417,7 @@ $$
|
||||
\end{bmatrix},
|
||||
$$
|
||||
|
||||
which is a \( 2\times 2 \) matrix while
|
||||
<p>which is a \( 2\times 2 \) matrix while</p>
|
||||
$$
|
||||
\boldsymbol{\Sigma}\boldsymbol{\Sigma}^T=
|
||||
\begin{bmatrix}
|
||||
@@ -442,12 +427,11 @@ $$
|
||||
\end{bmatrix},
|
||||
$$
|
||||
|
||||
<p>
|
||||
is a \( 3\times 3 \) matrix. The last row and column of this last matrix
|
||||
<p>is a \( 3\times 3 \) matrix. The last row and column of this last matrix
|
||||
contain only zeros. This will have important consequences for our SVD
|
||||
decomposition of the design matrix.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -477,25 +461,18 @@ decomposition of the design matrix.
|
||||
<li><a href="._week35-bs050.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,69 +371,59 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0050"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="setting-up-the-matrix-to-be-inverted" class="anchor">Setting up the Matrix to be inverted </h2>
|
||||
|
||||
<p>
|
||||
The matrix that may cause problems for us is \( \boldsymbol{X}^T\boldsymbol{X} \). Using the SVD we can rewrite this matrix as
|
||||
<p>The matrix that may cause problems for us is \( \boldsymbol{X}^T\boldsymbol{X} \). Using the SVD we can rewrite this matrix as</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{X}^T\boldsymbol{X}=\boldsymbol{V}\boldsymbol{\Sigma}^T\boldsymbol{U}^T\boldsymbol{U}\boldsymbol{\Sigma}\boldsymbol{V}^T,
|
||||
$$
|
||||
|
||||
and using the orthogonality of the matrix \( \boldsymbol{U} \) we have
|
||||
<p>and using the orthogonality of the matrix \( \boldsymbol{U} \) we have</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{X}^T\boldsymbol{X}=\boldsymbol{V}\boldsymbol{\Sigma}^T\boldsymbol{\Sigma}\boldsymbol{V}^T.
|
||||
$$
|
||||
|
||||
We define \( \boldsymbol{\Sigma}^T\boldsymbol{\Sigma}=\tilde{\boldsymbol{\Sigma}}^2 \) which is a diagonal matrix containing only the singular values squared. It has dimensionality \( p \times p \).
|
||||
<p>We define \( \boldsymbol{\Sigma}^T\boldsymbol{\Sigma}=\tilde{\boldsymbol{\Sigma}}^2 \) which is a diagonal matrix containing only the singular values squared. It has dimensionality \( p \times p \).</p>
|
||||
|
||||
<p>
|
||||
This means, using the orthogonality of \( \boldsymbol{V} \), that we get
|
||||
<p>This means, using the orthogonality of \( \boldsymbol{V} \), that we get</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{X}^T\boldsymbol{X}=\tilde{\boldsymbol{\Sigma}}^2.
|
||||
$$
|
||||
|
||||
<p>
|
||||
We can now insert the result for the matrix \( \boldsymbol{X}^T\boldsymbol{X} \) into our equation for ordinary least squares where
|
||||
<p>We can now insert the result for the matrix \( \boldsymbol{X}^T\boldsymbol{X} \) into our equation for ordinary least squares where</p>
|
||||
|
||||
$$
|
||||
\tilde{y}_{\mathrm{OLS}}=\boldsymbol{X}\left(\boldsymbol{X}^T\boldsymbol{X}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y},
|
||||
$$
|
||||
|
||||
and using our SVD decomposition of \( \boldsymbol{X} \) we have
|
||||
<p>and using our SVD decomposition of \( \boldsymbol{X} \) we have</p>
|
||||
|
||||
$$
|
||||
\tilde{y}_{\mathrm{OLS}}=\boldsymbol{U}\boldsymbol{\Sigma}\boldsymbol{V}^T\tilde{\boldsymbol{\Sigma}}^{-2}\boldsymbol{V}\boldsymbol{\Sigma}^T\boldsymbol{U}^T\boldsymbol{y},
|
||||
$$
|
||||
|
||||
which gives us, using the orthogonality of the matrices \( \boldsymbol{U} \) and \( \boldsymbol{V} \),
|
||||
<p>which gives us, using the orthogonality of the matrices \( \boldsymbol{U} \) and \( \boldsymbol{V} \),</p>
|
||||
|
||||
$$
|
||||
\tilde{y}_{\mathrm{OLS}}=\boldsymbol{U}\boldsymbol{U}^T\boldsymbol{y}=\sum_{i=0}^{p-1}\boldsymbol{u}_i\boldsymbol{u}^T_j\boldsymbol{y},
|
||||
$$
|
||||
|
||||
<p>
|
||||
Note here that when we perform the multiplication of the various matrices, the orthogonal vectors of the matrix \( \boldsymbol{U} \)
|
||||
<p>Note here that when we perform the multiplication of the various matrices, the orthogonal vectors of the matrix \( \boldsymbol{U} \)</p>
|
||||
$$
|
||||
\boldsymbol{U}=[\boldsymbol{u}_0,\boldsymbol{u}_1,\dots,\boldsymbol{u}_{n-1}],
|
||||
$$
|
||||
|
||||
that belong to \( i>p-1 \), result in only zeros when we perform the multiplications. This means that the sum above has non-zero elements only up to \( i=p-1 \). This corresponds also to the number of singular values (these are all non-zero).
|
||||
<p>that belong to \( i>p-1 \), result in only zeros when we perform the multiplications. This means that the sum above has non-zero elements only up to \( i=p-1 \). This corresponds also to the number of singular values (these are all non-zero).</p>
|
||||
|
||||
<p>
|
||||
It means that the ordinary least square model (with the optimal parameters) \( \boldsymbol{\tilde{y}} \), corresponds to an orthogonal transformation of the output (or target) vector \( \boldsymbol{y} \) by the vectors of the matrix \( \boldsymbol{U} \).
|
||||
<p>It means that the ordinary least square model (with the optimal parameters) \( \boldsymbol{\tilde{y}} \), corresponds to an orthogonal transformation of the output (or target) vector \( \boldsymbol{y} \) by the vectors of the matrix \( \boldsymbol{U} \).</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -471,25 +453,18 @@ It means that the ordinary least square model (with the optimal parameters) \( \
|
||||
<li><a href="._week35-bs051.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,65 +371,58 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0051"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="further-properties-important-for-our-analyses-later" class="anchor">Further properties (important for our analyses later) </h2>
|
||||
|
||||
<p>
|
||||
Let us study again \( \boldsymbol{X}^T\boldsymbol{X} \) in terms of our SVD,
|
||||
<p>Let us study again \( \boldsymbol{X}^T\boldsymbol{X} \) in terms of our SVD,</p>
|
||||
$$
|
||||
\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.
|
||||
$$
|
||||
|
||||
<p>
|
||||
If we now multiply from the right with \( \boldsymbol{V} \) (using the orthogonality of \( \boldsymbol{V} \)) we get
|
||||
<p>If we now multiply from the right with \( \boldsymbol{V} \) (using the orthogonality of \( \boldsymbol{V} \)) we get</p>
|
||||
$$
|
||||
\left(\boldsymbol{X}^T\boldsymbol{X}\right)\boldsymbol{V}=\boldsymbol{V}\boldsymbol{\Sigma}^T\boldsymbol{\Sigma}.
|
||||
$$
|
||||
|
||||
This means the vectors \( \boldsymbol{v}_i \) of the orthogonal matrix \( \boldsymbol{V} \) are the eigenvectors of the matrix \( \boldsymbol{X}^T\boldsymbol{X} \)
|
||||
<p>This means the vectors \( \boldsymbol{v}_i \) of the orthogonal matrix \( \boldsymbol{V} \) are the eigenvectors of the matrix \( \boldsymbol{X}^T\boldsymbol{X} \)
|
||||
with eigenvalues given by the singular values squared, that is
|
||||
</p>
|
||||
$$
|
||||
\left(\boldsymbol{X}^T\boldsymbol{X}\right)\boldsymbol{v}_i=\boldsymbol{v}_i\sigma_i^2.
|
||||
$$
|
||||
|
||||
<p>
|
||||
Similarly, if we use the SVD decomposition for the matrix \( \boldsymbol{X}\boldsymbol{X}^T \), we have
|
||||
<p>Similarly, if we use the SVD decomposition for the matrix \( \boldsymbol{X}\boldsymbol{X}^T \), we have</p>
|
||||
$$
|
||||
\boldsymbol{X}\boldsymbol{X}^T=\boldsymbol{U}\boldsymbol{\Sigma}\boldsymbol{V}^T\boldsymbol{V}\boldsymbol{\Sigma}^T\boldsymbol{U}^T=\boldsymbol{U}\boldsymbol{\Sigma}\boldsymbol{\Sigma}^T\boldsymbol{U}^T.
|
||||
$$
|
||||
|
||||
<p>
|
||||
If we now multiply from the right with \( \boldsymbol{U} \) (using the orthogonality of \( \boldsymbol{U} \)) we get
|
||||
<p>If we now multiply from the right with \( \boldsymbol{U} \) (using the orthogonality of \( \boldsymbol{U} \)) we get</p>
|
||||
$$
|
||||
\left(\boldsymbol{X}\boldsymbol{X}^T\right)\boldsymbol{U}=\boldsymbol{U}\boldsymbol{\Sigma}\boldsymbol{\Sigma}^T.
|
||||
$$
|
||||
|
||||
This means the vectors \( \boldsymbol{u}_i \) of the orthogonal matrix \( \boldsymbol{U} \) are the eigenvectors of the matrix \( \boldsymbol{X}\boldsymbol{X}^T \)
|
||||
<p>This means the vectors \( \boldsymbol{u}_i \) of the orthogonal matrix \( \boldsymbol{U} \) are the eigenvectors of the matrix \( \boldsymbol{X}\boldsymbol{X}^T \)
|
||||
with eigenvalues given by the singular values squared, that is
|
||||
</p>
|
||||
$$
|
||||
\left(\boldsymbol{X}\boldsymbol{X}^T\right)\boldsymbol{u}_i=\boldsymbol{u}_i\sigma_i^2.
|
||||
$$
|
||||
|
||||
<p>
|
||||
<b>Important note</b>: we have defined our design matrix \( \boldsymbol{X} \) to be an
|
||||
<p><b>Important note</b>: we have defined our design matrix \( \boldsymbol{X} \) to be an
|
||||
\( n\times p \) matrix. In most supervised learning cases we have that \( n
|
||||
\ge p \), and quite often we have \( n >> p \). For linear algebra based methods like ordinary least squares or Ridge regression, this leads to a matrix \( \boldsymbol{X}^T\boldsymbol{X} \) which is small and thereby easier to handle from a computational point of view (in terms of number of floating point operations).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
In our lectures, the number of columns will
|
||||
<p>In our lectures, the number of columns will
|
||||
always refer to the number of features in our data set, while the
|
||||
number of rows represents the number of data inputs. Note that in
|
||||
other texts you may find the opposite notation. This has consequences
|
||||
for the definition of for example the covariance matrix and its relation to the SVD.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -467,25 +452,18 @@ for the definition of for example the covariance matrix and its relation to the
|
||||
<li><a href="._week35-bs052.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,44 +371,37 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0052"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="meet-the-covariance-matrix" class="anchor">Meet the Covariance Matrix </h2>
|
||||
|
||||
<p>
|
||||
Before we move on to a discussion of Ridge and Lasso regression, we want to show an important example of the above.
|
||||
<p>Before we move on to a discussion of Ridge and Lasso regression, we want to show an important example of the above.</p>
|
||||
|
||||
<p>
|
||||
We have already noted that the matrix \( \boldsymbol{X}^T\boldsymbol{X} \) in ordinary
|
||||
<p>We have already noted that the matrix \( \boldsymbol{X}^T\boldsymbol{X} \) in ordinary
|
||||
least squares is proportional to the second derivative of the cost
|
||||
function, that is we have
|
||||
</p>
|
||||
|
||||
$$
|
||||
\frac{\partial^2 C(\boldsymbol{\beta})}{\partial \boldsymbol{\beta}^T\partial \boldsymbol{\beta}} =\frac{2}{n}\boldsymbol{X}^T\boldsymbol{X}.
|
||||
$$
|
||||
|
||||
This quantity defines was what is called the Hessian matrix (the second derivative of a function we want to optimize).
|
||||
<p>This quantity defines was what is called the Hessian matrix (the second derivative of a function we want to optimize).</p>
|
||||
|
||||
<p>
|
||||
The Hessian matrix plays an important role and is defined in this course as
|
||||
<p>The Hessian matrix plays an important role and is defined in this course as</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{H}=\boldsymbol{X}^T\boldsymbol{X}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
The Hessian matrix for ordinary least squares is also proportional to
|
||||
<p>The Hessian matrix for ordinary least squares is also proportional to
|
||||
the covariance matrix. This means also that we can use the SVD to find
|
||||
the eigenvalues of the covariance matrix and the Hessian matrix in
|
||||
terms of the singular values. Let us develop these arguments, as they will play an important role in our machine learning studies.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -446,25 +431,18 @@ terms of the singular values. Let us develop these arguments, as they will pla
|
||||
<li><a href="._week35-bs053.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,48 +371,43 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0053"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="introducing-the-covariance-and-correlation-functions" class="anchor">Introducing the Covariance and Correlation functions </h2>
|
||||
|
||||
<p>
|
||||
Before we discuss the link between for example Ridge regression and the singular value decomposition, we need to remind ourselves about
|
||||
<p>Before we discuss the link between for example Ridge regression and the singular value decomposition, we need to remind ourselves about
|
||||
the definition of the covariance and the correlation function. These are quantities that play a central role in machine learning methods.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Suppose we have defined two vectors
|
||||
<p>Suppose we have defined two vectors
|
||||
\( \hat{x} \) and \( \hat{y} \) with \( n \) elements each. The covariance matrix \( \boldsymbol{C} \) is defined as
|
||||
</p>
|
||||
$$
|
||||
\boldsymbol{C}[\boldsymbol{x},\boldsymbol{y}] = \begin{bmatrix} \mathrm{cov}[\boldsymbol{x},\boldsymbol{x}] & \mathrm{cov}[\boldsymbol{x},\boldsymbol{y}] \\
|
||||
\mathrm{cov}[\boldsymbol{y},\boldsymbol{x}] & \mathrm{cov}[\boldsymbol{y},\boldsymbol{y}] \\
|
||||
\end{bmatrix},
|
||||
$$
|
||||
|
||||
where for example
|
||||
<p>where for example</p>
|
||||
$$
|
||||
\mathrm{cov}[\boldsymbol{x},\boldsymbol{y}] =\frac{1}{n} \sum_{i=0}^{n-1}(x_i- \overline{x})(y_i- \overline{y}).
|
||||
$$
|
||||
|
||||
With this definition and recalling that the variance is defined as
|
||||
<p>With this definition and recalling that the variance is defined as</p>
|
||||
$$
|
||||
\mathrm{var}[\boldsymbol{x}]=\frac{1}{n} \sum_{i=0}^{n-1}(x_i- \overline{x})^2,
|
||||
$$
|
||||
|
||||
we can rewrite the covariance matrix as
|
||||
<p>we can rewrite the covariance matrix as </p>
|
||||
$$
|
||||
\boldsymbol{C}[\boldsymbol{x},\boldsymbol{y}] = \begin{bmatrix} \mathrm{var}[\boldsymbol{x}] & \mathrm{cov}[\boldsymbol{x},\boldsymbol{y}] \\
|
||||
\mathrm{cov}[\boldsymbol{x},\boldsymbol{y}] & \mathrm{var}[\boldsymbol{y}] \\
|
||||
\end{bmatrix}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
<b>Note:</b> we have used \( 1/n \) in the above definitions of the <em>sample</em> variance and covariance. We assume then that we can calculate the exact mean value.
|
||||
<p><b>Note:</b> we have used \( 1/n \) in the above definitions of the <em>sample</em> variance and covariance. We assume then that we can calculate the exact mean value.
|
||||
What you will find in essentially all statistics texts are equations
|
||||
with a factor \( 1/(n-1) \). This is called <a href="https://mathworld.wolfram.com/BesselsCorrection.html" target="_self">Bessel's correction</a>. This
|
||||
method corrects the bias in the estimation of the population variance
|
||||
@@ -428,8 +415,8 @@ and covariance. It also partially corrects the bias in the estimation
|
||||
of the population standard deviation. If you use a library like
|
||||
<b>Scikit-Learn</b> or <b>nunmpy's</b> function calculate the covariance, this
|
||||
quantity will be computed with a factor \( 1/(n-1) \).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -459,25 +446,18 @@ quantity will be computed with a factor \( 1/(n-1) \).
|
||||
<li><a href="._week35-bs054.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,32 +371,28 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0054"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="covariance-and-correlation-matrix" class="anchor">Covariance and Correlation Matrix </h2>
|
||||
|
||||
<p>
|
||||
The covariance takes values between zero and infinity and may thus
|
||||
<p>The covariance takes values between zero and infinity and may thus
|
||||
lead to problems with loss of numerical precision for particularly
|
||||
large values. It is common to scale the covariance matrix by
|
||||
introducing instead the correlation matrix defined via the so-called
|
||||
correlation function
|
||||
</p>
|
||||
|
||||
$$
|
||||
\mathrm{corr}[\boldsymbol{x},\boldsymbol{y}]=\frac{\mathrm{cov}[\boldsymbol{x},\boldsymbol{y}]}{\sqrt{\mathrm{var}[\boldsymbol{x}] \mathrm{var}[\boldsymbol{y}]}}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
The correlation function is then given by values \( \mathrm{corr}[\boldsymbol{x},\boldsymbol{y}]
|
||||
<p>The correlation function is then given by values \( \mathrm{corr}[\boldsymbol{x},\boldsymbol{y}]
|
||||
\in [-1,1] \). This avoids eventual problems with too large values. We
|
||||
can then define the correlation matrix for the two vectors \( \boldsymbol{x} \)
|
||||
and \( \boldsymbol{y} \) as
|
||||
</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{K}[\boldsymbol{x},\boldsymbol{y}] = \begin{bmatrix} 1 & \mathrm{corr}[\boldsymbol{x},\boldsymbol{y}] \\
|
||||
@@ -412,10 +400,8 @@ $$
|
||||
\end{bmatrix},
|
||||
$$
|
||||
|
||||
<p>
|
||||
In the above example this is the function we constructed using <b>pandas</b>.
|
||||
<p>In the above example this is the function we constructed using <b>pandas</b>.</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -445,25 +431,18 @@ In the above example this is the function we constructed using <b>pandas</b>.
|
||||
<li><a href="._week35-bs055.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,19 +371,15 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0055"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="correlation-function-and-design-feature-matrix" class="anchor">Correlation Function and Design/Feature Matrix </h2>
|
||||
|
||||
<p>
|
||||
In our derivation of the various regression algorithms like <b>Ordinary Least Squares</b> or <b>Ridge regression</b>
|
||||
<p>In our derivation of the various regression algorithms like <b>Ordinary Least Squares</b> or <b>Ridge regression</b>
|
||||
we defined the design/feature matrix \( \boldsymbol{X} \) as
|
||||
</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{X}=\begin{bmatrix}
|
||||
@@ -404,23 +392,24 @@ x_{n-1,0} & x_{n-1,1} & x_{n-1,2}& \dots & \dots x_{n-1,p-1}\\
|
||||
\end{bmatrix},
|
||||
$$
|
||||
|
||||
with \( \boldsymbol{X}\in {\mathbb{R}}^{n\times p} \), with the predictors/features \( p \) refering to the column numbers and the
|
||||
<p>with \( \boldsymbol{X}\in {\mathbb{R}}^{n\times p} \), with the predictors/features \( p \) refering to the column numbers and the
|
||||
entries \( n \) being the row elements.
|
||||
We can rewrite the design/feature matrix in terms of its column vectors as
|
||||
</p>
|
||||
$$
|
||||
\boldsymbol{X}=\begin{bmatrix} \boldsymbol{x}_0 & \boldsymbol{x}_1 & \boldsymbol{x}_2 & \dots & \dots & \boldsymbol{x}_{p-1}\end{bmatrix},
|
||||
$$
|
||||
|
||||
with a given vector
|
||||
<p>with a given vector</p>
|
||||
$$
|
||||
\boldsymbol{x}_i^T = \begin{bmatrix}x_{0,i} & x_{1,i} & x_{2,i}& \dots & \dots x_{n-1,i}\end{bmatrix}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
With these definitions, we can now rewrite our \( 2\times 2 \)
|
||||
<p>With these definitions, we can now rewrite our \( 2\times 2 \)
|
||||
correlation/covariance matrix in terms of a moe general design/feature
|
||||
matrix \( \boldsymbol{X}\in {\mathbb{R}}^{n\times p} \). This leads to a \( p\times p \)
|
||||
covariance matrix for the vectors \( \boldsymbol{x}_i \) with \( i=0,1,\dots,p-1 \)
|
||||
</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{C}[\boldsymbol{x}] = \begin{bmatrix}
|
||||
@@ -433,7 +422,7 @@ $$
|
||||
\end{bmatrix},
|
||||
$$
|
||||
|
||||
and the correlation matrix
|
||||
<p>and the correlation matrix</p>
|
||||
$$
|
||||
\boldsymbol{K}[\boldsymbol{x}] = \begin{bmatrix}
|
||||
1 & \mathrm{corr}[\boldsymbol{x}_0,\boldsymbol{x}_1] & \mathrm{corr}[\boldsymbol{x}_0,\boldsymbol{x}_2] & \dots & \dots & \mathrm{corr}[\boldsymbol{x}_0,\boldsymbol{x}_{p-1}]\\
|
||||
@@ -445,7 +434,7 @@ $$
|
||||
\end{bmatrix},
|
||||
$$
|
||||
|
||||
<p>
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -475,25 +464,18 @@ $$
|
||||
<li><a href="._week35-bs056.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,42 +371,41 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0056"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="covariance-matrix-examples" class="anchor">Covariance Matrix Examples </h2>
|
||||
|
||||
<p>
|
||||
The Numpy function <b>np.cov</b> calculates the covariance elements using
|
||||
<p>The Numpy function <b>np.cov</b> calculates the covariance elements using
|
||||
the factor \( 1/(n-1) \) instead of \( 1/n \) since it assumes we do not have
|
||||
the exact mean values. The following simple function uses the
|
||||
<b>np.vstack</b> function which takes each vector of dimension \( 1\times n \)
|
||||
and produces a \( 2\times n \) matrix \( \boldsymbol{W} \)
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Note that this assumes you have the features as the rows, and the inputs as columns, that is
|
||||
<p>Note that this assumes you have the features as the rows, and the inputs as columns, that is</p>
|
||||
$$
|
||||
\boldsymbol{W} = \begin{bmatrix} x_0 & x_1 & x_2 & \dots & x_{n-2} & x_{n-1} \\
|
||||
y_0 & y_1 & y_2 & \dots & y_{n-2} & y_{n-1} \\
|
||||
\end{bmatrix},
|
||||
$$
|
||||
|
||||
<p>
|
||||
which in turn is converted into into the \( 2\times 2 \) covariance matrix
|
||||
<p>which in turn is converted into into the \( 2\times 2 \) covariance matrix
|
||||
\( \boldsymbol{C} \) via the Numpy function <b>np.cov()</b>. We note that we can also calculate
|
||||
the mean value of each set of samples \( \boldsymbol{x} \) etc using the Numpy
|
||||
function <b>np.mean(x)</b>. We can also extract the eigenvalues of the
|
||||
covariance matrix through the <b>np.linalg.eig()</b> function.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #408080; font-style: italic"># Importing various packages</span>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #408080; font-style: italic"># Importing various packages</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
n <span style="color: #666666">=</span> <span style="color: #666666">100</span>
|
||||
x <span style="color: #666666">=</span> np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>normal(size<span style="color: #666666">=</span>n)
|
||||
@@ -424,8 +415,22 @@ y <span style="color: #666666">=</span> <span style="color: #666666">4+3*</span>
|
||||
W <span style="color: #666666">=</span> np<span style="color: #666666">.</span>vstack((x, y))
|
||||
C <span style="color: #666666">=</span> np<span style="color: #666666">.</span>cov(W)
|
||||
<span style="color: #008000">print</span>(C)
|
||||
</pre></div>
|
||||
<p>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -455,25 +460,18 @@ C <span style="color: #666666">=</span> np<span style="color: #666666">.</span>c
|
||||
<li><a href="._week35-bs057.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,27 +371,27 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0057"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="correlation-matrix" class="anchor">Correlation Matrix </h2>
|
||||
|
||||
<p>
|
||||
The previous example can be converted into the correlation matrix by
|
||||
<p>The previous example can be converted into the correlation matrix by
|
||||
simply scaling the matrix elements with the variances. We should also
|
||||
subtract the mean values for each column. This leads to the following
|
||||
code which sets up the correlations matrix for the previous example in
|
||||
a more brute force way. Here we scale the mean values for each column of the design matrix, calculate the relevant mean values and variances and then finally set up the \( 2\times 2 \) correlation matrix (since we have only two vectors).
|
||||
a more brute force way. Here we scale the mean values for each column of the design matrix, calculate the relevant mean values and variances and then finally set up the \( 2\times 2 \) correlation matrix (since we have only two vectors).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
n <span style="color: #666666">=</span> <span style="color: #666666">100</span>
|
||||
<span style="color: #408080; font-style: italic"># define two vectors </span>
|
||||
x <span style="color: #666666">=</span> np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>random(size<span style="color: #666666">=</span>n)
|
||||
@@ -420,16 +412,28 @@ C[<span style="color: #666666">1</span>,<span style="color: #666666">1</span>]<s
|
||||
C[<span style="color: #666666">0</span>,<span style="color: #666666">1</span>]<span style="color: #666666">=</span> cov_xy<span style="color: #666666">/</span>np<span style="color: #666666">.</span>sqrt(variance_y<span style="color: #666666">*</span>variance_x)
|
||||
C[<span style="color: #666666">1</span>,<span style="color: #666666">0</span>]<span style="color: #666666">=</span> C[<span style="color: #666666">0</span>,<span style="color: #666666">1</span>]
|
||||
<span style="color: #008000">print</span>(C)
|
||||
</pre></div>
|
||||
<p>
|
||||
We see that the matrix elements along the diagonal are one as they
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>We see that the matrix elements along the diagonal are one as they
|
||||
should be and that the matrix is symmetric. Furthermore, diagonalizing
|
||||
this matrix we easily see that it is a positive definite matrix.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The above procedure with <b>numpy</b> can be made more compact if we use <b>pandas</b>.
|
||||
<p>The above procedure with <b>numpy</b> can be made more compact if we use <b>pandas</b>.</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -459,25 +463,18 @@ The above procedure with <b>numpy</b> can be made more compact if we use <b>pand
|
||||
<li><a href="._week35-bs058.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,22 +371,21 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0058"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="correlation-matrix-with-pandas" class="anchor">Correlation Matrix with Pandas </h2>
|
||||
|
||||
<p>
|
||||
We whow here how we can set up the correlation matrix using <b>pandas</b>, as done in this simple code
|
||||
<p>
|
||||
<p>We whow here how we can set up the correlation matrix using <b>pandas</b>, as done in this simple code</p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">pandas</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">pd</span>
|
||||
n <span style="color: #666666">=</span> <span style="color: #666666">10</span>
|
||||
x <span style="color: #666666">=</span> np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>normal(size<span style="color: #666666">=</span>n)
|
||||
@@ -408,11 +399,23 @@ Xpd <span style="color: #666666">=</span> pd<span style="color: #666666">.</span
|
||||
<span style="color: #008000">print</span>(Xpd)
|
||||
correlation_matrix <span style="color: #666666">=</span> Xpd<span style="color: #666666">.</span>corr()
|
||||
<span style="color: #008000">print</span>(correlation_matrix)
|
||||
</pre></div>
|
||||
<p>
|
||||
We expand this model to the Franke function discussed above.
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>We expand this model to the Franke function discussed above.</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -442,25 +445,18 @@ We expand this model to the Franke function discussed above.
|
||||
<li><a href="._week35-bs059.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,20 +371,20 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0059"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="correlation-matrix-with-pandas-and-the-franke-function" class="anchor">Correlation Matrix with Pandas and the Franke function </h2>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #408080; font-style: italic"># Common imports</span>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #408080; font-style: italic"># Common imports</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">pandas</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">pd</span>
|
||||
|
||||
@@ -435,19 +427,32 @@ Xpd <span style="color: #666666">=</span> pd<span style="color: #666666">.</span
|
||||
Xpd <span style="color: #666666">=</span> Xpd <span style="color: #666666">-</span> Xpd<span style="color: #666666">.</span>mean()
|
||||
covariance_matrix <span style="color: #666666">=</span> Xpd<span style="color: #666666">.</span>cov()
|
||||
<span style="color: #008000">print</span>(covariance_matrix)
|
||||
</pre></div>
|
||||
<p>
|
||||
We note here that the covariance is zero for the first rows and
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>We note here that the covariance is zero for the first rows and
|
||||
columns since all matrix elements in the design matrix were set to one
|
||||
(we are fitting the function in terms of a polynomial of degree \( n \)).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
This means that the variance for these elements will be zero and will
|
||||
<p>This means that the variance for these elements will be zero and will
|
||||
cause problems when we set up the correlation matrix. We can simply
|
||||
drop these elements and construct a correlation
|
||||
matrix without these elements.
|
||||
matrix without these elements.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -477,25 +482,18 @@ matrix without these elements.
|
||||
<li><a href="._week35-bs060.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,24 +371,18 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0060"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="rewriting-the-covariance-and-or-correlation-matrix" class="anchor">Rewriting the Covariance and/or Correlation Matrix </h2>
|
||||
|
||||
<p>
|
||||
We can rewrite the covariance matrix in a more compact form in terms of the design/feature matrix \( \boldsymbol{X} \) as
|
||||
<p>We can rewrite the covariance matrix in a more compact form in terms of the design/feature matrix \( \boldsymbol{X} \) as </p>
|
||||
$$
|
||||
\boldsymbol{C}[\boldsymbol{x}] = \frac{1}{n}\boldsymbol{X}^T\boldsymbol{X}= \mathbb{E}[\boldsymbol{X}^T\boldsymbol{X}].
|
||||
$$
|
||||
|
||||
<p>
|
||||
To see this let us simply look at a design matrix \( \boldsymbol{X}\in {\mathbb{R}}^{2\times 2} \)
|
||||
<p>To see this let us simply look at a design matrix \( \boldsymbol{X}\in {\mathbb{R}}^{2\times 2} \)</p>
|
||||
$$
|
||||
\boldsymbol{X}=\begin{bmatrix}
|
||||
x_{00} & x_{01}\\
|
||||
@@ -406,8 +392,7 @@ x_{10} & x_{11}\\
|
||||
\end{bmatrix}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
If we then compute the expectation value (note the \( 1/n \) factor instead of \( 1/(n-1) \))
|
||||
<p>If we then compute the expectation value (note the \( 1/n \) factor instead of \( 1/(n-1) \))</p>
|
||||
$$
|
||||
\mathbb{E}[\boldsymbol{X}^T\boldsymbol{X}] = \frac{1}{n}\boldsymbol{X}^T\boldsymbol{X}=\frac{1}{n}\begin{bmatrix}
|
||||
x_{00}^2+x_{10}^2 & x_{00}x_{01}+x_{10}x_{11}\\
|
||||
@@ -415,19 +400,17 @@ x_{01}x_{00}+x_{11}x_{10} & x_{01}^2+x_{11}^2\\
|
||||
\end{bmatrix},
|
||||
$$
|
||||
|
||||
which is just
|
||||
<p>which is just </p>
|
||||
$$
|
||||
\boldsymbol{C}[\boldsymbol{x}_0,\boldsymbol{x}_1] = \boldsymbol{C}[\boldsymbol{x}]=\begin{bmatrix} \mathrm{var}[\boldsymbol{x}_0] & \mathrm{cov}[\boldsymbol{x}_0,\boldsymbol{x}_1] \\
|
||||
\mathrm{cov}[\boldsymbol{x}_1,\boldsymbol{x}_0] & \mathrm{var}[\boldsymbol{x}_1] \\
|
||||
\end{bmatrix},
|
||||
$$
|
||||
|
||||
where we wrote $$\boldsymbol{C}[\boldsymbol{x}_0,\boldsymbol{x}_1] = \boldsymbol{C}[\boldsymbol{x}]$$ to indicate that this is the covariance of the vectors \( \boldsymbol{x} \) of the design/feature matrix \( \boldsymbol{X} \).
|
||||
<p>where we wrote $$\boldsymbol{C}[\boldsymbol{x}_0,\boldsymbol{x}_1] = \boldsymbol{C}[\boldsymbol{x}]$$ to indicate that this is the covariance of the vectors \( \boldsymbol{x} \) of the design/feature matrix \( \boldsymbol{X} \).</p>
|
||||
|
||||
<p>
|
||||
It is easy to generalize this to a matrix \( \boldsymbol{X}\in {\mathbb{R}}^{n\times p} \).
|
||||
<p>It is easy to generalize this to a matrix \( \boldsymbol{X}\in {\mathbb{R}}^{n\times p} \).</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -455,25 +438,18 @@ It is easy to generalize this to a matrix \( \boldsymbol{X}\in {\mathbb{R}}^{n\t
|
||||
<li><a href="._week35-bs061.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,28 +371,23 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0061"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="linking-with-the-svd" class="anchor">Linking with the SVD </h2>
|
||||
|
||||
<p>
|
||||
We saw earlier that
|
||||
<p>We saw earlier that </p>
|
||||
$$
|
||||
\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
|
||||
<p>Since the matrices here have dimension \( p\times p \), with \( p \) corresponding to the singular values, we defined earlier the matrix</p>
|
||||
$$
|
||||
\boldsymbol{\Sigma}^T\boldsymbol{\Sigma} = \begin{bmatrix} \tilde{\boldsymbol{\Sigma}} & \boldsymbol{0}\\ \end{bmatrix}\begin{bmatrix} \tilde{\boldsymbol{\Sigma}} \\ \boldsymbol{0}\\ \end{bmatrix},
|
||||
$$
|
||||
|
||||
where the tilde-matrix \( \tilde{\boldsymbol{\Sigma}} \) is a matrix of dimension \( p\times p \) containing only the singular values \( \sigma_i \), that is
|
||||
<p>where the tilde-matrix \( \tilde{\boldsymbol{\Sigma}} \) is a matrix of dimension \( p\times p \) containing only the singular values \( \sigma_i \), that is</p>
|
||||
|
||||
$$
|
||||
\tilde{\boldsymbol{\Sigma}}=\begin{bmatrix} \sigma_0 & 0 & 0 & \dots & 0 & 0 \\
|
||||
@@ -411,17 +398,17 @@ $$
|
||||
\end{bmatrix},
|
||||
$$
|
||||
|
||||
meaning we can write
|
||||
<p>meaning we can write</p>
|
||||
$$
|
||||
\boldsymbol{X}^T\boldsymbol{X}=\boldsymbol{V}\tilde{\boldsymbol{\Sigma}}^2\boldsymbol{V}^T.
|
||||
$$
|
||||
|
||||
Multiplying from the right with \( \boldsymbol{V} \) (using the orthogonality of \( \boldsymbol{V} \)) we get
|
||||
<p>Multiplying from the right with \( \boldsymbol{V} \) (using the orthogonality of \( \boldsymbol{V} \)) we get</p>
|
||||
$$
|
||||
\left(\boldsymbol{X}^T\boldsymbol{X}\right)\boldsymbol{V}=\boldsymbol{V}\tilde{\boldsymbol{\Sigma}}^2.
|
||||
$$
|
||||
|
||||
<p>
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -448,25 +435,18 @@ $$
|
||||
<li><a href="._week35-bs062.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,55 +371,50 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0062"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="what-does-it-mean" class="anchor">What does it mean? </h2>
|
||||
|
||||
<p>
|
||||
This means the vectors \( \boldsymbol{v}_i \) of the orthogonal matrix \( \boldsymbol{V} \)
|
||||
<p>This means the vectors \( \boldsymbol{v}_i \) of the orthogonal matrix \( \boldsymbol{V} \)
|
||||
are the eigenvectors of the matrix \( \boldsymbol{X}^T\boldsymbol{X} \) with eigenvalues
|
||||
given by the singular values squared, that is
|
||||
</p>
|
||||
|
||||
$$
|
||||
\left(\boldsymbol{X}^T\boldsymbol{X}\right)\boldsymbol{v}_i=\boldsymbol{v}_i\sigma_i^2.
|
||||
$$
|
||||
|
||||
<p>
|
||||
In other words, each non-zero singular value of \( \boldsymbol{X} \) is a positive
|
||||
<p>In other words, each non-zero singular value of \( \boldsymbol{X} \) is a positive
|
||||
square root of an eigenvalue of \( \boldsymbol{X}^T\boldsymbol{X} \). It means also that
|
||||
the columns of \( \boldsymbol{V} \) are the eigenvectors of
|
||||
\( \boldsymbol{X}^T\boldsymbol{X} \). Since we have ordered the singular values of
|
||||
\( \boldsymbol{X} \) in a descending order, it means that the column vectors
|
||||
\( \boldsymbol{v}_i \) are hierarchically ordered by how much correlation they
|
||||
encode from the columns of \( \boldsymbol{X} \).
|
||||
encode from the columns of \( \boldsymbol{X} \).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Note that these are also the eigenvectors and eigenvalues of the
|
||||
<p>Note that these are also the eigenvectors and eigenvalues of the
|
||||
Hessian matrix.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If we now recall the definition of the covariance matrix (not using
|
||||
<p>If we now recall the definition of the covariance matrix (not using
|
||||
Bessel's correction) we have
|
||||
</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{C}[\boldsymbol{X}]=\frac{1}{n}\boldsymbol{X}^T\boldsymbol{X},
|
||||
$$
|
||||
|
||||
<p>
|
||||
meaning that every squared non-singular value of \( \boldsymbol{X} \) divided by \( n \) (
|
||||
<p>meaning that every squared non-singular value of \( \boldsymbol{X} \) divided by \( n \) (
|
||||
the number of samples) are the eigenvalues of the covariance
|
||||
matrix. Every singular value of \( \boldsymbol{X} \) is thus a positive square
|
||||
root of an eigenvalue of \( \boldsymbol{X}^T\boldsymbol{X} \). If the matrix \( \boldsymbol{X} \) is
|
||||
self-adjoint, the singular values of \( \boldsymbol{X} \) are equal to the
|
||||
absolute value of the eigenvalues of \( \boldsymbol{X} \).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -453,25 +440,18 @@ absolute value of the eigenvalues of \( \boldsymbol{X} \).
|
||||
<li><a href="._week35-bs063.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,51 +371,44 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0063"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="and-finally-boldsymbol-x-boldsymbol-x-t" class="anchor">And finally \( \boldsymbol{X}\boldsymbol{X}^T \) </h2>
|
||||
|
||||
<p>
|
||||
For \( \boldsymbol{X}\boldsymbol{X}^T \) we found
|
||||
<p>For \( \boldsymbol{X}\boldsymbol{X}^T \) we found</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{X}\boldsymbol{X}^T=\boldsymbol{U}\boldsymbol{\Sigma}\boldsymbol{V}^T\boldsymbol{V}\boldsymbol{\Sigma}^T\boldsymbol{U}^T=\boldsymbol{U}\boldsymbol{\Sigma}^T\boldsymbol{\Sigma}\boldsymbol{U}^T.
|
||||
$$
|
||||
|
||||
Since the matrices here have dimension \( n\times n \), we have
|
||||
<p>Since the matrices here have dimension \( n\times n \), we have</p>
|
||||
$$
|
||||
\boldsymbol{\Sigma}\boldsymbol{\Sigma}^T = \begin{bmatrix} \tilde{\boldsymbol{\Sigma}} \\ \boldsymbol{0}\\ \end{bmatrix}\begin{bmatrix} \tilde{\boldsymbol{\Sigma}} \boldsymbol{0}\\ \end{bmatrix}=\begin{bmatrix} \tilde{\boldsymbol{\Sigma}} & \boldsymbol{0} \\ \boldsymbol{0} & \boldsymbol{0}\\ \end{bmatrix},
|
||||
$$
|
||||
|
||||
leading to
|
||||
<p>leading to</p>
|
||||
$$
|
||||
\boldsymbol{X}\boldsymbol{X}^T=\boldsymbol{U}\begin{bmatrix} \tilde{\boldsymbol{\Sigma}} & \boldsymbol{0} \\ \boldsymbol{0} & \boldsymbol{0}\\ \end{bmatrix}\boldsymbol{U}^T.
|
||||
$$
|
||||
|
||||
<p>
|
||||
Multiplying with \( \boldsymbol{U} \) from the right gives us the eigenvalue problem
|
||||
<p>Multiplying with \( \boldsymbol{U} \) from the right gives us the eigenvalue problem</p>
|
||||
$$
|
||||
(\boldsymbol{X}\boldsymbol{X}^T)\boldsymbol{U}=\boldsymbol{U}\begin{bmatrix} \tilde{\boldsymbol{\Sigma}} & \boldsymbol{0} \\ \boldsymbol{0} & \boldsymbol{0}\\ \end{bmatrix}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
It means that the eigenvalues of \( \boldsymbol{X}\boldsymbol{X}^T \) are again given by
|
||||
<p>It means that the eigenvalues of \( \boldsymbol{X}\boldsymbol{X}^T \) are again given by
|
||||
the non-zero singular values plus now a series of zeros. The column
|
||||
vectors of \( \boldsymbol{U} \) are the eigenvectors of \( \boldsymbol{X}\boldsymbol{X}^T \) and
|
||||
measure how much correlations are contained in the rows of \( \boldsymbol{X} \).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Since we will mainly be interested in the correlations among the features
|
||||
<p>Since we will mainly be interested in the correlations among the features
|
||||
of our data (the columns of \( \boldsymbol{X} \), the quantity of interest for us are the non-zero singular
|
||||
values and the column vectors of \( \boldsymbol{V} \).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -448,25 +433,18 @@ values and the column vectors of \( \boldsymbol{V} \).
|
||||
<li><a href="._week35-bs064.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,70 +371,64 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0064"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="ridge-and-lasso-regression" class="anchor">Ridge and LASSO Regression </h2>
|
||||
|
||||
<p>
|
||||
Let us remind ourselves about the expression for the standard Mean Squared Error (MSE) which we used to define our cost function and the equations for the ordinary least squares (OLS) method, that is
|
||||
<p>Let us remind ourselves about the expression for the standard Mean Squared Error (MSE) which we used to define our cost function and the equations for the ordinary least squares (OLS) method, that is
|
||||
our optimization problem is
|
||||
</p>
|
||||
$$
|
||||
{\displaystyle \min_{\boldsymbol{\beta}\in {\mathbb{R}}^{p}}}\frac{1}{n}\left\{\left(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\right)^T\left(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\right)\right\}.
|
||||
$$
|
||||
|
||||
or we can state it as
|
||||
<p>or we can state it as</p>
|
||||
$$
|
||||
{\displaystyle \min_{\boldsymbol{\beta}\in
|
||||
{\mathbb{R}}^{p}}}\frac{1}{n}\sum_{i=0}^{n-1}\left(y_i-\tilde{y}_i\right)^2=\frac{1}{n}\vert\vert \boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\vert\vert_2^2,
|
||||
$$
|
||||
|
||||
where we have used the definition of a norm-2 vector, that is
|
||||
<p>where we have used the definition of a norm-2 vector, that is</p>
|
||||
$$
|
||||
\vert\vert \boldsymbol{x}\vert\vert_2 = \sqrt{\sum_i x_i^2}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
By minimizing the above equation with respect to the parameters
|
||||
<p>By minimizing the above equation with respect to the parameters
|
||||
\( \boldsymbol{\beta} \) we could then obtain an analytical expression for the
|
||||
parameters \( \boldsymbol{\beta} \). We can add a regularization parameter \( \lambda \) by
|
||||
defining a new cost function to be optimized, that is
|
||||
</p>
|
||||
|
||||
$$
|
||||
{\displaystyle \min_{\boldsymbol{\beta}\in
|
||||
{\mathbb{R}}^{p}}}\frac{1}{n}\vert\vert \boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\vert\vert_2^2+\lambda\vert\vert \boldsymbol{\beta}\vert\vert_2^2
|
||||
$$
|
||||
|
||||
<p>
|
||||
which leads to the Ridge regression minimization problem where we
|
||||
<p>which leads to the Ridge regression minimization problem where we
|
||||
require that \( \vert\vert \boldsymbol{\beta}\vert\vert_2^2\le t \), where \( t \) is
|
||||
a finite number larger than zero. By defining
|
||||
</p>
|
||||
|
||||
$$
|
||||
C(\boldsymbol{X},\boldsymbol{\beta})=\frac{1}{n}\vert\vert \boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\vert\vert_2^2+\lambda\vert\vert \boldsymbol{\beta}\vert\vert_1,
|
||||
$$
|
||||
|
||||
<p>
|
||||
we have a new optimization equation
|
||||
<p>we have a new optimization equation</p>
|
||||
$$
|
||||
{\displaystyle \min_{\boldsymbol{\beta}\in
|
||||
{\mathbb{R}}^{p}}}\frac{1}{n}\vert\vert \boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\vert\vert_2^2+\lambda\vert\vert \boldsymbol{\beta}\vert\vert_1
|
||||
$$
|
||||
|
||||
which leads to Lasso regression. Lasso stands for least absolute shrinkage and selection operator.
|
||||
<p>which leads to Lasso regression. Lasso stands for least absolute shrinkage and selection operator. </p>
|
||||
|
||||
<p>
|
||||
Here we have defined the norm-1 as
|
||||
<p>Here we have defined the norm-1 as </p>
|
||||
$$
|
||||
\vert\vert \boldsymbol{x}\vert\vert_1 = \sum_i \vert x_i\vert.
|
||||
$$
|
||||
|
||||
<p>
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -466,25 +452,18 @@ $$
|
||||
<li><a href="._week35-bs065.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,75 +371,72 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0065"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="deriving-the-ridge-regression-equations" class="anchor">Deriving the Ridge Regression Equations </h2>
|
||||
|
||||
<p>
|
||||
Using the matrix-vector expression for Ridge regression and dropping the parameter \( 1/n \) in front of the standard means squared error equation, we have
|
||||
<p>Using the matrix-vector expression for Ridge regression and dropping the parameter \( 1/n \) in front of the standard means squared error equation, we have</p>
|
||||
|
||||
$$
|
||||
C(\boldsymbol{X},\boldsymbol{\beta})=\left\{(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})^T(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})\right\}+\lambda\boldsymbol{\beta}^T\boldsymbol{\beta},
|
||||
$$
|
||||
|
||||
and
|
||||
<p>and
|
||||
taking the derivatives with respect to \( \boldsymbol{\beta} \) we obtain then
|
||||
a slightly modified matrix inversion problem which for finite values
|
||||
of \( \lambda \) does not suffer from singularity problems. We obtain
|
||||
the optimal parameters
|
||||
</p>
|
||||
$$
|
||||
\hat{\boldsymbol{\beta}}_{\mathrm{Ridge}} = \left(\boldsymbol{X}^T\boldsymbol{X}+\lambda\boldsymbol{I}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y},
|
||||
$$
|
||||
|
||||
<p>
|
||||
with \( \boldsymbol{I} \) being a \( p\times p \) identity matrix with the constraint that
|
||||
<p>with \( \boldsymbol{I} \) being a \( p\times p \) identity matrix with the constraint that</p>
|
||||
|
||||
$$
|
||||
\sum_{i=0}^{p-1} \beta_i^2 \leq t,
|
||||
$$
|
||||
|
||||
<p>
|
||||
with \( t \) a finite positive number.
|
||||
<p>with \( t \) a finite positive number. </p>
|
||||
|
||||
<p>
|
||||
When we compare this with the ordinary least squares result we have
|
||||
<p>If we keep the \( 1/n \) factor, the equation for the optimal \( \beta \) changes to</p>
|
||||
$$
|
||||
\hat{\boldsymbol{\beta}}_{\mathrm{Ridge}} = \left(\boldsymbol{X}^T\boldsymbol{X}+n\lambda\boldsymbol{I}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y}.
|
||||
$$
|
||||
|
||||
<p>In many textbooks the \( 1/n \) term is often omitted. Note that a library like <b>Scikit-Learn</b> does not include the \( 1/n \) factor in the setup of the cost function.</p>
|
||||
|
||||
<p>When we compare this with the ordinary least squares result we have</p>
|
||||
$$
|
||||
\hat{\boldsymbol{\beta}}_{\mathrm{OLS}} = \left(\boldsymbol{X}^T\boldsymbol{X}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y},
|
||||
$$
|
||||
|
||||
which can lead to singular matrices. However, with the SVD, we can always compute the inverse of the matrix \( \boldsymbol{X}^T\boldsymbol{X} \).
|
||||
<p>which can lead to singular matrices. However, with the SVD, we can always compute the inverse of the matrix \( \boldsymbol{X}^T\boldsymbol{X} \).</p>
|
||||
|
||||
<p>
|
||||
We see that Ridge regression is nothing but the standard OLS with a
|
||||
<p>We see that Ridge regression is nothing but the standard OLS with a
|
||||
modified diagonal term added to \( \boldsymbol{X}^T\boldsymbol{X} \). The consequences, in
|
||||
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>
|
||||
|
||||
<p>
|
||||
Using our insights about the SVD of the design matrix \( \boldsymbol{X} \)
|
||||
<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
|
||||
</p>
|
||||
$$
|
||||
\tilde{\boldsymbol{y}}_{\mathrm{OLS}}=\boldsymbol{X}\boldsymbol{\beta} =\boldsymbol{U}\boldsymbol{U}^T\boldsymbol{y}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
For Ridge regression this becomes
|
||||
<p>For Ridge regression this becomes</p>
|
||||
|
||||
$$
|
||||
\tilde{\boldsymbol{y}}_{\mathrm{Ridge}}=\boldsymbol{X}\boldsymbol{\beta}_{\mathrm{Ridge}} = \boldsymbol{U\Sigma V^T}\left(\boldsymbol{V}\boldsymbol{\Sigma}^2\boldsymbol{V}^T+\lambda\boldsymbol{I} \right)^{-1}(\boldsymbol{U\Sigma V^T})^T\boldsymbol{y}=\sum_{j=0}^{p-1}\boldsymbol{u}_j\boldsymbol{u}_j^T\frac{\sigma_j^2}{\sigma_j^2+\lambda}\boldsymbol{y},
|
||||
$$
|
||||
|
||||
<p>
|
||||
with the vectors \( \boldsymbol{u}_j \) being the columns of \( \boldsymbol{U} \) from the SVD of the matrix \( \boldsymbol{X} \).
|
||||
<p>with the vectors \( \boldsymbol{u}_j \) being the columns of \( \boldsymbol{U} \) from the SVD of the matrix \( \boldsymbol{X} \). </p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -470,25 +459,18 @@ with the vectors \( \boldsymbol{u}_j \) being the columns of \( \boldsymbol{U} \
|
||||
<li><a href="._week35-bs066.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,34 +371,27 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0066"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="interpreting-the-ridge-results" class="anchor">Interpreting the Ridge results </h2>
|
||||
|
||||
<p>
|
||||
Since \( \lambda \geq 0 \), it means that compared to OLS, we have
|
||||
<p>Since \( \lambda \geq 0 \), it means that compared to OLS, we have </p>
|
||||
|
||||
$$
|
||||
\frac{\sigma_j^2}{\sigma_j^2+\lambda} \leq 1.
|
||||
$$
|
||||
|
||||
<p>
|
||||
Ridge regression finds the coordinates of \( \boldsymbol{y} \) with respect to the
|
||||
<p>Ridge regression finds the coordinates of \( \boldsymbol{y} \) with respect to the
|
||||
orthonormal basis \( \boldsymbol{U} \), it then shrinks the coordinates by
|
||||
\( \frac{\sigma_j^2}{\sigma_j^2+\lambda} \). Recall that the SVD has
|
||||
eigenvalues ordered in a descending way, that is \( \sigma_i \geq
|
||||
\sigma_{i+1} \).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For small eigenvalues \( \sigma_i \) it means that their contributions become less important, a fact which can be used to reduce the number of degrees of freedom. More about this when we have covered the material on a statistical interpretation of various linear regression methods.
|
||||
<p>For small eigenvalues \( \sigma_i \) it means that their contributions become less important, a fact which can be used to reduce the number of degrees of freedom. More about this when we have covered the material on a statistical interpretation of various linear regression methods.</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -428,25 +413,18 @@ For small eigenvalues \( \sigma_i \) it means that their contributions become le
|
||||
<li><a href="._week35-bs067.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,49 +371,40 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0067"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="more-interpretations" class="anchor">More interpretations </h2>
|
||||
|
||||
<p>
|
||||
For the sake of simplicity, let us assume that the design matrix is orthonormal, that is
|
||||
<p>For the sake of simplicity, let us assume that the design matrix is orthonormal, that is </p>
|
||||
|
||||
$$
|
||||
\boldsymbol{X}^T\boldsymbol{X}=(\boldsymbol{X}^T\boldsymbol{X})^{-1} =\boldsymbol{I}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
In this case the standard OLS results in
|
||||
<p>In this case the standard OLS results in </p>
|
||||
$$
|
||||
\boldsymbol{\beta}^{\mathrm{OLS}} = \boldsymbol{X}^T\boldsymbol{y}=\sum_{i=0}^{p-1}\boldsymbol{u}_j\boldsymbol{u}_j^T\boldsymbol{y},
|
||||
$$
|
||||
|
||||
<p>
|
||||
and
|
||||
<p>and</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{\beta}^{\mathrm{Ridge}} = \left(\boldsymbol{I}+\lambda\boldsymbol{I}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y}=\left(1+\lambda\right)^{-1}\boldsymbol{\beta}^{\mathrm{OLS}},
|
||||
$$
|
||||
|
||||
<p>
|
||||
that is the Ridge estimator scales the OLS estimator by the inverse of a factor \( 1+\lambda \), and
|
||||
<p>that is the Ridge estimator scales the OLS estimator by the inverse of a factor \( 1+\lambda \), and
|
||||
the Ridge estimator converges to zero when the hyperparameter goes to
|
||||
infinity.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
We will come back to more interpreations after we have gone through some of the statistical analysis part.
|
||||
<p>We will come back to more interpreations after we have gone through some of the statistical analysis part. </p>
|
||||
|
||||
<p>
|
||||
For more discussions of Ridge and Lasso regression, <a href="https://arxiv.org/abs/1509.09169" target="_self">Wessel van Wieringen's</a> article is highly recommended.
|
||||
<p>For more discussions of Ridge and Lasso regression, <a href="https://arxiv.org/abs/1509.09169" target="_self">Wessel van Wieringen's</a> article is highly recommended.
|
||||
Similarly, <a href="https://arxiv.org/abs/1803.08823" target="_self">Mehta et al's article</a> is also recommended.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -442,25 +425,18 @@ Similarly, <a href="https://arxiv.org/abs/1803.08823" target="_self">Mehta et al
|
||||
<li><a href="._week35-bs068.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,43 +371,36 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0068"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="deriving-the-lasso-regression-equations" class="anchor">Deriving the Lasso Regression Equations </h2>
|
||||
|
||||
<p>
|
||||
Using the matrix-vector expression for Lasso regression and dropping the parameter \( 1/n \) in front of the standard means squared error equation, we have the following <b>cost</b> function
|
||||
<p>Using the matrix-vector expression for Lasso regression and dropping the parameter \( 1/n \) in front of the standard means squared error equation, we have the following <b>cost</b> function</p>
|
||||
|
||||
$$
|
||||
C(\boldsymbol{X},\boldsymbol{\beta})=\left\{(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})^T(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})\right\}+\lambda\vert\vert\boldsymbol{\beta}\vert\vert_1,
|
||||
$$
|
||||
|
||||
<p>
|
||||
Taking the derivative with respect to \( \boldsymbol{\beta} \) and recalling that the derivative of the absolute value is (we drop the boldfaced vector symbol for simplicty)
|
||||
<p>Taking the derivative with respect to \( \boldsymbol{\beta} \) and recalling that the derivative of the absolute value is (we drop the boldfaced vector symbol for simplicty)</p>
|
||||
$$
|
||||
\frac{d \vert \beta\vert}{d \boldsymbol{\beta}}=\mathrm{sgn}(\boldsymbol{\beta})=\left\{\begin{array}{cc} 1 & \beta > 0 \\ 0 & \beta =0\\-1 & \beta < 0, \end{array}\right.
|
||||
$$
|
||||
|
||||
we have that the derivative of the cost function is
|
||||
<p>we have that the derivative of the cost function is</p>
|
||||
|
||||
$$
|
||||
\frac{\partial C(\boldsymbol{X},\boldsymbol{\beta})}{\partial \boldsymbol{\beta}}=-2\boldsymbol{X}^T(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})+\lambda sgn(\boldsymbol{\beta})=0,
|
||||
$$
|
||||
|
||||
and reordering we have
|
||||
<p>and reordering we have</p>
|
||||
$$
|
||||
\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 either 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="_self">CVXOPT</a>. We will discuss this later.
|
||||
<p>This equation does not lead to a nice analytical equation as in either 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="_self">CVXOPT</a>. We will discuss this later. </p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -435,25 +420,18 @@ This equation does not lead to a nice analytical equation as in either Ridge reg
|
||||
<li><a href="._week35-bs069.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,57 +371,70 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0069"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="exercises-for-week-36-september-6-10" class="anchor">Exercises for week 36, September 6-10 </h2>
|
||||
|
||||
<p>
|
||||
The exercises here are meant to prepare you for work with project 1. The first exercise is a follow-up of exercise 2 from week 35 August 30-September 3).
|
||||
<p>The exercises here are meant to prepare you for work with project 1. The first exercise is a follow-up of exercise 2 from week 35 August 30-September 3).</p>
|
||||
|
||||
<p>
|
||||
<!-- --- begin exercise --- -->
|
||||
|
||||
<h2 id="exercise-1-adding-ridge-and-lasso-regression" class="anchor">Exercise 1: Adding Ridge and Lasso Regression </h2>
|
||||
|
||||
<p>
|
||||
This exercise is a continuation of exercise 2 from exercise set 1
|
||||
<p>This exercise is a continuation of exercise 2 from exercise set 1
|
||||
(week 35, August 30-September 3). We will use the same function to
|
||||
generate our data set, still staying with a simple function \( y(x) \)
|
||||
which we want to fit using linear regression, but now extending the
|
||||
analysis to include the Ridge and the Lasso regression methods.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
We will thus again generate our own dataset for a function \( y(x) \) where
|
||||
<p>We will thus again generate our own dataset for a function \( y(x) \) where
|
||||
\( x \in [0,1] \) and defined by random numbers computed with the uniform
|
||||
distribution. The function \( y \) is a quadratic polynomial in \( x \) with
|
||||
added stochastic noise according to the normal distribution \( \cal{N}(0,1) \).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The following simple Python instructions define our \( x \) and \( y \) values (with 100 data points).
|
||||
<p>
|
||||
<p>The following simple Python instructions define our \( x \) and \( y \) values (with 100 data points).</p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span>x <span style="color: #666666">=</span> np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>rand(<span style="color: #666666">100</span>)
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;">x <span style="color: #666666">=</span> np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>rand(<span style="color: #666666">100</span>)
|
||||
y <span style="color: #666666">=</span> <span style="color: #666666">2.0+5*</span>x<span style="color: #666666">*</span>x<span style="color: #666666">+0.1*</span>np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>randn(<span style="color: #666666">100</span>)
|
||||
</pre></div>
|
||||
<p>
|
||||
Write your own code for the Ridge method (see chapter 3.4 of Hastie <em>et al.</em>, equations (3.43) and (3.44)) and compute the parametrization for different values of \( \lambda \). Compare and analyze your results with those from exercise 3. Study the dependence on \( \lambda \) while also varying the strength of the noise in your expression for \( y(x) \).
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
The code here allows you to perform your own Ridge calculation and
|
||||
<p>Write your own code for the Ridge method (see chapter 3.4 of Hastie <em>et al.</em>, equations (3.43) and (3.44)) and compute the parametrization for different values of \( \lambda \). Compare and analyze your results with those from exercise 3. Study the dependence on \( \lambda \) while also varying the strength of the noise in your expression for \( y(x) \). </p>
|
||||
|
||||
<p>The code here allows you to perform your own Ridge calculation and
|
||||
perform calculations for various values of the regularization
|
||||
parameter \( \lambda \). This program can easily be extended upon.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">os</span>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">os</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">pandas</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">pd</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">matplotlib.pyplot</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">plt</span>
|
||||
@@ -498,49 +503,61 @@ plt<span style="color: #666666">.</span>xlabel(<span style="color: #BA2121">'
|
||||
plt<span style="color: #666666">.</span>ylabel(<span style="color: #BA2121">'MSE'</span>)
|
||||
plt<span style="color: #666666">.</span>legend()
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
<p>
|
||||
Repeat the above but using the functionality of
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>Repeat the above but using the functionality of
|
||||
<b>Scikit-Learn</b>. Compare your code with the results from
|
||||
<b>Scikit-Learn</b>. Remember to run with the same random numbers for
|
||||
generating \( x \) and \( y \). Observe also that when you compare with <b>Scikit-Learn</b>, you need to pay attention to how the intercept is dealt with.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Finally, using <b>Scikit-Learn</b> or your own code, compute also the mean square error, a risk metric corresponding to the expected value of the squared (quadratic) error defined as
|
||||
<p>Finally, using <b>Scikit-Learn</b> or your own code, compute also the mean square error, a risk metric corresponding to the expected value of the squared (quadratic) error defined as</p>
|
||||
$$ MSE(\hat{y},\hat{\tilde{y}}) = \frac{1}{n}
|
||||
\sum_{i=0}^{n-1}(y_i-\tilde{y}_i)^2,
|
||||
$$
|
||||
|
||||
and the \( R^2 \) score function.
|
||||
<p>and the \( R^2 \) score function.
|
||||
If \( \tilde{\hat{y}}_i \) is the predicted value of the \( i-th \) sample and \( y_i \) is the corresponding true value, then the score \( R^2 \) is defined as
|
||||
</p>
|
||||
$$
|
||||
R^2(\hat{y}, \tilde{\hat{y}}) = 1 - \frac{\sum_{i=0}^{n - 1} (y_i - \tilde{y}_i)^2}{\sum_{i=0}^{n - 1} (y_i - \bar{y})^2},
|
||||
$$
|
||||
|
||||
where we have defined the mean value of \( \hat{y} \) as
|
||||
<p>where we have defined the mean value of \( \hat{y} \) as</p>
|
||||
$$
|
||||
\bar{y} = \frac{1}{n} \sum_{i=0}^{n - 1} y_i.
|
||||
$$
|
||||
|
||||
Discuss these quantities as functions of the variable \( \lambda \) in the Ridge and Lasso regression methods.
|
||||
|
||||
<p>Discuss these quantities as functions of the variable \( \lambda \) in the Ridge and Lasso regression methods.</p>
|
||||
<h3 id="exercise-linear-regression-for-a-two-dimensional-function" class="anchor">Exercise: Linear Regression for a two-dimensional function </h3>
|
||||
|
||||
<p>
|
||||
This is a longer exercise and the aim is to study in more detail various
|
||||
<p>This is a longer exercise and the aim is to study in more detail various
|
||||
regression methods, including the Ordinary Least Squares (OLS) method,
|
||||
Ridge regression and finally Lasso regression.
|
||||
This exercise forms a part of project 1.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
We will study how to fit polynomials to a specific
|
||||
<p>We will study how to fit polynomials to a specific
|
||||
two-dimensional function called <a href="http://www.dtic.mil/dtic/tr/fulltext/u2/a081688.pdf" target="_self">Franke's
|
||||
function</a>. This
|
||||
is a function which has been widely used when testing various
|
||||
interpolation and fitting algorithms.
|
||||
interpolation and fitting algorithms.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The Franke function, which is a weighted sum of four exponentials reads as follows
|
||||
<p>The Franke function, which is a weighted sum of four exponentials reads as follows</p>
|
||||
$$
|
||||
\begin{align*}
|
||||
f(x,y) &= \frac{3}{4}\exp{\left(-\frac{(9x-2)^2}{4} - \frac{(9y-2)^2}{4}\right)}+\frac{3}{4}\exp{\left(-\frac{(9x+1)^2}{49}- \frac{(9y+1)}{10}\right)} \\
|
||||
@@ -548,8 +565,7 @@ f(x,y) &= \frac{3}{4}\exp{\left(-\frac{(9x-2)^2}{4} - \frac{(9y-2)^2}{4}\right)}
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
<p>
|
||||
The function will be defined for \( x,y\in [0,1] \). Our first step will
|
||||
<p>The function will be defined for \( x,y\in [0,1] \). Our first step will
|
||||
be to perform an OLS regression analysis of this function, trying out
|
||||
a polynomial fit with an \( x \) and \( y \) dependence of the form \( [x, y,
|
||||
x^2, y^2, xy, \dots] \). We will fit a
|
||||
@@ -557,13 +573,17 @@ function (for example a polynomial) of \( x \) and \( y \). Thereafter we
|
||||
will repeat much of the same procedure using the Ridge and Lasso
|
||||
regression methods, introducing thus a dependence on the bias
|
||||
(penalty) \( \lambda \).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The Python fucntion for the Franke function is included here (it performs also a three-dimensional plot of it)
|
||||
<p>
|
||||
<p>The Python fucntion for the Franke function is included here (it performs also a three-dimensional plot of it)</p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">mpl_toolkits.mplot3d</span> <span style="color: #008000; font-weight: bold">import</span> Axes3D
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">mpl_toolkits.mplot3d</span> <span style="color: #008000; font-weight: bold">import</span> Axes3D
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">matplotlib.pyplot</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">plt</span>
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">matplotlib</span> <span style="color: #008000; font-weight: bold">import</span> cm
|
||||
<span style="color: #008000; font-weight: bold">from</span> <span style="color: #0000FF; font-weight: bold">matplotlib.ticker</span> <span style="color: #008000; font-weight: bold">import</span> LinearLocator, FormatStrFormatter
|
||||
@@ -602,51 +622,65 @@ ax<span style="color: #666666">.</span>zaxis<span style="color: #666666">.</span
|
||||
fig<span style="color: #666666">.</span>colorbar(surf, shrink<span style="color: #666666">=0.5</span>, aspect<span style="color: #666666">=5</span>)
|
||||
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
<p>
|
||||
We will generate our own dataset for a function
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>We will generate our own dataset for a function
|
||||
\( \mathrm{FrankeFunction}(x,y) \) with \( x,y \in [0,1] \). The function
|
||||
\( f(x,y) \) is the Franke function. You should explore also the addition
|
||||
an added stochastic noise to this function using the normal
|
||||
distribution \( \cal{N}(0,1) \).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Write your own code (using either a matrix inversion or a singular
|
||||
<p>Write your own code (using either a matrix inversion or a singular
|
||||
value decomposition from e.g., <b>numpy</b> ) or use your code and perform a standard least square regression
|
||||
analysis using polynomials in \( x \) and \( y \) up to fifth order. You can use <b>scikit-learn</b> as well.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Evaluate the Mean Squared error (MSE)
|
||||
<p>Evaluate the Mean Squared error (MSE)</p>
|
||||
|
||||
$$ MSE(\hat{y},\hat{\tilde{y}}) = \frac{1}{n}
|
||||
\sum_{i=0}^{n-1}(y_i-\tilde{y}_i)^2,
|
||||
$$
|
||||
|
||||
<p>
|
||||
and the \( R^2 \) score function. If \( \tilde{\hat{y}}_i \) is the predicted
|
||||
<p>and the \( R^2 \) score function. If \( \tilde{\hat{y}}_i \) is the predicted
|
||||
value of the \( i-th \) sample and \( y_i \) is the corresponding true value,
|
||||
then the score \( R^2 \) is defined as
|
||||
</p>
|
||||
|
||||
$$
|
||||
R^2(\hat{y}, \tilde{\hat{y}}) = 1 - \frac{\sum_{i=0}^{n - 1} (y_i - \tilde{y}_i)^2}{\sum_{i=0}^{n - 1} (y_i - \bar{y})^2},
|
||||
$$
|
||||
|
||||
<p>
|
||||
where we have defined the mean value of \( \hat{y} \) as
|
||||
<p>where we have defined the mean value of \( \hat{y} \) as</p>
|
||||
|
||||
$$
|
||||
\bar{y} = \frac{1}{n} \sum_{i=0}^{n - 1} y_i.
|
||||
$$
|
||||
|
||||
<p>
|
||||
You should split your data in train and test and also consider scaling the data.
|
||||
<p>You should split your data in train and test and also consider scaling the data.</p>
|
||||
|
||||
<p>
|
||||
To set up the design matrix, the following code can be used
|
||||
<p>
|
||||
<p>To set up the design matrix, the following code can be used</p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">FrankeFunction</span>(x,y):
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">FrankeFunction</span>(x,y):
|
||||
term1 <span style="color: #666666">=</span> <span style="color: #666666">0.75*</span>np<span style="color: #666666">.</span>exp(<span style="color: #666666">-</span>(<span style="color: #666666">0.25*</span>(<span style="color: #666666">9*</span>x<span style="color: #666666">-2</span>)<span style="color: #666666">**2</span>) <span style="color: #666666">-</span> <span style="color: #666666">0.25*</span>((<span style="color: #666666">9*</span>y<span style="color: #666666">-2</span>)<span style="color: #666666">**2</span>))
|
||||
term2 <span style="color: #666666">=</span> <span style="color: #666666">0.75*</span>np<span style="color: #666666">.</span>exp(<span style="color: #666666">-</span>((<span style="color: #666666">9*</span>x<span style="color: #666666">+1</span>)<span style="color: #666666">**2</span>)<span style="color: #666666">/49.0</span> <span style="color: #666666">-</span> <span style="color: #666666">0.1*</span>(<span style="color: #666666">9*</span>y<span style="color: #666666">+1</span>))
|
||||
term3 <span style="color: #666666">=</span> <span style="color: #666666">0.5*</span>np<span style="color: #666666">.</span>exp(<span style="color: #666666">-</span>(<span style="color: #666666">9*</span>x<span style="color: #666666">-7</span>)<span style="color: #666666">**2/4.0</span> <span style="color: #666666">-</span> <span style="color: #666666">0.25*</span>((<span style="color: #666666">9*</span>y<span style="color: #666666">-3</span>)<span style="color: #666666">**2</span>))
|
||||
@@ -678,24 +712,36 @@ x <span style="color: #666666">=</span> np<span style="color: #666666">.</span>s
|
||||
y <span style="color: #666666">=</span> np<span style="color: #666666">.</span>sort(np<span style="color: #666666">.</span>random<span style="color: #666666">.</span>uniform(<span style="color: #666666">0</span>, <span style="color: #666666">1</span>, N))
|
||||
z <span style="color: #666666">=</span> FrankeFunction(x, y)
|
||||
X <span style="color: #666666">=</span> create_X(x, y, n<span style="color: #666666">=</span>n)
|
||||
</pre></div>
|
||||
<p>
|
||||
Write then your own code for the Ridge method or use <b>Scikit-Learn</b>.
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>Write then your own code for the Ridge method or use <b>Scikit-Learn</b>.
|
||||
Perform the same analysis as you did for ordinary Least Squares (for the same polynomials) but now for different values of \( \lambda \). Compare and
|
||||
analyze your results with those obtained with ordinary Least Squares. Study the
|
||||
dependence on \( \lambda \).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
This part is essentially a repeat of the previous ones, but now
|
||||
<p>This part is essentially a repeat of the previous ones, but now
|
||||
with Lasso regression. Write either your own code or
|
||||
use the functionalities of <b>Scikit-Learn</b> (recommended).
|
||||
Give a
|
||||
critical discussion of the three methods and a judgement of which
|
||||
model fits the data best.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<!-- --- end exercise --- -->
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -713,25 +759,18 @@ model fits the data best.
|
||||
<li class="active"><a href="._week35-bs069.html">70</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression">
|
||||
|
||||
<title>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week35.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week35-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -283,8 +278,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -295,7 +288,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week35-bs.html">Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -379,36 +371,32 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0000"></a>
|
||||
<!-- ------------------- main content ---------------------- -->
|
||||
|
||||
|
||||
|
||||
<div class="jumbotron">
|
||||
<center><h1>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</h1></center> <!-- document title -->
|
||||
<center>
|
||||
<h1>Week 35: From Ordinary Linear Regression to Ridge and Lasso Regression</h1>
|
||||
</center> <!-- document title -->
|
||||
|
||||
<p>
|
||||
<!-- author(s): Morten Hjorth-Jensen -->
|
||||
|
||||
<center>
|
||||
<b>Morten Hjorth-Jensen</b> [1, 2]
|
||||
</center>
|
||||
|
||||
<p>
|
||||
<!-- institution(s) -->
|
||||
<center>
|
||||
[1] <b>Department of Physics, University of Oslo</b>
|
||||
</center>
|
||||
<center>
|
||||
[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b>
|
||||
</center>
|
||||
<br>
|
||||
<center>
|
||||
<h4>Nov 3, 2021</h4>
|
||||
</center> <!-- date -->
|
||||
<br>
|
||||
|
||||
<center>[1] <b>Department of Physics, University of Oslo</b></center>
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p>
|
||||
<center><h4>Sep 28, 2021</h4></center> <!-- date -->
|
||||
<br>
|
||||
<p>
|
||||
|
||||
|
||||
<p><a href="._week35-bs001.html" class="btn btn-primary btn-lg">Read »</a></p>
|
||||
@@ -434,25 +422,18 @@ MathJax.Hub.Config({
|
||||
<li><a href="._week35-bs001.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright --> © 1999-2021, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
+1307
-839
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+1241
-815
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+1884
-626
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,36 +258,32 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0000"></a>
|
||||
<!-- ------------------- main content ---------------------- -->
|
||||
|
||||
|
||||
|
||||
<div class="jumbotron">
|
||||
<center><h1>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</h1></center> <!-- document title -->
|
||||
<center>
|
||||
<h1>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</h1>
|
||||
</center> <!-- document title -->
|
||||
|
||||
<p>
|
||||
<!-- author(s): Morten Hjorth-Jensen -->
|
||||
|
||||
<center>
|
||||
<b>Morten Hjorth-Jensen</b> [1, 2]
|
||||
</center>
|
||||
|
||||
<p>
|
||||
<!-- institution(s) -->
|
||||
<center>
|
||||
[1] <b>Department of Physics, University of Oslo</b>
|
||||
</center>
|
||||
<center>
|
||||
[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b>
|
||||
</center>
|
||||
<br>
|
||||
<center>
|
||||
<h4>Nov 3, 2021</h4>
|
||||
</center> <!-- date -->
|
||||
<br>
|
||||
|
||||
<center>[1] <b>Department of Physics, University of Oslo</b></center>
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p>
|
||||
<center><h4>Sep 16, 2021</h4></center> <!-- date -->
|
||||
<br>
|
||||
<p>
|
||||
|
||||
|
||||
<p><a href="._week36-bs001.html" class="btn btn-primary btn-lg">Read »</a></p>
|
||||
@@ -313,29 +305,22 @@ 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-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs001.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright --> © 1999-2021, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,29 +258,22 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0001"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="plans-for-week-36" class="anchor">Plans for week 36 </h2>
|
||||
|
||||
<ul>
|
||||
<li> Thursday: Summary from last week on SVD, Statistics, probability theory and linear regression. <a href="https://www.uio.no/studier/emner/matnat/fys/FYS-STK3155/h21/forelesningsvideoer/LectureSeptember9.mp4?vrtx=view-as-webpage" target="_self">Video of Lecture</a>.</li>
|
||||
<li> Friday: Linear Regression and links with Statistics, Resampling methods and presentation of first project. <a href="https://www.uio.no/studier/emner/matnat/fys/FYS-STK4155/h21/forelesningsvideoer/LectureSeptember10.mp4?vrtx=view-as-webpage" target="_self">Video of Lecture</a></li>
|
||||
</ul>
|
||||
|
||||
Recommended Reading:
|
||||
|
||||
<p>Recommended Reading:</p>
|
||||
<ol>
|
||||
<li> Lectures on Regression</li>
|
||||
<li> Bishop 1.1, 1.2, 2.1, 2.2, 2.3 and 3.1</li>
|
||||
<li> Hastie et al chapter 3</li>
|
||||
</ol>
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -301,29 +290,22 @@ Recommended Reading:
|
||||
<li><a href="._week36-bs009.html">10</a></li>
|
||||
<li><a href="._week36-bs010.html">11</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs002.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,17 +258,12 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0002"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="thursday-september-9" class="anchor">Thursday September 9 </h2>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -290,29 +281,22 @@ MathJax.Hub.Config({
|
||||
<li><a href="._week36-bs010.html">11</a></li>
|
||||
<li><a href="._week36-bs011.html">12</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs003.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,17 +258,12 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0003"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="summary-from-last-week-and-examples" class="anchor">Summary from last Week and Examples </h2>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -291,29 +282,22 @@ MathJax.Hub.Config({
|
||||
<li><a href="._week36-bs011.html">12</a></li>
|
||||
<li><a href="._week36-bs012.html">13</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs004.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,28 +258,23 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0004"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="linear-regression-and-the-svd" class="anchor">Linear Regression and the SVD </h2>
|
||||
|
||||
<p>
|
||||
We used the SVD to analyse the matrix to invert in ordinary lineat regression
|
||||
<p>We used the SVD to analyse the matrix to invert in ordinary lineat regression</p>
|
||||
$$
|
||||
\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 last week the matrix
|
||||
<p>Since the matrices here have dimension \( p\times p \), with \( p \) corresponding to the singular values, we defined last week the matrix</p>
|
||||
$$
|
||||
\boldsymbol{\Sigma}^T\boldsymbol{\Sigma} = \begin{bmatrix} \tilde{\boldsymbol{\Sigma}} & \boldsymbol{0}\\ \end{bmatrix}\begin{bmatrix} \tilde{\boldsymbol{\Sigma}} \\ \boldsymbol{0}\end{bmatrix},
|
||||
$$
|
||||
|
||||
where the tilde-matrix \( \tilde{\boldsymbol{\Sigma}} \) is a matrix of dimension \( p\times p \) containing only the singular values \( \sigma_i \), that is
|
||||
<p>where the tilde-matrix \( \tilde{\boldsymbol{\Sigma}} \) is a matrix of dimension \( p\times p \) containing only the singular values \( \sigma_i \), that is</p>
|
||||
|
||||
$$
|
||||
\tilde{\boldsymbol{\Sigma}}=\begin{bmatrix} \sigma_0 & 0 & 0 & \dots & 0 & 0 \\
|
||||
@@ -294,17 +285,17 @@ $$
|
||||
\end{bmatrix},
|
||||
$$
|
||||
|
||||
meaning we can write
|
||||
<p>meaning we can write</p>
|
||||
$$
|
||||
\boldsymbol{X}^T\boldsymbol{X}=\boldsymbol{V}\tilde{\boldsymbol{\Sigma}}^2\boldsymbol{V}^T.
|
||||
$$
|
||||
|
||||
Multiplying from the right with \( \boldsymbol{V} \) (using the orthogonality of \( \boldsymbol{V} \)) we get
|
||||
<p>Multiplying from the right with \( \boldsymbol{V} \) (using the orthogonality of \( \boldsymbol{V} \)) we get</p>
|
||||
$$
|
||||
\left(\boldsymbol{X}^T\boldsymbol{X}\right)\boldsymbol{V}=\boldsymbol{V}\tilde{\boldsymbol{\Sigma}}^2.
|
||||
$$
|
||||
|
||||
<p>
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -324,29 +315,22 @@ $$
|
||||
<li><a href="._week36-bs012.html">13</a></li>
|
||||
<li><a href="._week36-bs013.html">14</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs005.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,55 +258,50 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0005"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="what-does-it-mean" class="anchor">What does it mean? </h2>
|
||||
|
||||
<p>
|
||||
This means the vectors \( \boldsymbol{v}_i \) of the orthogonal matrix \( \boldsymbol{V} \)
|
||||
<p>This means the vectors \( \boldsymbol{v}_i \) of the orthogonal matrix \( \boldsymbol{V} \)
|
||||
are the eigenvectors of the matrix \( \boldsymbol{X}^T\boldsymbol{X} \) with eigenvalues
|
||||
given by the singular values squared, that is
|
||||
</p>
|
||||
|
||||
$$
|
||||
\left(\boldsymbol{X}^T\boldsymbol{X}\right)\boldsymbol{v}_i=\boldsymbol{v}_i\sigma_i^2.
|
||||
$$
|
||||
|
||||
<p>
|
||||
In other words, each non-zero singular value of \( \boldsymbol{X} \) is a positive
|
||||
<p>In other words, each non-zero singular value of \( \boldsymbol{X} \) is a positive
|
||||
square root of an eigenvalue of \( \boldsymbol{X}^T\boldsymbol{X} \). It means also that
|
||||
the columns of \( \boldsymbol{V} \) are the eigenvectors of
|
||||
\( \boldsymbol{X}^T\boldsymbol{X} \). Since we have ordered the singular values of
|
||||
\( \boldsymbol{X} \) in a descending order, it means that the column vectors
|
||||
\( \boldsymbol{v}_i \) are hierarchically ordered by how much correlation they
|
||||
encode from the columns of \( \boldsymbol{X} \).
|
||||
encode from the columns of \( \boldsymbol{X} \).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Note that these are also the eigenvectors and eigenvalues of the
|
||||
<p>Note that these are also the eigenvectors and eigenvalues of the
|
||||
Hessian matrix.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If we now recall the definition of the covariance matrix (not using
|
||||
<p>If we now recall the definition of the covariance matrix (not using
|
||||
Bessel's correction) we have
|
||||
</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{C}[\boldsymbol{X}]=\frac{1}{n}\boldsymbol{X}^T\boldsymbol{X},
|
||||
$$
|
||||
|
||||
<p>
|
||||
meaning that every squared non-singular value of \( \boldsymbol{X} \) divided by \( n \) (
|
||||
<p>meaning that every squared non-singular value of \( \boldsymbol{X} \) divided by \( n \) (
|
||||
the number of samples) are the eigenvalues of the covariance
|
||||
matrix. Every singular value of \( \boldsymbol{X} \) is thus a positive square
|
||||
root of an eigenvalue of \( \boldsymbol{X}^T\boldsymbol{X} \). If the matrix \( \boldsymbol{X} \) is
|
||||
self-adjoint, the singular values of \( \boldsymbol{X} \) are equal to the
|
||||
absolute value of the eigenvalues of \( \boldsymbol{X} \).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -331,29 +322,22 @@ absolute value of the eigenvalues of \( \boldsymbol{X} \).
|
||||
<li><a href="._week36-bs013.html">14</a></li>
|
||||
<li><a href="._week36-bs014.html">15</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs006.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,51 +258,44 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0006"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="and-finally-boldsymbol-x-boldsymbol-x-t" class="anchor">And finally \( \boldsymbol{X}\boldsymbol{X}^T \) </h2>
|
||||
|
||||
<p>
|
||||
For \( \boldsymbol{X}\boldsymbol{X}^T \) we found
|
||||
<p>For \( \boldsymbol{X}\boldsymbol{X}^T \) we found</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{X}\boldsymbol{X}^T=\boldsymbol{U}\boldsymbol{\Sigma}\boldsymbol{V}^T\boldsymbol{V}\boldsymbol{\Sigma}^T\boldsymbol{U}^T=\boldsymbol{U}\boldsymbol{\Sigma}^T\boldsymbol{\Sigma}\boldsymbol{U}^T.
|
||||
$$
|
||||
|
||||
Since the matrices here have dimension \( n\times n \), we have
|
||||
<p>Since the matrices here have dimension \( n\times n \), we have</p>
|
||||
$$
|
||||
\boldsymbol{\Sigma}\boldsymbol{\Sigma}^T = \begin{bmatrix} \tilde{\boldsymbol{\Sigma}} \\ \boldsymbol{0}\\ \end{bmatrix}\begin{bmatrix} \tilde{\boldsymbol{\Sigma}} \boldsymbol{0}\\ \end{bmatrix}=\begin{bmatrix} \tilde{\boldsymbol{\Sigma}} & \boldsymbol{0} \\ \boldsymbol{0} & \boldsymbol{0}\\ \end{bmatrix},
|
||||
$$
|
||||
|
||||
leading to
|
||||
<p>leading to</p>
|
||||
$$
|
||||
\boldsymbol{X}\boldsymbol{X}^T=\boldsymbol{U}\begin{bmatrix} \tilde{\boldsymbol{\Sigma}} & \boldsymbol{0} \\ \boldsymbol{0} & \boldsymbol{0}\\ \end{bmatrix}\boldsymbol{U}^T.
|
||||
$$
|
||||
|
||||
<p>
|
||||
Multiplying with \( \boldsymbol{U} \) from the right gives us the eigenvalue problem
|
||||
<p>Multiplying with \( \boldsymbol{U} \) from the right gives us the eigenvalue problem</p>
|
||||
$$
|
||||
(\boldsymbol{X}\boldsymbol{X}^T)\boldsymbol{U}=\boldsymbol{U}\begin{bmatrix} \tilde{\boldsymbol{\Sigma}} & \boldsymbol{0} \\ \boldsymbol{0} & \boldsymbol{0}\\ \end{bmatrix}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
It means that the eigenvalues of \( \boldsymbol{X}\boldsymbol{X}^T \) are again given by
|
||||
<p>It means that the eigenvalues of \( \boldsymbol{X}\boldsymbol{X}^T \) are again given by
|
||||
the non-zero singular values plus now a series of zeros. The column
|
||||
vectors of \( \boldsymbol{U} \) are the eigenvectors of \( \boldsymbol{X}\boldsymbol{X}^T \) and
|
||||
measure how much correlations are contained in the rows of \( \boldsymbol{X} \).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Since we will mainly be interested in the correlations among the features
|
||||
<p>Since we will mainly be interested in the correlations among the features
|
||||
of our data (the columns of \( \boldsymbol{X} \), the quantity of interest for us are the non-zero singular
|
||||
values and the column vectors of \( \boldsymbol{V} \).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -328,29 +317,22 @@ values and the column vectors of \( \boldsymbol{V} \).
|
||||
<li><a href="._week36-bs014.html">15</a></li>
|
||||
<li><a href="._week36-bs015.html">16</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs007.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,31 +258,48 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0007"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="code-for-svd-and-inversion-of-matrices" class="anchor">Code for SVD and Inversion of Matrices </h2>
|
||||
|
||||
<p>
|
||||
How do we use the SVD to invert a matrix \( \boldsymbol{X}^\boldsymbol{X} \) which is singular or near singular?
|
||||
<p>How do we use the SVD to invert a matrix \( \boldsymbol{X}^\boldsymbol{X} \) which is singular or near singular?
|
||||
The simple answer is to use the linear algebra function for pseudoinvers, that is
|
||||
<p>
|
||||
</p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span>Ainv <span style="color: #666666">=</span> np<span style="color: #666666">.</span>linlag<span style="color: #666666">.</span>pinv(A)
|
||||
</pre></div>
|
||||
<p>
|
||||
Let us first look at a matrix which does not causes problems and write our own function where we just use the SVD.
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;">Ainv <span style="color: #666666">=</span> np<span style="color: #666666">.</span>linlag<span style="color: #666666">.</span>pinv(A)
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>Let us first look at a matrix which does not causes problems and write our own function where we just use the SVD.</p>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<span style="color: #408080; font-style: italic"># SVD inversion</span>
|
||||
<span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">SVDinv</span>(A):
|
||||
<span style="color: #BA2121; font-style: italic">''' Takes as input a numpy matrix A and returns inv(A) based on singular value decomposition (SVD).</span>
|
||||
@@ -315,8 +328,22 @@ A <span style="color: #666666">=</span> np<span style="color: #666666">.</span>t
|
||||
B <span style="color: #666666">=</span> np<span style="color: #666666">.</span>linalg<span style="color: #666666">.</span>inv(A) <span style="color: #408080; font-style: italic"># here we could use np.linalg.pinv(A)</span>
|
||||
C <span style="color: #666666">=</span> SVDinv(A)
|
||||
<span style="color: #008000">print</span>(np<span style="color: #666666">.</span>abs(B<span style="color: #666666">-</span>C))
|
||||
</pre></div>
|
||||
<p>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -339,29 +366,22 @@ C <span style="color: #666666">=</span> SVDinv(A)
|
||||
<li><a href="._week36-bs015.html">16</a></li>
|
||||
<li><a href="._week36-bs016.html">17</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs008.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,39 +258,37 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0008"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="inverse-of-rectangular-matrix" class="anchor">Inverse of Rectangular Matrix </h2>
|
||||
|
||||
<p>
|
||||
Although our matrix to invert \( \boldsymbol{X}^T\boldsymbol{X} \) is a square matrix, our matrix may be singular.
|
||||
<p>Although our matrix to invert \( \boldsymbol{X}^T\boldsymbol{X} \) is a square matrix, our matrix may be singular. </p>
|
||||
|
||||
<p>
|
||||
The pseudoinverse is the generalization of the matrix inverse for square matrices to
|
||||
<p>The pseudoinverse is the generalization of the matrix inverse for square matrices to
|
||||
rectangular matrices where the number of rows and columns are not equal.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
It is also called the the Moore-Penrose Inverse after two independent discoverers of the method or the Generalized Inverse.
|
||||
<p>It is also called the the Moore-Penrose Inverse after two independent discoverers of the method or the Generalized Inverse.
|
||||
It is used for the calculation of the inverse for singular or near singular matrices and for rectangular matrices.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Using the SVD we can obtain the pseudoinverse of a matrix \( \boldsymbol{A} \) (labeled here as \( \boldsymbol{A}_{\mathrm{PI}} \))
|
||||
<p>Using the SVD we can obtain the pseudoinverse of a matrix \( \boldsymbol{A} \) (labeled here as \( \boldsymbol{A}_{\mathrm{PI}} \))</p>
|
||||
$$
|
||||
\boldsymbol{A}_{\mathrm{PI}}= \boldsymbol{V}\boldsymbol{D}_{\mathrm{PI}}\boldsymbol{U}^T,
|
||||
$$
|
||||
|
||||
where \( \boldsymbol{D}_{\mathrm{PI}} \) can be calculated by creating a diagonal matrix from \( \boldsymbol{\Sigma} \) where we only keep the singular values (the non-zero values). The following code computes the pseudoinvers of the matrix based on the SVD.
|
||||
<p>where \( \boldsymbol{D}_{\mathrm{PI}} \) can be calculated by creating a diagonal matrix from \( \boldsymbol{\Sigma} \) where we only keep the singular values (the non-zero values). The following code computes the pseudoinvers of the matrix based on the SVD.</p>
|
||||
|
||||
<p>
|
||||
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%;"><span></span><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<div class="cell border-box-sizing code_cell rendered">
|
||||
<div class="input">
|
||||
<div class="inner_cell">
|
||||
<div class="input_area">
|
||||
<div class="highlight" style="background: #f8f8f8">
|
||||
<pre style="line-height: 125%;"><span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<span style="color: #408080; font-style: italic"># SVD inversion</span>
|
||||
<span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">SVDinv</span>(A):
|
||||
U, s, VT <span style="color: #666666">=</span> np<span style="color: #666666">.</span>linalg<span style="color: #666666">.</span>svd(A)
|
||||
@@ -317,11 +311,23 @@ B <span style="color: #666666">=</span> np<span style="color: #666666">.</span>l
|
||||
<span style="color: #408080; font-style: italic"># Compare our own algorithm with pinv</span>
|
||||
C <span style="color: #666666">=</span> SVDinv(A)
|
||||
<span style="color: #008000">print</span>(np<span style="color: #666666">.</span>abs(C<span style="color: #666666">-</span>B))
|
||||
</pre></div>
|
||||
<p>
|
||||
As you can see from this example, our own decomposition based on the SVD agrees the pseudoinverse algorithm provided by <b>Numpy</b>.
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="output_wrapper">
|
||||
<div class="output">
|
||||
<div class="output_area">
|
||||
<div class="output_subarea output_stream output_stdout output_text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>As you can see from this example, our own decomposition based on the SVD agrees the pseudoinverse algorithm provided by <b>Numpy</b>.</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -345,29 +351,22 @@ As you can see from this example, our own decomposition based on the SVD agrees
|
||||
<li><a href="._week36-bs016.html">17</a></li>
|
||||
<li><a href="._week36-bs017.html">18</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs009.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,35 +258,31 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0009"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="ridge-and-lasso-regression" class="anchor">Ridge and LASSO Regression </h2>
|
||||
|
||||
<p>
|
||||
Let us remind ourselves about the expression for the standard Mean Squared Error (MSE) which we used to define our cost function and the equations for the ordinary least squares (OLS) method, that is
|
||||
<p>Let us remind ourselves about the expression for the standard Mean Squared Error (MSE) which we used to define our cost function and the equations for the ordinary least squares (OLS) method, that is
|
||||
our optimization problem is
|
||||
</p>
|
||||
$$
|
||||
{\displaystyle \min_{\boldsymbol{\beta}\in {\mathbb{R}}^{p}}}\frac{1}{n}\left\{\left(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\right)^T\left(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\right)\right\}.
|
||||
$$
|
||||
|
||||
or we can state it as
|
||||
<p>or we can state it as</p>
|
||||
$$
|
||||
{\displaystyle \min_{\boldsymbol{\beta}\in
|
||||
{\mathbb{R}}^{p}}}\frac{1}{n}\sum_{i=0}^{n-1}\left(y_i-\tilde{y}_i\right)^2=\frac{1}{n}\vert\vert \boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\vert\vert_2^2,
|
||||
$$
|
||||
|
||||
where we have used the definition of a norm-2 vector, that is
|
||||
<p>where we have used the definition of a norm-2 vector, that is</p>
|
||||
$$
|
||||
\vert\vert \boldsymbol{x}\vert\vert_2 = \sqrt{\sum_i x_i^2}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -315,29 +307,22 @@ $$
|
||||
<li><a href="._week36-bs017.html">18</a></li>
|
||||
<li><a href="._week36-bs018.html">19</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs010.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#from-ols-to-ridge-and-lasso" style="font-size: 80%;">From OLS to Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,52 +258,46 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0010"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="from-ols-to-ridge-and-lasso" class="anchor">From OLS to Ridge and Lasso </h2>
|
||||
|
||||
<p>
|
||||
By minimizing the above equation with respect to the parameters
|
||||
<p>By minimizing the above equation with respect to the parameters
|
||||
\( \boldsymbol{\beta} \) we could then obtain an analytical expression for the
|
||||
parameters \( \boldsymbol{\beta} \). We can add a regularization parameter \( \lambda \) by
|
||||
defining a new cost function to be optimized, that is
|
||||
</p>
|
||||
|
||||
$$
|
||||
{\displaystyle \min_{\boldsymbol{\beta}\in
|
||||
{\mathbb{R}}^{p}}}\frac{1}{n}\vert\vert \boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\vert\vert_2^2+\lambda\vert\vert \boldsymbol{\beta}\vert\vert_2^2
|
||||
$$
|
||||
|
||||
<p>
|
||||
which leads to the Ridge regression minimization problem where we
|
||||
<p>which leads to the Ridge regression minimization problem where we
|
||||
require that \( \vert\vert \boldsymbol{\beta}\vert\vert_2^2\le t \), where \( t \) is
|
||||
a finite number larger than zero. By defining
|
||||
</p>
|
||||
|
||||
$$
|
||||
C(\boldsymbol{X},\boldsymbol{\beta})=\frac{1}{n}\vert\vert \boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\vert\vert_2^2+\lambda\vert\vert \boldsymbol{\beta}\vert\vert_1,
|
||||
$$
|
||||
|
||||
<p>
|
||||
we have a new optimization equation
|
||||
<p>we have a new optimization equation</p>
|
||||
$$
|
||||
{\displaystyle \min_{\boldsymbol{\beta}\in
|
||||
{\mathbb{R}}^{p}}}\frac{1}{n}\vert\vert \boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta}\vert\vert_2^2+\lambda\vert\vert \boldsymbol{\beta}\vert\vert_1
|
||||
$$
|
||||
|
||||
which leads to Lasso regression. Lasso stands for least absolute shrinkage and selection operator.
|
||||
<p>which leads to Lasso regression. Lasso stands for least absolute shrinkage and selection operator. </p>
|
||||
|
||||
<p>
|
||||
Here we have defined the norm-1 as
|
||||
<p>Here we have defined the norm-1 as </p>
|
||||
$$
|
||||
\vert\vert \boldsymbol{x}\vert\vert_1 = \sum_i \vert x_i\vert.
|
||||
$$
|
||||
|
||||
<p>
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -333,29 +323,22 @@ $$
|
||||
<li><a href="._week36-bs018.html">19</a></li>
|
||||
<li><a href="._week36-bs019.html">20</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs011.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.html#from-ols-to-ridge-and-lasso" style="font-size: 80%;">From OLS to Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,58 +258,36 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0011"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="deriving-the-ridge-regression-equations" class="anchor">Deriving the Ridge Regression Equations </h2>
|
||||
|
||||
<p>
|
||||
Using the matrix-vector expression for Ridge regression and dropping the parameter \( 1/n \) in front of the standard means squared error equation, we have
|
||||
<p>Using the matrix-vector expression for Ridge regression and dropping the parameter \( 1/n \) in front of the standard means squared error equation, we have</p>
|
||||
|
||||
$$
|
||||
C(\boldsymbol{X},\boldsymbol{\beta})=\left\{(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})^T(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})\right\}+\lambda\boldsymbol{\beta}^T\boldsymbol{\beta},
|
||||
$$
|
||||
|
||||
and
|
||||
<p>and
|
||||
taking the derivatives with respect to \( \boldsymbol{\beta} \) we obtain then
|
||||
a slightly modified matrix inversion problem which for finite values
|
||||
of \( \lambda \) does not suffer from singularity problems. We obtain
|
||||
the optimal parameters
|
||||
</p>
|
||||
$$
|
||||
\hat{\boldsymbol{\beta}}_{\mathrm{Ridge}} = \left(\boldsymbol{X}^T\boldsymbol{X}+\lambda\boldsymbol{I}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y},
|
||||
$$
|
||||
|
||||
<p>
|
||||
with \( \boldsymbol{I} \) being a \( p\times p \) identity matrix with the constraint that
|
||||
<p>with \( \boldsymbol{I} \) being a \( p\times p \) identity matrix with the constraint that</p>
|
||||
|
||||
$$
|
||||
\sum_{i=0}^{p-1} \beta_i^2 \leq t,
|
||||
$$
|
||||
|
||||
<p>
|
||||
with \( t \) a finite positive number.
|
||||
<p>with \( t \) a finite positive number. </p>
|
||||
|
||||
<p>
|
||||
When we compare this with the ordinary least squares result we have
|
||||
$$
|
||||
\hat{\boldsymbol{\beta}}_{\mathrm{OLS}} = \left(\boldsymbol{X}^T\boldsymbol{X}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y},
|
||||
$$
|
||||
|
||||
which can lead to singular matrices. However, with the SVD, we can always compute the inverse of the matrix \( \boldsymbol{X}^T\boldsymbol{X} \).
|
||||
|
||||
<p>
|
||||
We see that Ridge regression is nothing but the standard OLS with a
|
||||
modified diagonal term added to \( \boldsymbol{X}^T\boldsymbol{X} \). The consequences, in
|
||||
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>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -339,29 +313,22 @@ even reduce the variance of the optimal parameters \( \boldsymbol{\beta} \). The
|
||||
<li><a href="._week36-bs019.html">20</a></li>
|
||||
<li><a href="._week36-bs020.html">21</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs012.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,34 +258,20 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0012"></a>
|
||||
<!-- !split -->
|
||||
<h2 id="note-on-scikit-learn" class="anchor">Note on Scikit-Learn </h2>
|
||||
|
||||
<h2 id="svd-analysis" class="anchor">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
|
||||
$$
|
||||
\tilde{\boldsymbol{y}}_{\mathrm{OLS}}=\boldsymbol{X}\boldsymbol{\beta} =\boldsymbol{U}\boldsymbol{U}^T\boldsymbol{y}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
For Ridge regression this becomes
|
||||
<p>Note well that a library like <b>Scikit-Learn</b> does not include the \( 1/n \) factor in the expression for the mean-squared error. If you include it, the optimal parameter \( \beta \) becomes</p>
|
||||
|
||||
$$
|
||||
\tilde{\boldsymbol{y}}_{\mathrm{Ridge}}=\boldsymbol{X}\boldsymbol{\beta}_{\mathrm{Ridge}} = \boldsymbol{U\Sigma V^T}\left(\boldsymbol{V}\boldsymbol{\Sigma}^2\boldsymbol{V}^T+\lambda\boldsymbol{I} \right)^{-1}(\boldsymbol{U\Sigma V^T})^T\boldsymbol{y}=\sum_{j=0}^{p-1}\boldsymbol{u}_j\boldsymbol{u}_j^T\frac{\sigma_j^2}{\sigma_j^2+\lambda}\boldsymbol{y},
|
||||
\hat{\boldsymbol{\beta}}_{\mathrm{Ridge}} = \left(\boldsymbol{X}^T\boldsymbol{X}+n\lambda\boldsymbol{I}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
with the vectors \( \boldsymbol{u}_j \) being the columns of \( \boldsymbol{U} \) from the SVD of the matrix \( \boldsymbol{X} \).
|
||||
<p>In our codes where we compare our own codes with <b>Scikit-Learn</b>, we do thus not include the \( 1/n \) factor in the cost function.</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -315,29 +297,22 @@ with the vectors \( \boldsymbol{u}_j \) being the columns of \( \boldsymbol{U} \
|
||||
<li><a href="._week36-bs020.html">21</a></li>
|
||||
<li><a href="._week36-bs021.html">22</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs013.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,34 +258,25 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0013"></a>
|
||||
<!-- !split -->
|
||||
|
||||
<h2 id="interpreting-the-ridge-results" class="anchor">Interpreting the Ridge results </h2>
|
||||
|
||||
<p>
|
||||
Since \( \lambda \geq 0 \), it means that compared to OLS, we have
|
||||
|
||||
<h2 id="comparison-with-ols" class="anchor">Comparison with OLS </h2>
|
||||
<p>When we compare this with the ordinary least squares result we have</p>
|
||||
$$
|
||||
\frac{\sigma_j^2}{\sigma_j^2+\lambda} \leq 1.
|
||||
\hat{\boldsymbol{\beta}}_{\mathrm{OLS}} = \left(\boldsymbol{X}^T\boldsymbol{X}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y},
|
||||
$$
|
||||
|
||||
<p>
|
||||
Ridge regression finds the coordinates of \( \boldsymbol{y} \) with respect to the
|
||||
orthonormal basis \( \boldsymbol{U} \), it then shrinks the coordinates by
|
||||
\( \frac{\sigma_j^2}{\sigma_j^2+\lambda} \). Recall that the SVD has
|
||||
eigenvalues ordered in a descending way, that is \( \sigma_i \geq
|
||||
\sigma_{i+1} \).
|
||||
<p>which can lead to singular matrices. However, with the SVD, we can always compute the inverse of the matrix \( \boldsymbol{X}^T\boldsymbol{X} \).</p>
|
||||
|
||||
<p>
|
||||
For small eigenvalues \( \sigma_i \) it means that their contributions become less important, a fact which can be used to reduce the number of degrees of freedom. More about this when we have covered the material on a statistical interpretation of various linear regression methods.
|
||||
<p>We see that Ridge regression is nothing but the standard OLS with a
|
||||
modified diagonal term added to \( \boldsymbol{X}^T\boldsymbol{X} \). The consequences, in
|
||||
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>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -315,29 +302,22 @@ For small eigenvalues \( \sigma_i \) it means that their contributions become le
|
||||
<li><a href="._week36-bs021.html">22</a></li>
|
||||
<li><a href="._week36-bs022.html">23</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs014.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,49 +258,27 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0014"></a>
|
||||
<!-- !split -->
|
||||
<h2 id="svd-analysis" class="anchor">SVD analysis </h2>
|
||||
|
||||
<h2 id="more-interpretations" class="anchor">More interpretations </h2>
|
||||
|
||||
<p>
|
||||
For the sake of simplicity, let us assume that the design matrix is orthonormal, that is
|
||||
|
||||
<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
|
||||
</p>
|
||||
$$
|
||||
\boldsymbol{X}^T\boldsymbol{X}=(\boldsymbol{X}^T\boldsymbol{X})^{-1} =\boldsymbol{I}.
|
||||
\tilde{\boldsymbol{y}}_{\mathrm{OLS}}=\boldsymbol{X}\boldsymbol{\beta} =\boldsymbol{U}\boldsymbol{U}^T\boldsymbol{y}.
|
||||
$$
|
||||
|
||||
<p>
|
||||
In this case the standard OLS results in
|
||||
$$
|
||||
\boldsymbol{\beta}^{\mathrm{OLS}} = \boldsymbol{X}^T\boldsymbol{y}=\sum_{i=0}^{p-1}\boldsymbol{u}_j\boldsymbol{u}_j^T\boldsymbol{y},
|
||||
$$
|
||||
|
||||
<p>
|
||||
and
|
||||
<p>For Ridge regression this becomes</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{\beta}^{\mathrm{Ridge}} = \left(\boldsymbol{I}+\lambda\boldsymbol{I}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y}=\left(1+\lambda\right)^{-1}\boldsymbol{\beta}^{\mathrm{OLS}},
|
||||
\tilde{\boldsymbol{y}}_{\mathrm{Ridge}}=\boldsymbol{X}\boldsymbol{\beta}_{\mathrm{Ridge}} = \boldsymbol{U\Sigma V^T}\left(\boldsymbol{V}\boldsymbol{\Sigma}^2\boldsymbol{V}^T+\lambda\boldsymbol{I} \right)^{-1}(\boldsymbol{U\Sigma V^T})^T\boldsymbol{y}=\sum_{j=0}^{p-1}\boldsymbol{u}_j\boldsymbol{u}_j^T\frac{\sigma_j^2}{\sigma_j^2+\lambda}\boldsymbol{y},
|
||||
$$
|
||||
|
||||
<p>
|
||||
that is the Ridge estimator scales the OLS estimator by the inverse of a factor \( 1+\lambda \), and
|
||||
the Ridge estimator converges to zero when the hyperparameter goes to
|
||||
infinity.
|
||||
<p>with the vectors \( \boldsymbol{u}_j \) being the columns of \( \boldsymbol{U} \) from the SVD of the matrix \( \boldsymbol{X} \). </p>
|
||||
|
||||
<p>
|
||||
We will come back to more interpreations after we have gone through some of the statistical analysis part.
|
||||
|
||||
<p>
|
||||
For more discussions of Ridge and Lasso regression, <a href="https://arxiv.org/abs/1509.09169" target="_self">Wessel van Wieringen's</a> article is highly recommended.
|
||||
Similarly, <a href="https://arxiv.org/abs/1803.08823" target="_self">Mehta et al's article</a> is also recommended.
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -330,29 +304,22 @@ Similarly, <a href="https://arxiv.org/abs/1803.08823" target="_self">Mehta et al
|
||||
<li><a href="._week36-bs022.html">23</a></li>
|
||||
<li><a href="._week36-bs023.html">24</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs015.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,43 +258,27 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0015"></a>
|
||||
<!-- !split -->
|
||||
<h2 id="interpreting-the-ridge-results" class="anchor">Interpreting the Ridge results </h2>
|
||||
|
||||
<h2 id="deriving-the-lasso-regression-equations" class="anchor">Deriving the Lasso Regression Equations </h2>
|
||||
|
||||
<p>
|
||||
Using the matrix-vector expression for Lasso regression and dropping the parameter \( 1/n \) in front of the standard mean squared error equation, we have the following <b>cost</b> function
|
||||
<p>Since \( \lambda \geq 0 \), it means that compared to OLS, we have </p>
|
||||
|
||||
$$
|
||||
C(\boldsymbol{X},\boldsymbol{\beta})=\left\{(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})^T(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})\right\}+\lambda\vert\vert\boldsymbol{\beta}\vert\vert_1,
|
||||
\frac{\sigma_j^2}{\sigma_j^2+\lambda} \leq 1.
|
||||
$$
|
||||
|
||||
<p>
|
||||
Taking the derivative with respect to \( \boldsymbol{\beta} \) and recalling that the derivative of the absolute value is (we drop the boldfaced vector symbol for simplicty)
|
||||
$$
|
||||
\frac{d \vert \beta\vert}{d \boldsymbol{\beta}}=\mathrm{sgn}(\boldsymbol{\beta})=\left\{\begin{array}{cc} 1 & \beta > 0 \\ 0 & \beta =0\\-1 & \beta < 0, \end{array}\right.
|
||||
$$
|
||||
<p>Ridge regression finds the coordinates of \( \boldsymbol{y} \) with respect to the
|
||||
orthonormal basis \( \boldsymbol{U} \), it then shrinks the coordinates by
|
||||
\( \frac{\sigma_j^2}{\sigma_j^2+\lambda} \). Recall that the SVD has
|
||||
eigenvalues ordered in a descending way, that is \( \sigma_i \geq
|
||||
\sigma_{i+1} \).
|
||||
</p>
|
||||
|
||||
we have that the derivative of the cost function is
|
||||
<p>For small eigenvalues \( \sigma_i \) it means that their contributions become less important, a fact which can be used to reduce the number of degrees of freedom. More about this when we have covered the material on a statistical interpretation of various linear regression methods.</p>
|
||||
|
||||
$$
|
||||
\frac{\partial C(\boldsymbol{X},\boldsymbol{\beta})}{\partial \boldsymbol{\beta}}=-2\boldsymbol{X}^T(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})+\lambda sgn(\boldsymbol{\beta})=0,
|
||||
$$
|
||||
|
||||
and reordering we have
|
||||
$$
|
||||
\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="_self">CVXOPT</a>. We will discuss this later.
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -324,29 +304,22 @@ This equation does not lead to a nice analytical equation as in Ridge regression
|
||||
<li><a href="._week36-bs023.html">24</a></li>
|
||||
<li><a href="._week36-bs024.html">25</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs016.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,32 +258,40 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0016"></a>
|
||||
<!-- !split -->
|
||||
<h2 id="more-interpretations" class="anchor">More interpretations </h2>
|
||||
|
||||
<h2 id="simple-example-to-illustrate-ordinary-least-squares-ridge-and-lasso-regression" class="anchor">Simple example to illustrate Ordinary Least Squares, Ridge and Lasso Regression </h2>
|
||||
<p>For the sake of simplicity, let us assume that the design matrix is orthonormal, that is </p>
|
||||
|
||||
<p>
|
||||
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 \).
|
||||
|
||||
<p>
|
||||
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,
|
||||
\boldsymbol{X}^T\boldsymbol{X}=(\boldsymbol{X}^T\boldsymbol{X})^{-1} =\boldsymbol{I}.
|
||||
$$
|
||||
|
||||
and minimizing we have that
|
||||
<p>In this case the standard OLS results in </p>
|
||||
$$
|
||||
\hat{\beta}_i^{\mathrm{OLS}} = y_i.
|
||||
\boldsymbol{\beta}^{\mathrm{OLS}} = \boldsymbol{X}^T\boldsymbol{y}=\sum_{i=0}^{p-1}\boldsymbol{u}_j\boldsymbol{u}_j^T\boldsymbol{y},
|
||||
$$
|
||||
|
||||
<p>
|
||||
<p>and</p>
|
||||
|
||||
$$
|
||||
\boldsymbol{\beta}^{\mathrm{Ridge}} = \left(\boldsymbol{I}+\lambda\boldsymbol{I}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y}=\left(1+\lambda\right)^{-1}\boldsymbol{\beta}^{\mathrm{OLS}},
|
||||
$$
|
||||
|
||||
<p>that is the Ridge estimator scales the OLS estimator by the inverse of a factor \( 1+\lambda \), and
|
||||
the Ridge estimator converges to zero when the hyperparameter goes to
|
||||
infinity.
|
||||
</p>
|
||||
|
||||
<p>We will come back to more interpreations after we have gone through some of the statistical analysis part. </p>
|
||||
|
||||
<p>For more discussions of Ridge and Lasso regression, <a href="https://arxiv.org/abs/1509.09169" target="_self">Wessel van Wieringen's</a> article is highly recommended.
|
||||
Similarly, <a href="https://arxiv.org/abs/1803.08823" target="_self">Mehta et al's article</a> is also recommended.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -313,29 +317,22 @@ $$
|
||||
<li><a href="._week36-bs024.html">25</a></li>
|
||||
<li><a href="._week36-bs025.html">26</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs017.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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="#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,28 +258,36 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0017"></a>
|
||||
<!-- !split -->
|
||||
<h2 id="deriving-the-lasso-regression-equations" class="anchor">Deriving the Lasso Regression Equations </h2>
|
||||
|
||||
<h2 id="ridge-regression" class="anchor">Ridge Regression </h2>
|
||||
<p>Using the matrix-vector expression for Lasso regression and dropping the parameter \( 1/n \) in front of the standard mean squared error equation, we have the following <b>cost</b> function</p>
|
||||
|
||||
<p>
|
||||
For Ridge regression our cost function is
|
||||
$$
|
||||
C(\boldsymbol{\beta})=\sum_{i=0}^{p-1}(y_i-\beta_i)^2+\lambda\sum_{i=0}^{p-1}\beta_i^2,
|
||||
C(\boldsymbol{X},\boldsymbol{\beta})=\left\{(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})^T(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})\right\}+\lambda\vert\vert\boldsymbol{\beta}\vert\vert_1,
|
||||
$$
|
||||
|
||||
and minimizing we have that
|
||||
<p>Taking the derivative with respect to \( \boldsymbol{\beta} \) and recalling that the derivative of the absolute value is (we drop the boldfaced vector symbol for simplicty)</p>
|
||||
$$
|
||||
\hat{\beta}_i^{\mathrm{Ridge}} = \frac{y_i}{1+\lambda}.
|
||||
\frac{d \vert \beta\vert}{d \boldsymbol{\beta}}=\mathrm{sgn}(\boldsymbol{\beta})=\left\{\begin{array}{cc} 1 & \beta > 0 \\ 0 & \beta =0\\-1 & \beta < 0, \end{array}\right.
|
||||
$$
|
||||
|
||||
<p>
|
||||
<p>we have that the derivative of the cost function is</p>
|
||||
|
||||
$$
|
||||
\frac{\partial C(\boldsymbol{X},\boldsymbol{\beta})}{\partial \boldsymbol{\beta}}=-2\boldsymbol{X}^T(\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})+\lambda sgn(\boldsymbol{\beta})=0,
|
||||
$$
|
||||
|
||||
<p>and reordering we have</p>
|
||||
$$
|
||||
\boldsymbol{X}^T\boldsymbol{X}\boldsymbol{\beta}+\lambda sgn(\boldsymbol{\beta})=2\boldsymbol{X}^T\boldsymbol{y}.
|
||||
$$
|
||||
|
||||
<p>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="_self">CVXOPT</a>. We will discuss this later. </p>
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -309,29 +313,22 @@ $$
|
||||
<li><a href="._week36-bs025.html">26</a></li>
|
||||
<li><a href="._week36-bs026.html">27</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs018.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,38 +258,27 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0018"></a>
|
||||
<!-- !split -->
|
||||
<h2 id="simple-example-to-illustrate-ordinary-least-squares-ridge-and-lasso-regression" class="anchor">Simple example to illustrate Ordinary Least Squares, Ridge and Lasso Regression </h2>
|
||||
|
||||
<h2 id="lasso-regression" class="anchor">Lasso Regression </h2>
|
||||
<p>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 \).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For Lasso regression our cost function is
|
||||
<p>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>
|
||||
$$
|
||||
C(\boldsymbol{\beta})=\sum_{i=0}^{p-1}(y_i-\beta_i)^2+\lambda\sum_{i=0}^{p-1}\vert\beta_i\vert=\sum_{i=0}^{p-1}(y_i-\beta_i)^2+\lambda\sum_{i=0}^{p-1}\sqrt{\beta_i^2},
|
||||
C(\boldsymbol{\beta})=\sum_{i=0}^{p-1}(y_i-\beta_i)^2,
|
||||
$$
|
||||
|
||||
and minimizing we have that
|
||||
<p>and minimizing we have that</p>
|
||||
$$
|
||||
-2\sum_{i=0}^{p-1}(y_i-\beta_i)+\lambda \sum_{i=0}^{p-1}\frac{(\beta_i)}{\vert\beta_i\vert}=0,
|
||||
\hat{\beta}_i^{\mathrm{OLS}} = y_i.
|
||||
$$
|
||||
|
||||
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} & \vert y_i\vert\le \frac{\lambda}{2}\end{array}\right.\\.
|
||||
$$
|
||||
|
||||
<p>
|
||||
Plotting these results (<a href="https://github.com/CompPhysics/MachineLearning/blob/master/doc/HandWrittenNotes/2021/NotesSeptember9.pdf" target="_self">figure in handwritten notes for week 36</a>) shows clearly that Lasso regression suppresses (sets to zero) values of \( \beta_i \) for specific values of \( \lambda \). Ridge regression reduces on the other hand the values of \( \beta_i \) as function of \( \lambda \).
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -319,29 +304,22 @@ Plotting these results (<a href="https://github.com/CompPhysics/MachineLearning/
|
||||
<li><a href="._week36-bs026.html">27</a></li>
|
||||
<li><a href="._week36-bs027.html">28</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs019.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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="#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,31 +258,23 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0019"></a>
|
||||
<!-- !split -->
|
||||
<h2 id="ridge-regression" class="anchor">Ridge Regression </h2>
|
||||
|
||||
<h2 id="yet-another-example" class="anchor">Yet another Example </h2>
|
||||
|
||||
<p>
|
||||
Let us assume we have a data set with outputs/targets given by the vector
|
||||
|
||||
<p>For Ridge regression our cost function is</p>
|
||||
$$
|
||||
\boldsymbol{y}=\begin{bmatrix}4 \\ 2 \\3\end{bmatrix},
|
||||
C(\boldsymbol{\beta})=\sum_{i=0}^{p-1}(y_i-\beta_i)^2+\lambda\sum_{i=0}^{p-1}\beta_i^2,
|
||||
$$
|
||||
|
||||
and our inputs as a \( 3\times 2 \) design matrix
|
||||
<p>and minimizing we have that</p>
|
||||
$$
|
||||
\boldsymbol{X}=\begin{bmatrix}2 & 0\\ 0 & 1 \\ 0 & 0\end{bmatrix},
|
||||
\hat{\beta}_i^{\mathrm{Ridge}} = \frac{y_i}{1+\lambda}.
|
||||
$$
|
||||
|
||||
meaning that we have two features and two unknown parameters \( \beta_0 \) and \( \beta_1 \) to be determined either by ordinary least squares, Ridge or Lasso regression.
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -312,29 +300,22 @@ meaning that we have two features and two unknown parameters \( \beta_0 \) and \
|
||||
<li><a href="._week36-bs027.html">28</a></li>
|
||||
<li><a href="._week36-bs028.html">29</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs020.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,33 +258,31 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0020"></a>
|
||||
<!-- !split -->
|
||||
<h2 id="lasso-regression" class="anchor">Lasso Regression </h2>
|
||||
|
||||
<h2 id="the-ols-case" class="anchor">The OLS case </h2>
|
||||
|
||||
<p>
|
||||
For ordinary least squares (OLS) we know that the optimal solution is
|
||||
|
||||
<p>For Lasso regression our cost function is</p>
|
||||
$$
|
||||
\hat{\boldsymbol{\beta}}^{\mathrm{OLS}}=\left( \boldsymbol{X}^T\boldsymbol{X}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y}.
|
||||
C(\boldsymbol{\beta})=\sum_{i=0}^{p-1}(y_i-\beta_i)^2+\lambda\sum_{i=0}^{p-1}\vert\beta_i\vert=\sum_{i=0}^{p-1}(y_i-\beta_i)^2+\lambda\sum_{i=0}^{p-1}\sqrt{\beta_i^2},
|
||||
$$
|
||||
|
||||
Inserting the above values we obtain that
|
||||
|
||||
<p>and minimizing we have that</p>
|
||||
$$
|
||||
\hat{\boldsymbol{\beta}}^{\mathrm{OLS}}=\begin{bmatrix}2 \\ 2\end{bmatrix},
|
||||
-2\sum_{i=0}^{p-1}(y_i-\beta_i)+\lambda \sum_{i=0}^{p-1}\frac{(\beta_i)}{\vert\beta_i\vert}=0,
|
||||
$$
|
||||
|
||||
<p>
|
||||
The code which implements this simpler case is presented after the discussion of Ridge and Lasso.
|
||||
<p>which leads to </p>
|
||||
$$
|
||||
\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} & \vert y_i\vert\le \frac{\lambda}{2}\end{array}\right.\\.
|
||||
$$
|
||||
|
||||
<p>Plotting these results (<a href="https://github.com/CompPhysics/MachineLearning/blob/master/doc/HandWrittenNotes/2021/NotesSeptember9.pdf" target="_self">figure in handwritten notes for week 36</a>) shows clearly that Lasso regression suppresses (sets to zero) values of \( \beta_i \) for specific values of \( \lambda \). Ridge regression reduces on the other hand the values of \( \beta_i \) as function of \( \lambda \).</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -314,29 +308,22 @@ The code which implements this simpler case is presented after the discussion of
|
||||
<li><a href="._week36-bs028.html">29</a></li>
|
||||
<li><a href="._week36-bs029.html">30</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs021.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,37 +258,25 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0021"></a>
|
||||
<!-- !split -->
|
||||
<h2 id="yet-another-example" class="anchor">Yet another Example </h2>
|
||||
|
||||
<h2 id="the-ridge-case" class="anchor">The Ridge case </h2>
|
||||
|
||||
<p>
|
||||
For Ridge regression we have
|
||||
<p>Let us assume we have a data set with outputs/targets given by the vector</p>
|
||||
|
||||
$$
|
||||
\hat{\boldsymbol{\beta}}^{\mathrm{Ridge}}=\left( \boldsymbol{X}^T\boldsymbol{X}+\lambda\boldsymbol{I}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y}.
|
||||
\boldsymbol{y}=\begin{bmatrix}4 \\ 2 \\3\end{bmatrix},
|
||||
$$
|
||||
|
||||
Inserting the above values we obtain that
|
||||
|
||||
<p>and our inputs as a \( 3\times 2 \) design matrix</p>
|
||||
$$
|
||||
\hat{\boldsymbol{\beta}}^{\mathrm{Ridge}}=\begin{bmatrix}\frac{8}{4+\lambda} \\ \frac{2}{1+\lambda}\end{bmatrix},
|
||||
\boldsymbol{X}=\begin{bmatrix}2 & 0\\ 0 & 1 \\ 0 & 0\end{bmatrix},
|
||||
$$
|
||||
|
||||
<p>
|
||||
There is normally a constraint on the value of \( \vert\vert \boldsymbol{\beta}\vert\vert_2 \) via the parameter \( \lambda \).
|
||||
Let us for simplicity assume that \( \beta_0^2+\beta_1^2=1 \) as constraint. This will allow us to find an expression for the optimal values of \( \beta \) and \( \lambda \).
|
||||
<p>meaning that we have two features and two unknown parameters \( \beta_0 \) and \( \beta_1 \) to be determined either by ordinary least squares, Ridge or Lasso regression.</p>
|
||||
|
||||
<p>
|
||||
To see this, let us write the cost function for Ridge regression.
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -318,29 +302,22 @@ To see this, let us write the cost function for Ridge regression.
|
||||
<li><a href="._week36-bs029.html">30</a></li>
|
||||
<li><a href="._week36-bs030.html">31</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs022.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs023.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,46 +258,26 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0022"></a>
|
||||
<!-- !split -->
|
||||
<h2 id="the-ols-case" class="anchor">The OLS case </h2>
|
||||
|
||||
<h2 id="writing-the-cost-function" class="anchor">Writing the Cost Function </h2>
|
||||
|
||||
<p>
|
||||
We define the MSE without the \( 1/n \) factor and have then, using that
|
||||
$$
|
||||
\boldsymbol{X}\boldsymbol{\beta}=\begin{bmatrix} 2\beta_0 \\ \beta_1 \\0 \end{bmatrix},
|
||||
$$
|
||||
|
||||
<p>For ordinary least squares (OLS) we know that the optimal solution is</p>
|
||||
|
||||
$$
|
||||
C(\boldsymbol{\beta})=(4-2\beta_0)^2+(2-\beta_1)^2+\lambda(\beta_0^2+\beta_1^2),
|
||||
\hat{\boldsymbol{\beta}}^{\mathrm{OLS}}=\left( \boldsymbol{X}^T\boldsymbol{X}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y}.
|
||||
$$
|
||||
|
||||
and taking the derivative with respect to \( \beta_0 \) we get
|
||||
<p>Inserting the above values we obtain that </p>
|
||||
|
||||
$$
|
||||
\beta_0=\frac{8}{4+\lambda},
|
||||
\hat{\boldsymbol{\beta}}^{\mathrm{OLS}}=\begin{bmatrix}2 \\ 2\end{bmatrix},
|
||||
$$
|
||||
|
||||
and for \( \beta_1 \) we obtain
|
||||
$$
|
||||
\beta_1=\frac{2}{1+\lambda},
|
||||
$$
|
||||
<p>The code which implements this simpler case is presented after the discussion of Ridge and Lasso.</p>
|
||||
|
||||
<p>
|
||||
Using the constraint for \( \beta_0^2+\beta_1^2=1 \) we can constrain \( \lambda \) by solving
|
||||
$$
|
||||
\left(\frac{8}{4+\lambda}\right)^2+\left(\frac{2}{1+\lambda}\right)^2=1,
|
||||
$$
|
||||
|
||||
which gives \( \lambda=4.571 \) and \( \beta_0=0.933 \) and \( \beta_1=0.359 \).
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
@@ -327,29 +303,22 @@ which gives \( \lambda=4.571 \) and \( \beta_0=0.933 \) and \( \beta_1=0.359 \).
|
||||
<li><a href="._week36-bs030.html">31</a></li>
|
||||
<li><a href="._week36-bs031.html">32</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs023.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!--
|
||||
Automatically generated HTML file from DocOnce source
|
||||
HTML file automatically generated from DocOnce source
|
||||
(https://github.com/doconce/doconce/)
|
||||
doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
@@ -8,24 +9,20 @@ Automatically generated HTML file from DocOnce source
|
||||
<meta name="generator" content="DocOnce: https://github.com/doconce/doconce/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="Week 36: Statistical interpretation of Linear Regression and Resampling techniques">
|
||||
|
||||
<title>Week 36: Statistical interpretation of Linear Regression and Resampling techniques</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<!-- doconce format html week36.do.txt --html_style=bootstrap --pygments_html_style=default --html_admon=bootstrap_panel --html_output=week36-bs --no_mako -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
@@ -35,8 +32,6 @@ Automatically generated HTML file from DocOnce source
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
@@ -76,6 +71,8 @@ Automatically generated HTML file from DocOnce source
|
||||
2,
|
||||
None,
|
||||
'deriving-the-ridge-regression-equations'),
|
||||
('Note on Scikit-Learn', 2, None, 'note-on-scikit-learn'),
|
||||
('Comparison with OLS', 2, None, 'comparison-with-ols'),
|
||||
('SVD analysis', 2, None, 'svd-analysis'),
|
||||
('Interpreting the Ridge results',
|
||||
2,
|
||||
@@ -187,8 +184,6 @@ MathJax.Hub.Config({
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
@@ -199,7 +194,6 @@ MathJax.Hub.Config({
|
||||
</button>
|
||||
<a class="navbar-brand" href="week36-bs.html">Week 36: Statistical interpretation of Linear Regression and Resampling techniques</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
@@ -216,45 +210,47 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs009.html#ridge-and-lasso-regression" style="font-size: 80%;">Ridge and LASSO Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs010.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-bs011.html#deriving-the-ridge-regression-equations" style="font-size: 80%;">Deriving the Ridge Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.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-bs017.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs019.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.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-bs032.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs034.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-bs035.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs037.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs012.html#note-on-scikit-learn" style="font-size: 80%;">Note on Scikit-Learn</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs013.html#comparison-with-ols" style="font-size: 80%;">Comparison with OLS</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs014.html#svd-analysis" style="font-size: 80%;">SVD analysis</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs015.html#interpreting-the-ridge-results" style="font-size: 80%;">Interpreting the Ridge results</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs016.html#more-interpretations" style="font-size: 80%;">More interpretations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs017.html#deriving-the-lasso-regression-equations" style="font-size: 80%;">Deriving the Lasso Regression Equations</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs018.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-bs019.html#ridge-regression" style="font-size: 80%;">Ridge Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs020.html#lasso-regression" style="font-size: 80%;">Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs021.html#yet-another-example" style="font-size: 80%;">Yet another Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs022.html#the-ols-case" style="font-size: 80%;">The OLS case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#the-ridge-case" style="font-size: 80%;">The Ridge case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs024.html#writing-the-cost-function" style="font-size: 80%;">Writing the Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs025.html#lasso-case" style="font-size: 80%;">Lasso case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs026.html#the-first-case" style="font-size: 80%;">The first Case</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs027.html#simple-code-for-solving-the-above-problem" style="font-size: 80%;">Simple code for solving the above problem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs028.html#with-lasso-regression" style="font-size: 80%;">With Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs029.html#another-example-now-with-a-polynomial-fit" style="font-size: 80%;">Another Example, now with a polynomial fit</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs030.html#using-cvxopt" style="font-size: 80%;">Using CVXOPT</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs031.html#the-simpler-example" style="font-size: 80%;">The simpler Example</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs032.html#friday-september-10" style="font-size: 80%;">Friday September 10</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs033.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-bs034.html#assumptions-made" style="font-size: 80%;">Assumptions made</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs035.html#expectation-value-and-variance" style="font-size: 80%;">Expectation value and variance</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs036.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-bs037.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs038.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs039.html#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs040.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs041.html#more-basic-statistics-and-bayes-theorem" style="font-size: 80%;">More basic Statistics and Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs042.html#marginal-probability" style="font-size: 80%;">Marginal Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs043.html#conditional-probability" style="font-size: 80%;">Conditional Probability</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs044.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs045.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs046.html#example-of-usage-of-bayes-theorem" style="font-size: 80%;">Example of Usage of Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs047.html#doing-it-correctly" style="font-size: 80%;">Doing it correctly</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs048.html#bayes-theorem-and-ridge-and-lasso-regression" style="font-size: 80%;">Bayes' Theorem and Ridge and Lasso Regression</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs049.html#test-function-for-what-happens-with-ols-ridge-and-lasso" style="font-size: 80%;">Test Function for what happens with OLS, Ridge and Lasso</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs050.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs051.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
|
||||
<!-- navigation toc: --> <li><a href="._week36-bs052.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -262,41 +258,29 @@ MathJax.Hub.Config({
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0023"></a>
|
||||
<!-- !split -->
|
||||
<h2 id="the-ridge-case" class="anchor">The Ridge case </h2>
|
||||
|
||||
<h2 id="lasso-case" class="anchor">Lasso case </h2>
|
||||
|
||||
<p>
|
||||
For Lasso we need now, keeping a constraint on \( \vert\beta_0\vert+\vert\beta_1\vert=1 \), to take the derivative of the absolute values of \( \beta_0 \)
|
||||
and \( \beta_1 \). This gives us the following derivatives of the cost function
|
||||
$$
|
||||
C(\boldsymbol{\beta})=(4-2\beta_0)^2+(2-\beta_1)^2+\lambda(\vert\beta_0\vert+\vert\beta_1\vert),
|
||||
$$
|
||||
|
||||
<p>For Ridge regression we have</p>
|
||||
|
||||
$$
|
||||
\frac{\partial C(\boldsymbol{\beta})}{\partial \beta_0}=-4(4-2\beta_0)+\lambda\mathrm{sgn}(\beta_0)=0,
|
||||
\hat{\boldsymbol{\beta}}^{\mathrm{Ridge}}=\left( \boldsymbol{X}^T\boldsymbol{X}+\lambda\boldsymbol{I}\right)^{-1}\boldsymbol{X}^T\boldsymbol{y}.
|
||||
$$
|
||||
|
||||
and
|
||||
<p>Inserting the above values we obtain that </p>
|
||||
|
||||
$$
|
||||
\frac{\partial C(\boldsymbol{\beta})}{\partial \beta_1}=-2(2-\beta_1)+\lambda\mathrm{sgn}(\beta_1)=0.
|
||||
\hat{\boldsymbol{\beta}}^{\mathrm{Ridge}}=\begin{bmatrix}\frac{8}{4+\lambda} \\ \frac{2}{1+\lambda}\end{bmatrix},
|
||||
$$
|
||||
|
||||
We have now four cases to solve besides the trivial cases \( \beta_0 \) and/or \( \beta_1 \) are zero, namely
|
||||
<p>There is normally a constraint on the value of \( \vert\vert \boldsymbol{\beta}\vert\vert_2 \) via the parameter \( \lambda \).
|
||||
Let us for simplicity assume that \( \beta_0^2+\beta_1^2=1 \) as constraint. This will allow us to find an expression for the optimal values of \( \beta \) and \( \lambda \).
|
||||
</p>
|
||||
|
||||
<ol>
|
||||
<li> \( \beta_0 > 0 \) and \( \beta_1 > 0 \),</li>
|
||||
<li> \( \beta_0 > 0 \) and \( \beta_1 < 0 \),</li>
|
||||
<li> \( \beta_0 < 0 \) and \( \beta_1 > 0 \),</li>
|
||||
<li> \( \beta_0 < 0 \) and \( \beta_1 < 0 \).</li>
|
||||
</ol>
|
||||
<p>To see this, let us write the cost function for Ridge regression. </p>
|
||||
|
||||
<p>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
@@ -323,29 +307,22 @@ We have now four cases to solve besides the trivial cases \( \beta_0 \) and/or \
|
||||
<li><a href="._week36-bs031.html">32</a></li>
|
||||
<li><a href="._week36-bs032.html">33</a></li>
|
||||
<li><a href="">...</a></li>
|
||||
<li><a href="._week36-bs050.html">51</a></li>
|
||||
<li><a href="._week36-bs052.html">53</a></li>
|
||||
<li><a href="._week36-bs024.html">»</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="https://..."><img width="250" align=right src="https://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright only on the titlepage -->
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user