update book
This commit is contained in:
@@ -7,8 +7,8 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>4. Ridge and Lasso Regression — Applied Data Analysis and Machine Learning</title>
|
||||
|
||||
<link href="_static/css/theme.css" rel="stylesheet" />
|
||||
<link href="_static/css/index.c5995385ac14fb8791e8eb36b4908be2.css" rel="stylesheet" />
|
||||
<link href="_static/css/theme.css" rel="stylesheet">
|
||||
<link href="_static/css/index.ff1ffe594081f20da1ef19478df9384b.css" rel="stylesheet">
|
||||
|
||||
|
||||
<link rel="stylesheet"
|
||||
@@ -31,7 +31,7 @@
|
||||
<link rel="stylesheet" type="text/css" href="_static/panels-main.c949a650a448cc0ae9fd3441c0e17fb0.css" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/panels-variables.06eb56fa6e07937060861dad626602ad.css" />
|
||||
|
||||
<link rel="preload" as="script" href="_static/js/index.1c5a1a01449ed65a7b51.js">
|
||||
<link rel="preload" as="script" href="_static/js/index.be7d3bbb2ef33a8344ce.js">
|
||||
|
||||
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
|
||||
<script src="_static/jquery.js"></script>
|
||||
@@ -41,22 +41,24 @@
|
||||
<script src="_static/clipboard.min.js"></script>
|
||||
<script src="_static/copybutton.js"></script>
|
||||
<script>var togglebuttonSelector = '.toggle, .admonition.dropdown, .tag_hide_input div.cell_input, .tag_hide-input div.cell_input, .tag_hide_output div.cell_output, .tag_hide-output div.cell_output, .tag_hide_cell.cell, .tag_hide-cell.cell';</script>
|
||||
<script src="_static/sphinx-book-theme.12a9622fbb08dcb3a2a40b2c02b83a57.js"></script>
|
||||
<script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
||||
<script>window.MathJax = {"options": {"processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script>
|
||||
<script async="async" src="https://unpkg.com/thebe@0.5.1/lib/index.js"></script>
|
||||
<script>
|
||||
const thebe_selector = ".thebe"
|
||||
const thebe_selector_input = "pre"
|
||||
const thebe_selector_output = ".output"
|
||||
</script>
|
||||
<script src="_static/sphinx-book-theme.d59cb220de22ca1c485ebbdc042f0030.js"></script>
|
||||
<script>const THEBE_JS_URL = "https://unpkg.com/thebe@0.8.2/lib/index.js"
|
||||
const thebe_selector = ".thebe,.cell"
|
||||
const thebe_selector_input = "pre"
|
||||
const thebe_selector_output = ".output, .cell_output"
|
||||
</script>
|
||||
<script async="async" src="_static/sphinx-thebe.js"></script>
|
||||
<script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
||||
<script>window.MathJax = {"options": {"processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script>
|
||||
<link rel="index" title="Index" href="genindex.html" />
|
||||
<link rel="search" title="Search" href="search.html" />
|
||||
<link rel="next" title="5. Resampling Methods" href="chapter3.html" />
|
||||
<link rel="prev" title="3. Linear Regression" href="chapter1.html" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="docsearch:language" content="en" />
|
||||
<meta name="docsearch:language" content="None">
|
||||
|
||||
|
||||
<!-- Google Analytics -->
|
||||
|
||||
</head>
|
||||
<body data-spy="scroll" data-target="#bd-toc-nav" data-offset="80">
|
||||
@@ -91,11 +93,11 @@
|
||||
<ul class="nav bd-sidenav">
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="intro.html">
|
||||
Applied Data Analysis and Machine Learning, FYS-STK3155/4155 at the University of Oslo, Norway
|
||||
Applied Data Analysis and Machine Learning
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="caption" role="heading">
|
||||
<p aria-level="2" class="caption" role="heading">
|
||||
<span class="caption-text">
|
||||
About the course
|
||||
</span>
|
||||
@@ -117,7 +119,7 @@
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="caption" role="heading">
|
||||
<p aria-level="2" class="caption" role="heading">
|
||||
<span class="caption-text">
|
||||
Review of Statistics with Resampling Techniques and Linear Algebra
|
||||
</span>
|
||||
@@ -134,7 +136,7 @@
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="caption" role="heading">
|
||||
<p aria-level="2" class="caption" role="heading">
|
||||
<span class="caption-text">
|
||||
From Regression to Support Vector Machines
|
||||
</span>
|
||||
@@ -171,7 +173,7 @@
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="caption" role="heading">
|
||||
<p aria-level="2" class="caption" role="heading">
|
||||
<span class="caption-text">
|
||||
Decision Trees, Ensemble Methods and Boosting
|
||||
</span>
|
||||
@@ -188,7 +190,7 @@
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="caption" role="heading">
|
||||
<p aria-level="2" class="caption" role="heading">
|
||||
<span class="caption-text">
|
||||
Dimensionality Reduction
|
||||
</span>
|
||||
@@ -199,8 +201,13 @@
|
||||
11. Basic ideas of the Principal Component Analysis (PCA)
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="clustering.html">
|
||||
12. Clustering and Unsupervised Learning
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="caption" role="heading">
|
||||
<p aria-level="2" class="caption" role="heading">
|
||||
<span class="caption-text">
|
||||
Deep Learning Methods
|
||||
</span>
|
||||
@@ -208,17 +215,27 @@
|
||||
<ul class="nav bd-sidenav">
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter9.html">
|
||||
12. Neural networks
|
||||
13. Neural networks
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter10.html">
|
||||
13. Building a Feed Forward Neural Network
|
||||
14. Building a Feed Forward Neural Network
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter11.html">
|
||||
14. Solving Differential Equations with Deep Learning
|
||||
15. Solving Differential Equations with Deep Learning
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter12.html">
|
||||
16. Convolutional Neural Networks
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter13.html">
|
||||
17. Recurrent neural networks: Overarching view
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -267,7 +284,7 @@
|
||||
data-placement="left">.ipynb</button></a>
|
||||
<!-- Download PDF via print -->
|
||||
<button type="button" id="download-print" class="btn btn-secondary topbarbtn" title="Print to PDF"
|
||||
onClick="window.print()" data-toggle="tooltip" data-placement="left">.pdf</button>
|
||||
onclick="printPdf(this)" data-toggle="tooltip" data-placement="left">.pdf</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -285,7 +302,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Table of contents -->
|
||||
<div class="d-none d-md-block col-md-2 bd-toc show">
|
||||
<div class="d-none d-md-block col-md-2 bd-toc show noprint">
|
||||
|
||||
<div class="tocsection onthispage pt-5 pb-3">
|
||||
<i class="fas fa-list"></i> Contents
|
||||
@@ -370,7 +387,95 @@
|
||||
</div>
|
||||
<div id="main-content" class="row">
|
||||
<div class="col-12 col-md-9 pl-md-3 pr-md-0">
|
||||
|
||||
<!-- Table of contents that is only displayed when printing the page -->
|
||||
<div id="jb-print-docs-body" class="onlyprint">
|
||||
<h1>Ridge and Lasso Regression</h1>
|
||||
<!-- Table of contents -->
|
||||
<div id="print-main-content">
|
||||
<div id="jb-print-toc">
|
||||
|
||||
<div>
|
||||
<h2> Contents </h2>
|
||||
</div>
|
||||
<nav aria-label="Page">
|
||||
<ul class="visible nav section-nav flex-column">
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#mathematical-interpretation-of-ordinary-least-squares">
|
||||
4.1. Mathematical Interpretation of Ordinary Least Squares
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#the-singular-value-decomposition">
|
||||
4.2. The singular value decomposition
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#basic-math-of-the-svd">
|
||||
4.3. Basic math of the SVD
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#codes-for-the-svd">
|
||||
4.4. Codes for the SVD
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#code-for-svd-and-inversion-of-matrices">
|
||||
4.5. Code for SVD and Inversion of Matrices
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#mathematics-of-the-svd-and-implications">
|
||||
4.6. Mathematics of the SVD and implications
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#further-properties-important-for-our-analyses-later">
|
||||
4.7. Further properties (important for our analyses later)
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#meet-the-covariance-matrix">
|
||||
4.8. Meet the Covariance Matrix
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#linking-with-the-svd">
|
||||
4.9. Linking with the SVD
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#id1">
|
||||
4.10. Ridge and Lasso Regression
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#linking-the-regression-analysis-with-a-statistical-interpretation">
|
||||
4.11. Linking the regression analysis with a statistical interpretation
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#deriving-ols-from-a-probability-distribution">
|
||||
4.12. Deriving OLS from a probability distribution
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#bayes-theorem-and-ridge-and-lasso-regression">
|
||||
4.13. Bayes’ Theorem and Ridge and Lasso Regression
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#linking-bayes-theorem-with-ridge-and-lasso-regression">
|
||||
4.14. Linking Bayes’ Theorem with Ridge and Lasso Regression
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
<div class="tex2jax_ignore mathjax_ignore section" id="ridge-and-lasso-regression">
|
||||
@@ -721,13 +826,13 @@ The simple answer is to use the linear algebra function for the pseudoinverse, t
|
||||
[2 4 5]
|
||||
[3 5 6]]
|
||||
test U
|
||||
[[ 2.22044605e-16 -1.11362930e-15 -8.52945798e-16]
|
||||
[-1.11362930e-15 0.00000000e+00 -1.37835429e-16]
|
||||
[-8.52945798e-16 -1.37835429e-16 -1.11022302e-16]]
|
||||
[[ 4.44089210e-16 -4.69484813e-16 -6.67314874e-16]
|
||||
[-4.69484813e-16 -4.44089210e-16 -1.54041041e-16]
|
||||
[-6.67314874e-16 -1.54041041e-16 1.11022302e-16]]
|
||||
test VT
|
||||
[[ 1.11022302e-16 -1.84228957e-16 2.68545647e-16]
|
||||
[-1.84228957e-16 0.00000000e+00 -6.33166055e-17]
|
||||
[ 2.68545647e-16 -6.33166055e-17 -1.11022302e-16]]
|
||||
[[ 2.22044605e-16 3.78156479e-17 1.85278920e-16]
|
||||
[ 3.78156479e-17 0.00000000e+00 -6.33166055e-17]
|
||||
[ 1.85278920e-16 -6.33166055e-17 -1.11022302e-16]]
|
||||
[[0. 0. 0.]
|
||||
[0. 0. 0.]
|
||||
[0. 0. 0.]]
|
||||
@@ -1109,10 +1214,10 @@ covariance matrix through the <strong>np.linalg.eig()</strong> function.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.0934597075922044
|
||||
4.185278747229417
|
||||
[[0.84292394 2.47432993]
|
||||
[2.47432993 8.32458459]]
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>-0.13876586436927824
|
||||
3.722047011333792
|
||||
[[ 1.233528 3.58428804]
|
||||
[ 3.58428804 11.47942814]]
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1149,10 +1254,10 @@ a more brute force way. Here we scale the mean values for each column of the des
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.08673755293381497
|
||||
1.3925515884752442
|
||||
[[1. 0.62364974]
|
||||
[0.62364974 1. ]]
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.08464758160254343
|
||||
1.8503720991789538
|
||||
[[1. 0.65626043]
|
||||
[0.65626043 1. ]]
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1182,30 +1287,30 @@ this matrix we easily see that it is a positive definite matrix.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[ 0.77034458 1.03056589]
|
||||
[-0.46986815 -1.26822717]
|
||||
[ 0.82650876 -0.37655936]
|
||||
[ 1.1323603 2.97788031]
|
||||
[-0.07989327 0.08630331]
|
||||
[-1.8608479 -5.59839245]
|
||||
[-0.3528556 0.06021285]
|
||||
[ 0.25286618 1.40116777]
|
||||
[-1.1224392 -2.14042769]
|
||||
[ 0.90382431 3.82747653]]
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[-1.41876267 -4.93248252]
|
||||
[ 1.83687444 5.28097861]
|
||||
[ 0.37429133 0.59766 ]
|
||||
[ 0.59159438 1.71869727]
|
||||
[-0.80315282 -0.89348922]
|
||||
[-0.38748219 -2.12288563]
|
||||
[-2.08917679 -5.64933923]
|
||||
[ 0.27803645 0.89944994]
|
||||
[ 1.23703839 3.2321528 ]
|
||||
[ 0.38073947 1.86925797]]
|
||||
0 1
|
||||
0 0.770345 1.030566
|
||||
1 -0.469868 -1.268227
|
||||
2 0.826509 -0.376559
|
||||
3 1.132360 2.977880
|
||||
4 -0.079893 0.086303
|
||||
5 -1.860848 -5.598392
|
||||
6 -0.352856 0.060213
|
||||
7 0.252866 1.401168
|
||||
8 -1.122439 -2.140428
|
||||
9 0.903824 3.827477
|
||||
0 -1.418763 -4.932483
|
||||
1 1.836874 5.280979
|
||||
2 0.374291 0.597660
|
||||
3 0.591594 1.718697
|
||||
4 -0.803153 -0.893489
|
||||
5 -0.387482 -2.122886
|
||||
6 -2.089177 -5.649339
|
||||
7 0.278036 0.899450
|
||||
8 1.237038 3.232153
|
||||
9 0.380739 1.869258
|
||||
0 1
|
||||
0 1.000000 0.900449
|
||||
1 0.900449 1.000000
|
||||
0 1.000000 0.977418
|
||||
1 0.977418 1.000000
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1262,37 +1367,37 @@ this matrix we easily see that it is a positive definite matrix.</p>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 0 1 2 3 4 5 6 7 \
|
||||
0 0.0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
|
||||
1 0.0 0.088611 0.086567 0.090229 0.089425 0.088631 0.082174 0.081773
|
||||
2 0.0 0.086567 0.085416 0.088176 0.087834 0.087501 0.080517 0.080406
|
||||
3 0.0 0.090229 0.088176 0.097360 0.096623 0.095871 0.091891 0.091630
|
||||
4 0.0 0.089425 0.087834 0.096623 0.096173 0.095702 0.091426 0.091363
|
||||
5 0.0 0.088631 0.087501 0.095871 0.095702 0.095510 0.090929 0.091060
|
||||
6 0.0 0.082174 0.080517 0.091891 0.091426 0.090929 0.088853 0.088816
|
||||
7 0.0 0.081773 0.080406 0.091630 0.091363 0.091060 0.088816 0.088926
|
||||
8 0.0 0.081431 0.080347 0.091414 0.091340 0.091224 0.088809 0.089059
|
||||
9 0.0 0.081140 0.080334 0.091236 0.091349 0.091416 0.088825 0.089212
|
||||
10 0.0 0.073695 0.072492 0.084408 0.084224 0.084000 0.083053 0.083220
|
||||
11 0.0 0.073531 0.072530 0.084400 0.084364 0.084282 0.083227 0.083506
|
||||
12 0.0 0.073423 0.072617 0.084444 0.084549 0.084604 0.083441 0.083829
|
||||
13 0.0 0.073368 0.072750 0.084536 0.084777 0.084965 0.083692 0.084184
|
||||
14 0.0 0.073362 0.072928 0.084670 0.085044 0.085361 0.083977 0.084570
|
||||
1 0.0 0.081253 0.083015 0.080297 0.079157 0.078040 0.071112 0.069847
|
||||
2 0.0 0.083015 0.086807 0.084909 0.084904 0.084702 0.076955 0.076338
|
||||
3 0.0 0.080297 0.084909 0.084414 0.084862 0.085018 0.077793 0.077402
|
||||
4 0.0 0.079157 0.084904 0.084862 0.086076 0.086872 0.079281 0.079383
|
||||
5 0.0 0.078040 0.084702 0.085018 0.086872 0.088212 0.080319 0.080847
|
||||
6 0.0 0.071112 0.076955 0.077793 0.079281 0.080319 0.073719 0.074034
|
||||
7 0.0 0.069847 0.076338 0.077402 0.079383 0.080847 0.074034 0.074693
|
||||
8 0.0 0.068735 0.075760 0.077003 0.079405 0.081233 0.074237 0.075195
|
||||
9 0.0 0.067769 0.075241 0.076628 0.079389 0.081533 0.074375 0.075594
|
||||
10 0.0 0.062136 0.068318 0.069888 0.071921 0.073449 0.067622 0.068376
|
||||
11 0.0 0.061149 0.067723 0.069408 0.071767 0.073583 0.067612 0.068608
|
||||
12 0.0 0.060309 0.067213 0.068991 0.071632 0.073699 0.067599 0.068806
|
||||
13 0.0 0.059601 0.066789 0.068642 0.071529 0.073816 0.067597 0.068992
|
||||
14 0.0 0.059013 0.066449 0.068363 0.071467 0.073949 0.067620 0.069181
|
||||
|
||||
8 9 10 11 12 13 14
|
||||
0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
|
||||
1 0.081431 0.081140 0.073695 0.073531 0.073423 0.073368 0.073362
|
||||
2 0.080347 0.080334 0.072492 0.072530 0.072617 0.072750 0.072928
|
||||
3 0.091414 0.091236 0.084408 0.084400 0.084444 0.084536 0.084670
|
||||
4 0.091340 0.091349 0.084224 0.084364 0.084549 0.084777 0.085044
|
||||
5 0.091224 0.091416 0.084000 0.084282 0.084604 0.084965 0.085361
|
||||
6 0.088809 0.088825 0.083053 0.083227 0.083441 0.083692 0.083977
|
||||
7 0.089059 0.089212 0.083220 0.083506 0.083829 0.084184 0.084570
|
||||
8 0.089329 0.089614 0.083404 0.083799 0.084226 0.084683 0.085167
|
||||
9 0.089614 0.090028 0.083600 0.084101 0.084629 0.085184 0.085764
|
||||
10 0.083404 0.083600 0.078667 0.078992 0.079347 0.079729 0.080137
|
||||
11 0.083799 0.084101 0.078992 0.079406 0.079847 0.080312 0.080801
|
||||
12 0.084226 0.084629 0.079347 0.079847 0.080370 0.080916 0.081483
|
||||
13 0.084683 0.085184 0.079729 0.080312 0.080916 0.081540 0.082183
|
||||
14 0.085167 0.085764 0.080137 0.080801 0.081483 0.082183 0.082900
|
||||
1 0.068735 0.067769 0.062136 0.061149 0.060309 0.059601 0.059013
|
||||
2 0.075760 0.075241 0.068318 0.067723 0.067213 0.066789 0.066449
|
||||
3 0.077003 0.076628 0.069888 0.069408 0.068991 0.068642 0.068363
|
||||
4 0.079405 0.079389 0.071921 0.071767 0.071632 0.071529 0.071467
|
||||
5 0.081233 0.081533 0.073449 0.073583 0.073699 0.073816 0.073949
|
||||
6 0.074237 0.074375 0.067622 0.067612 0.067599 0.067597 0.067620
|
||||
7 0.075195 0.075594 0.068376 0.068608 0.068806 0.068992 0.069181
|
||||
8 0.075959 0.076589 0.068965 0.069409 0.069796 0.070150 0.070491
|
||||
9 0.076589 0.077425 0.069441 0.070074 0.070630 0.071136 0.071614
|
||||
10 0.068965 0.069441 0.063052 0.063364 0.063631 0.063874 0.064110
|
||||
11 0.069409 0.070074 0.063364 0.063851 0.064274 0.064658 0.065020
|
||||
12 0.069796 0.070630 0.063631 0.064274 0.064838 0.065348 0.065826
|
||||
13 0.070150 0.071136 0.063874 0.064658 0.065348 0.065974 0.066558
|
||||
14 0.070491 0.071614 0.064110 0.065020 0.065826 0.066558 0.067240
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -2149,9 +2254,9 @@ set of <span class="math notranslate nohighlight">\(\lambda\)</span> values.</p>
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[ 2.03099776 -0.17917768 5.18029127]
|
||||
Training MSE for OLS
|
||||
0.009163470508352211
|
||||
0.009163470508352218
|
||||
Test MSE OLS
|
||||
0.008675369724976501
|
||||
0.008675369724975977
|
||||
</pre></div>
|
||||
</div>
|
||||
<img alt="_images/chapter2_249_1.png" src="_images/chapter2_249_1.png" />
|
||||
@@ -2428,7 +2533,7 @@ The following code example solves the simpler problem we discussed above, where
|
||||
<div class="cell_output docutils container">
|
||||
<div class="output traceback highlight-ipythontb notranslate"><div class="highlight"><pre><span></span><span class="gt">---------------------------------------------------------------------------</span>
|
||||
<span class="ne">ModuleNotFoundError</span><span class="g g-Whitespace"> </span>Traceback (most recent call last)
|
||||
<span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">folders</span><span class="o">/</span><span class="n">jy</span><span class="o">/</span><span class="n">g42mrgv128v34gnnhxwk9nrc0000gp</span><span class="o">/</span><span class="n">T</span><span class="o">/</span><span class="n">ipykernel_42449</span><span class="o">/</span><span class="mf">3530606977.</span><span class="n">py</span> <span class="ow">in</span> <span class="o"><</span><span class="n">module</span><span class="o">></span>
|
||||
<span class="o"><</span><span class="n">ipython</span><span class="o">-</span><span class="nb">input</span><span class="o">-</span><span class="mi">12</span><span class="o">-</span><span class="n">d670a873ab0c</span><span class="o">></span> <span class="ow">in</span> <span class="o"><</span><span class="n">module</span><span class="o">></span>
|
||||
<span class="ne">----> </span><span class="mi">1</span> <span class="kn">from</span> <span class="nn">cvxopt</span> <span class="kn">import</span> <span class="n">matrix</span><span class="p">,</span> <span class="n">spdiag</span><span class="p">,</span> <span class="n">mul</span><span class="p">,</span> <span class="n">div</span><span class="p">,</span> <span class="n">sqrt</span><span class="p">,</span> <span class="n">normal</span><span class="p">,</span> <span class="n">setseed</span>
|
||||
<span class="g g-Whitespace"> </span><span class="mi">2</span> <span class="kn">from</span> <span class="nn">cvxopt</span> <span class="kn">import</span> <span class="n">blas</span><span class="p">,</span> <span class="n">lapack</span><span class="p">,</span> <span class="n">solvers</span><span class="p">,</span> <span class="n">sparse</span><span class="p">,</span> <span class="n">spmatrix</span>
|
||||
<span class="g g-Whitespace"> </span><span class="mi">3</span> <span class="kn">import</span> <span class="nn">math</span>
|
||||
@@ -3049,54 +3154,42 @@ decreasing <span class="math notranslate nohighlight">\(\lambda\)</span> and shr
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class='prev-next-bottom'>
|
||||
|
||||
<div id="prev">
|
||||
<a class="left-prev" href="chapter1.html" title="previous page">
|
||||
<i class="prevnext-label fas fa-angle-left"></i>
|
||||
<div class="prevnext-info">
|
||||
<p class="prevnext-label">previous</p>
|
||||
<p class="prevnext-title"><span class="section-number">3. </span>Linear Regression</p>
|
||||
</div>
|
||||
</a>
|
||||
<!-- Previous / next buttons -->
|
||||
<div class='prev-next-area'>
|
||||
<a class='left-prev' id="prev-link" href="chapter1.html" title="previous page">
|
||||
<i class="fas fa-angle-left"></i>
|
||||
<div class="prev-next-info">
|
||||
<p class="prev-next-subtitle">previous</p>
|
||||
<p class="prev-next-title"><span class="section-number">3. </span>Linear Regression</p>
|
||||
</div>
|
||||
</a>
|
||||
<a class='right-next' id="next-link" href="chapter3.html" title="next page">
|
||||
<div class="prev-next-info">
|
||||
<p class="prev-next-subtitle">next</p>
|
||||
<p class="prev-next-title"><span class="section-number">5. </span>Resampling Methods</p>
|
||||
</div>
|
||||
<div id="next">
|
||||
<a class="right-next" href="chapter3.html" title="next page">
|
||||
<div class="prevnext-info">
|
||||
<p class="prevnext-label">next</p>
|
||||
<p class="prevnext-title"><span class="section-number">5. </span>Resampling Methods</p>
|
||||
</div>
|
||||
<i class="prevnext-label fas fa-angle-right"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<i class="fas fa-angle-right"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p>
|
||||
|
||||
By Morten Hjorth-Jensen<br/>
|
||||
|
||||
© Copyright 2021.<br/>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<p>
|
||||
|
||||
By Morten Hjorth-Jensen<br/>
|
||||
|
||||
© Copyright 2021.<br/>
|
||||
</p>
|
||||
</footer>
|
||||
</main>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="_static/js/index.1c5a1a01449ed65a7b51.js"></script>
|
||||
<script src="_static/js/index.be7d3bbb2ef33a8344ce.js"></script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user