Files
FYS-STK4155/doc/pub/week37/html/._week37-bs005.html
T
Morten Hjorth-Jensen c253fedc65 cleaning up week 37
2021-09-28 10:15:00 +02:00

355 lines
19 KiB
HTML

<!--
Automatically generated HTML file from DocOnce source
(https://github.com/doconce/doconce/)
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<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 37: Summary of Ridge and Lasso Regression and Resampling Methods">
<title>Week 37: Summary of Ridge and Lasso Regression and Resampling Methods</title>
<!-- Bootstrap style: bootstrap -->
<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 {
content:"";
display:block;
height:50px; /* fixed header height for style bootstrap */
margin:-50px 0 0; /* negative fixed header height */
}
</style>
</head>
<!-- tocinfo
{'highest level': 2,
'sections': [('Plans for week 37', 2, None, 'plans-for-week-37'),
('Thursday September 16, Summary of Ridge and Lasso Regression '
'and start Resampling methods',
2,
None,
'thursday-september-16-summary-of-ridge-and-lasso-regression-and-start-resampling-methods'),
('Deriving OLS from a probability distribution',
2,
None,
'deriving-ols-from-a-probability-distribution'),
('Independent and Identically Distrubuted (iid)',
2,
None,
'independent-and-identically-distrubuted-iid'),
('Maximum Likelihood Estimation (MLE)',
2,
None,
'maximum-likelihood-estimation-mle'),
('A new Cost Function', 2, None, 'a-new-cost-function'),
("Bayes' Theorem", 2, None, 'bayes-theorem'),
("Interpretations of Bayes' Theorem",
2,
None,
'interpretations-of-bayes-theorem'),
('Test Function for what happens with OLS, Ridge and Lasso',
2,
None,
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
('Rerunning the above code', 2, None, 'rerunning-the-above-code'),
("Invoking Bayes' theorem", 2, None, 'invoking-bayes-theorem'),
('Ridge and Bayes', 2, None, 'ridge-and-bayes'),
('Lasso and Bayes', 2, None, 'lasso-and-bayes'),
('Why resampling methods', 2, None, 'why-resampling-methods'),
('Resampling methods', 2, None, 'resampling-methods'),
('Resampling approaches can be computationally expensive',
2,
None,
'resampling-approaches-can-be-computationally-expensive'),
('Why resampling methods ?', 2, None, 'why-resampling-methods'),
('Statistical analysis', 2, None, 'statistical-analysis'),
('Resampling methods', 2, None, 'resampling-methods'),
('Resampling methods: Jackknife and Bootstrap',
2,
None,
'resampling-methods-jackknife-and-bootstrap'),
('Resampling methods: Jackknife',
2,
None,
'resampling-methods-jackknife'),
('Jackknife code example', 2, None, 'jackknife-code-example'),
('Resampling methods: Bootstrap',
2,
None,
'resampling-methods-bootstrap'),
('The Central Limit Theorem',
2,
None,
'the-central-limit-theorem'),
('Finding the Limit', 2, None, 'finding-the-limit'),
('Rewriting the $\\delta$-function',
2,
None,
'rewriting-the-delta-function'),
('Identifying Terms', 2, None, 'identifying-terms'),
('Wrapping it up', 2, None, 'wrapping-it-up'),
('Confidence Intervals', 2, None, 'confidence-intervals'),
('Standard Approach based on the Normal Distribution',
2,
None,
'standard-approach-based-on-the-normal-distribution'),
('Resampling methods: Bootstrap background',
2,
None,
'resampling-methods-bootstrap-background'),
('Resampling methods: More Bootstrap background',
2,
None,
'resampling-methods-more-bootstrap-background'),
('Resampling methods: Bootstrap approach',
2,
None,
'resampling-methods-bootstrap-approach'),
('Resampling methods: Bootstrap steps',
2,
None,
'resampling-methods-bootstrap-steps'),
('Code example for the Bootstrap method',
2,
None,
'code-example-for-the-bootstrap-method'),
('Plotting the Histogram', 2, None, 'plotting-the-histogram'),
('The bias-variance tradeoff',
2,
None,
'the-bias-variance-tradeoff'),
('A way to Read the Bias-Variance Tradeoff',
2,
None,
'a-way-to-read-the-bias-variance-tradeoff'),
('Example code for Bias-Variance tradeoff',
2,
None,
'example-code-for-bias-variance-tradeoff'),
('Understanding what happens',
2,
None,
'understanding-what-happens'),
('Summing up', 2, None, 'summing-up'),
("Another Example from Scikit-Learn's Repository",
2,
None,
'another-example-from-scikit-learn-s-repository'),
('Various steps in cross-validation',
2,
None,
'various-steps-in-cross-validation'),
('How to set up the cross-validation for Ridge and/or Lasso',
2,
None,
'how-to-set-up-the-cross-validation-for-ridge-and-or-lasso'),
('Cross-validation in brief',
2,
None,
'cross-validation-in-brief'),
('Code Example for Cross-validation and $k$-fold '
'Cross-validation',
2,
None,
'code-example-for-cross-validation-and-k-fold-cross-validation'),
('More examples on bootstrap and cross-validation and errors',
2,
None,
'more-examples-on-bootstrap-and-cross-validation-and-errors'),
('The same example but now with cross-validation',
2,
None,
'the-same-example-but-now-with-cross-validation')]}
end of tocinfo -->
<body>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: {
equationNumbers: { autoNumber: "none" },
extensions: ["AMSmath.js", "AMSsymbols.js", "autobold.js", "color.js"]
}
});
</script>
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<!-- Bootstrap navigation bar -->
<div class="navbar navbar-default navbar-fixed-top">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="week37-bs.html">Week 37: Summary of Ridge and Lasso Regression and Resampling Methods</a>
</div>
<div class="navbar-collapse collapse navbar-responsive-collapse">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Contents <b class="caret"></b></a>
<ul class="dropdown-menu">
<!-- navigation toc: --> <li><a href="._week37-bs001.html#plans-for-week-37" style="font-size: 80%;">Plans for week 37</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs002.html#thursday-september-16-summary-of-ridge-and-lasso-regression-and-start-resampling-methods" style="font-size: 80%;">Thursday September 16, Summary of Ridge and Lasso Regression and start Resampling methods</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs003.html#deriving-ols-from-a-probability-distribution" style="font-size: 80%;">Deriving OLS from a probability distribution</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs004.html#independent-and-identically-distrubuted-iid" style="font-size: 80%;">Independent and Identically Distrubuted (iid)</a></li>
<!-- navigation toc: --> <li><a href="#maximum-likelihood-estimation-mle" style="font-size: 80%;">Maximum Likelihood Estimation (MLE)</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs006.html#a-new-cost-function" style="font-size: 80%;">A new Cost Function</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs007.html#bayes-theorem" style="font-size: 80%;">Bayes' Theorem</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs008.html#interpretations-of-bayes-theorem" style="font-size: 80%;">Interpretations of Bayes' Theorem</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs009.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="._week37-bs010.html#rerunning-the-above-code" style="font-size: 80%;">Rerunning the above code</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs011.html#invoking-bayes-theorem" style="font-size: 80%;">Invoking Bayes' theorem</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs012.html#ridge-and-bayes" style="font-size: 80%;">Ridge and Bayes</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs013.html#lasso-and-bayes" style="font-size: 80%;">Lasso and Bayes</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs017.html#why-resampling-methods" style="font-size: 80%;">Why resampling methods</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs019.html#resampling-methods" style="font-size: 80%;">Resampling methods</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs016.html#resampling-approaches-can-be-computationally-expensive" style="font-size: 80%;">Resampling approaches can be computationally expensive</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs017.html#why-resampling-methods" style="font-size: 80%;">Why resampling methods ?</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs018.html#statistical-analysis" style="font-size: 80%;">Statistical analysis</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs019.html#resampling-methods" style="font-size: 80%;">Resampling methods</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs020.html#resampling-methods-jackknife-and-bootstrap" style="font-size: 80%;">Resampling methods: Jackknife and Bootstrap</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs021.html#resampling-methods-jackknife" style="font-size: 80%;">Resampling methods: Jackknife</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs022.html#jackknife-code-example" style="font-size: 80%;">Jackknife code example</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs023.html#resampling-methods-bootstrap" style="font-size: 80%;">Resampling methods: Bootstrap</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs024.html#the-central-limit-theorem" style="font-size: 80%;">The Central Limit Theorem</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs025.html#finding-the-limit" style="font-size: 80%;">Finding the Limit</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs026.html#rewriting-the-delta-function" style="font-size: 80%;">Rewriting the \( \delta \)-function</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs027.html#identifying-terms" style="font-size: 80%;">Identifying Terms</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs028.html#wrapping-it-up" style="font-size: 80%;">Wrapping it up</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs029.html#confidence-intervals" style="font-size: 80%;">Confidence Intervals</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs030.html#standard-approach-based-on-the-normal-distribution" style="font-size: 80%;">Standard Approach based on the Normal Distribution</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs031.html#resampling-methods-bootstrap-background" style="font-size: 80%;">Resampling methods: Bootstrap background</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs032.html#resampling-methods-more-bootstrap-background" style="font-size: 80%;">Resampling methods: More Bootstrap background</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs033.html#resampling-methods-bootstrap-approach" style="font-size: 80%;">Resampling methods: Bootstrap approach</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs034.html#resampling-methods-bootstrap-steps" style="font-size: 80%;">Resampling methods: Bootstrap steps</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs035.html#code-example-for-the-bootstrap-method" style="font-size: 80%;">Code example for the Bootstrap method</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs036.html#plotting-the-histogram" style="font-size: 80%;">Plotting the Histogram</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs037.html#the-bias-variance-tradeoff" style="font-size: 80%;">The bias-variance tradeoff</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs038.html#a-way-to-read-the-bias-variance-tradeoff" style="font-size: 80%;">A way to Read the Bias-Variance Tradeoff</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs039.html#example-code-for-bias-variance-tradeoff" style="font-size: 80%;">Example code for Bias-Variance tradeoff</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs040.html#understanding-what-happens" style="font-size: 80%;">Understanding what happens</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs041.html#summing-up" style="font-size: 80%;">Summing up</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs042.html#another-example-from-scikit-learn-s-repository" style="font-size: 80%;">Another Example from Scikit-Learn's Repository</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs043.html#various-steps-in-cross-validation" style="font-size: 80%;">Various steps in cross-validation</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs044.html#how-to-set-up-the-cross-validation-for-ridge-and-or-lasso" style="font-size: 80%;">How to set up the cross-validation for Ridge and/or Lasso</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs045.html#cross-validation-in-brief" style="font-size: 80%;">Cross-validation in brief</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs046.html#code-example-for-cross-validation-and-k-fold-cross-validation" style="font-size: 80%;">Code Example for Cross-validation and \( k \)-fold Cross-validation</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs047.html#more-examples-on-bootstrap-and-cross-validation-and-errors" style="font-size: 80%;">More examples on bootstrap and cross-validation and errors</a></li>
<!-- navigation toc: --> <li><a href="._week37-bs048.html#the-same-example-but-now-with-cross-validation" style="font-size: 80%;">The same example but now with cross-validation</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div> <!-- end of navigation bar -->
<div class="container">
<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p> <!-- add vertical space -->
<a name="part0005"></a>
<!-- !split -->
<h2 id="maximum-likelihood-estimation-mle" class="anchor">Maximum Likelihood Estimation (MLE) </h2>
<p>
In statistics, maximum likelihood estimation (MLE) is a method of
estimating the parameters of an assumed probability distribution,
given some observed data. This is achieved by maximizing a likelihood
function so that, under the assumed statistical model, the observed
data is the most probable.
<p>
We will assume here that our events are given by the above Gaussian
distribution and we will determine the optimal parameters \( \beta \) by
maximizing the above PDF. However, computing the derivatives of a
product function is cumbersome and can easily lead to overflow and/or
underflowproblems, with potentials for loss of numerical precision.
<p>
In practice, it is more convenient to maximize the logarithm of the
PDF because it is a monotonically increasing function of the argument.
Alternatively, and this will be our option, we will minimize the
negative of the logarithm since this is a monotonically decreasing
function.
<p>
Note also that maximization/minimization of the logarithm of the PDF
is equivalent to the maximization/minimization of the function itself.
<p>
<p>
<!-- navigation buttons at the bottom of the page -->
<ul class="pagination">
<li><a href="._week37-bs004.html">&laquo;</a></li>
<li><a href="._week37-bs000.html">1</a></li>
<li><a href="._week37-bs001.html">2</a></li>
<li><a href="._week37-bs002.html">3</a></li>
<li><a href="._week37-bs003.html">4</a></li>
<li><a href="._week37-bs004.html">5</a></li>
<li class="active"><a href="._week37-bs005.html">6</a></li>
<li><a href="._week37-bs006.html">7</a></li>
<li><a href="._week37-bs007.html">8</a></li>
<li><a href="._week37-bs008.html">9</a></li>
<li><a href="._week37-bs009.html">10</a></li>
<li><a href="._week37-bs010.html">11</a></li>
<li><a href="._week37-bs011.html">12</a></li>
<li><a href="._week37-bs012.html">13</a></li>
<li><a href="._week37-bs013.html">14</a></li>
<li><a href="._week37-bs014.html">15</a></li>
<li><a href="">...</a></li>
<li><a href="._week37-bs048.html">49</a></li>
<li><a href="._week37-bs006.html">&raquo;</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>