diff --git a/doc/pub/week36/html/._week36-bs000.html b/doc/pub/week36/html/._week36-bs000.html
index 923ed3495..11ff82d8c 100644
--- a/doc/pub/week36/html/._week36-bs000.html
+++ b/doc/pub/week36/html/._week36-bs000.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -428,7 +313,7 @@ MathJax.Hub.Config({
9
10
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs001.html b/doc/pub/week36/html/._week36-bs001.html
index 261d71e32..063c5a2da 100644
--- a/doc/pub/week36/html/._week36-bs001.html
+++ b/doc/pub/week36/html/._week36-bs001.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -416,7 +301,7 @@ Recommended Reading:
10
11
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs002.html b/doc/pub/week36/html/._week36-bs002.html
index 6cd088af4..ab5a65b28 100644
--- a/doc/pub/week36/html/._week36-bs002.html
+++ b/doc/pub/week36/html/._week36-bs002.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -405,7 +290,7 @@ MathJax.Hub.Config({
11
12
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs003.html b/doc/pub/week36/html/._week36-bs003.html
index ed7fae69e..06bb28ecb 100644
--- a/doc/pub/week36/html/._week36-bs003.html
+++ b/doc/pub/week36/html/._week36-bs003.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -406,7 +291,7 @@ MathJax.Hub.Config({
12
13
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs004.html b/doc/pub/week36/html/._week36-bs004.html
index dc8375ebd..ad956480c 100644
--- a/doc/pub/week36/html/._week36-bs004.html
+++ b/doc/pub/week36/html/._week36-bs004.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -439,7 +324,7 @@ $$
13
14
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs005.html b/doc/pub/week36/html/._week36-bs005.html
index ebaa4cf93..16d7be9bc 100644
--- a/doc/pub/week36/html/._week36-bs005.html
+++ b/doc/pub/week36/html/._week36-bs005.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -446,7 +331,7 @@ absolute value of the eigenvalues of \( \boldsymbol{X} \).
14
15
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs006.html b/doc/pub/week36/html/._week36-bs006.html
index a99a7d588..70125e4e9 100644
--- a/doc/pub/week36/html/._week36-bs006.html
+++ b/doc/pub/week36/html/._week36-bs006.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -443,7 +328,7 @@ values and the column vectors of \( \boldsymbol{V} \).
15
16
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs007.html b/doc/pub/week36/html/._week36-bs007.html
index 0b3b4fb1c..de3a97d20 100644
--- a/doc/pub/week36/html/._week36-bs007.html
+++ b/doc/pub/week36/html/._week36-bs007.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -454,7 +339,7 @@ C = SVDinv(A)
16
17
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs008.html b/doc/pub/week36/html/._week36-bs008.html
index 71855dc02..1e7df6297 100644
--- a/doc/pub/week36/html/._week36-bs008.html
+++ b/doc/pub/week36/html/._week36-bs008.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -460,7 +345,7 @@ As you can see from this example, our own decomposition based on the SVD agrees
17
18
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs009.html b/doc/pub/week36/html/._week36-bs009.html
index 43a708864..3a51c650e 100644
--- a/doc/pub/week36/html/._week36-bs009.html
+++ b/doc/pub/week36/html/._week36-bs009.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -430,7 +315,7 @@ $$
18
19
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs010.html b/doc/pub/week36/html/._week36-bs010.html
index 5d4516b05..29afe5478 100644
--- a/doc/pub/week36/html/._week36-bs010.html
+++ b/doc/pub/week36/html/._week36-bs010.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -448,7 +333,7 @@ $$
19
20
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs011.html b/doc/pub/week36/html/._week36-bs011.html
index 4b3e8c6ec..4a8bf211a 100644
--- a/doc/pub/week36/html/._week36-bs011.html
+++ b/doc/pub/week36/html/._week36-bs011.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -454,7 +339,7 @@ even reduce the variance of the optimal parameters \( \boldsymbol{\beta} \). The
20
21
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs012.html b/doc/pub/week36/html/._week36-bs012.html
index 47da58ee3..386eaf6f5 100644
--- a/doc/pub/week36/html/._week36-bs012.html
+++ b/doc/pub/week36/html/._week36-bs012.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -430,7 +315,7 @@ with the vectors \( \boldsymbol{u}_j \) being the columns of \( \boldsymbol{U} \
21
22
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs013.html b/doc/pub/week36/html/._week36-bs013.html
index 9c656668a..8f5e2a6aa 100644
--- a/doc/pub/week36/html/._week36-bs013.html
+++ b/doc/pub/week36/html/._week36-bs013.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -430,7 +315,7 @@ For small eigenvalues \( \sigma_i \) it means that their contributions become le
22
23
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs014.html b/doc/pub/week36/html/._week36-bs014.html
index c44e0544a..b8644c7f8 100644
--- a/doc/pub/week36/html/._week36-bs014.html
+++ b/doc/pub/week36/html/._week36-bs014.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -445,7 +330,7 @@ Similarly, Mehta et al
23
24
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs015.html b/doc/pub/week36/html/._week36-bs015.html
index aa2d3891a..64ae4999a 100644
--- a/doc/pub/week36/html/._week36-bs015.html
+++ b/doc/pub/week36/html/._week36-bs015.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -439,7 +324,7 @@ This equation does not lead to a nice analytical equation as in Ridge regression
24
25
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs016.html b/doc/pub/week36/html/._week36-bs016.html
index 48804297e..6d3c4cb86 100644
--- a/doc/pub/week36/html/._week36-bs016.html
+++ b/doc/pub/week36/html/._week36-bs016.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -428,7 +313,7 @@ $$
25
26
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs017.html b/doc/pub/week36/html/._week36-bs017.html
index 70ec987a2..80aadb339 100644
--- a/doc/pub/week36/html/._week36-bs017.html
+++ b/doc/pub/week36/html/._week36-bs017.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -424,7 +309,7 @@ $$
26
27
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs018.html b/doc/pub/week36/html/._week36-bs018.html
index 0c338eafe..fe1aa55a6 100644
--- a/doc/pub/week36/html/._week36-bs018.html
+++ b/doc/pub/week36/html/._week36-bs018.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -434,7 +319,7 @@ Plotting these results (27
28
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs019.html b/doc/pub/week36/html/._week36-bs019.html
index 011207545..12d0bb9c7 100644
--- a/doc/pub/week36/html/._week36-bs019.html
+++ b/doc/pub/week36/html/._week36-bs019.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -427,7 +312,7 @@ meaning that we have two features and two unknown parameters \( \beta_0 \) and \
28
29
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs020.html b/doc/pub/week36/html/._week36-bs020.html
index b48481901..2cbf3a2ac 100644
--- a/doc/pub/week36/html/._week36-bs020.html
+++ b/doc/pub/week36/html/._week36-bs020.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -429,7 +314,7 @@ The code which implements this simpler case is presented after the discussion of
29
30
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs021.html b/doc/pub/week36/html/._week36-bs021.html
index d44fa6209..3d4cd8ea6 100644
--- a/doc/pub/week36/html/._week36-bs021.html
+++ b/doc/pub/week36/html/._week36-bs021.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -433,7 +318,7 @@ To see this, let us write the cost function for Ridge regression.
30
31
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs022.html b/doc/pub/week36/html/._week36-bs022.html
index c864cf2dd..6025dfac6 100644
--- a/doc/pub/week36/html/._week36-bs022.html
+++ b/doc/pub/week36/html/._week36-bs022.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -442,7 +327,7 @@ which gives \( \lambda=4.571 \) and \( \beta_0=0.933 \) and \( \beta_1=0.359 \).
31
32
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs023.html b/doc/pub/week36/html/._week36-bs023.html
index 9e3f40384..4f200a2da 100644
--- a/doc/pub/week36/html/._week36-bs023.html
+++ b/doc/pub/week36/html/._week36-bs023.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -438,7 +323,7 @@ We have now four cases to solve besides the trivial cases \( \beta_0 \) and/or \
32
33
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs024.html b/doc/pub/week36/html/._week36-bs024.html
index dc97ebf15..99b69fcd4 100644
--- a/doc/pub/week36/html/._week36-bs024.html
+++ b/doc/pub/week36/html/._week36-bs024.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -438,7 +323,7 @@ Using the constraint on \( \beta_0 \) and \( \beta_1 \) we can then find the opt
33
34
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs025.html b/doc/pub/week36/html/._week36-bs025.html
index 87b25afaa..2b4498097 100644
--- a/doc/pub/week36/html/._week36-bs025.html
+++ b/doc/pub/week36/html/._week36-bs025.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -475,7 +360,7 @@ We see here that we reach a plateau. What is actually happening?
34
35
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs026.html b/doc/pub/week36/html/._week36-bs026.html
index 23a920ea2..5541ab5e9 100644
--- a/doc/pub/week36/html/._week36-bs026.html
+++ b/doc/pub/week36/html/._week36-bs026.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -473,7 +358,7 @@ plt.show()
35
36
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs027.html b/doc/pub/week36/html/._week36-bs027.html
index f94ef5e37..7e9f17121 100644
--- a/doc/pub/week36/html/._week36-bs027.html
+++ b/doc/pub/week36/html/._week36-bs027.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -495,7 +380,7 @@ plt.show()
36
37
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs028.html b/doc/pub/week36/html/._week36-bs028.html
index 09a8a6bd9..bc624f22d 100644
--- a/doc/pub/week36/html/._week36-bs028.html
+++ b/doc/pub/week36/html/._week36-bs028.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -686,7 +571,7 @@ We list first the needed file. Thereafter we set up the problem to solve.
37
38
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs029.html b/doc/pub/week36/html/._week36-bs029.html
index 421ab3c44..b6dfb66b2 100644
--- a/doc/pub/week36/html/._week36-bs029.html
+++ b/doc/pub/week36/html/._week36-bs029.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -422,7 +307,7 @@ x = l1regls(X,y)
38
39
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs030.html b/doc/pub/week36/html/._week36-bs030.html
index ebc7ec23b..8ec9fd839 100644
--- a/doc/pub/week36/html/._week36-bs030.html
+++ b/doc/pub/week36/html/._week36-bs030.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -413,7 +298,7 @@ MathJax.Hub.Config({
39
40
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs031.html b/doc/pub/week36/html/._week36-bs031.html
index f1cd4c9d5..2d74d284b 100644
--- a/doc/pub/week36/html/._week36-bs031.html
+++ b/doc/pub/week36/html/._week36-bs031.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -454,7 +339,7 @@ row number \( i \) and perform a sum over all values \( p \).
40
41
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs032.html b/doc/pub/week36/html/._week36-bs032.html
index a1925a52c..cad7fff92 100644
--- a/doc/pub/week36/html/._week36-bs032.html
+++ b/doc/pub/week36/html/._week36-bs032.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -428,7 +313,7 @@ $$
41
42
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs033.html b/doc/pub/week36/html/._week36-bs033.html
index 19841cc7c..fedc3e064 100644
--- a/doc/pub/week36/html/._week36-bs033.html
+++ b/doc/pub/week36/html/._week36-bs033.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -443,7 +328,7 @@ mean value \( \boldsymbol{X}\boldsymbol{\beta} \) and variance \( \sigma^2 \) (n
42
43
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs034.html b/doc/pub/week36/html/._week36-bs034.html
index b499096b2..d98b12724 100644
--- a/doc/pub/week36/html/._week36-bs034.html
+++ b/doc/pub/week36/html/._week36-bs034.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -492,7 +377,7 @@ This means the variance we obtain with the standard OLS will always for \( \lamb
43
44
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs035.html b/doc/pub/week36/html/._week36-bs035.html
index 99c14fbe0..5a6d754fb 100644
--- a/doc/pub/week36/html/._week36-bs035.html
+++ b/doc/pub/week36/html/._week36-bs035.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -432,7 +317,7 @@ $$
44
45
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs036.html b/doc/pub/week36/html/._week36-bs036.html
index 9ddbe8264..614c2dde9 100644
--- a/doc/pub/week36/html/._week36-bs036.html
+++ b/doc/pub/week36/html/._week36-bs036.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -445,7 +330,7 @@ It is a conditional probability (see below) and reads as the likelihood of a dom
45
46
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs037.html b/doc/pub/week36/html/._week36-bs037.html
index bd692b60d..0acc4016c 100644
--- a/doc/pub/week36/html/._week36-bs037.html
+++ b/doc/pub/week36/html/._week36-bs037.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -438,7 +323,7 @@ is equivalent to the maximization/minimization of the function itself.
46
47
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs038.html b/doc/pub/week36/html/._week36-bs038.html
index 0e41a4d0f..5ff7c9705 100644
--- a/doc/pub/week36/html/._week36-bs038.html
+++ b/doc/pub/week36/html/._week36-bs038.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -440,7 +325,7 @@ Before we make a similar analysis for Ridge and Lasso regression, we need a shor
47
48
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs039.html b/doc/pub/week36/html/._week36-bs039.html
index efef643ce..dd46a25c2 100644
--- a/doc/pub/week36/html/._week36-bs039.html
+++ b/doc/pub/week36/html/._week36-bs039.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -451,7 +336,7 @@ If we have independent events then \( p(X,Y)=p(X)p(Y) \).
48
49
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs040.html b/doc/pub/week36/html/._week36-bs040.html
index d4adb8933..7f38a5df1 100644
--- a/doc/pub/week36/html/._week36-bs040.html
+++ b/doc/pub/week36/html/._week36-bs040.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -425,7 +310,7 @@ $$
49
50
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/._week36-bs041.html b/doc/pub/week36/html/._week36-bs041.html
index 4360d729d..e96ca3f40 100644
--- a/doc/pub/week36/html/._week36-bs041.html
+++ b/doc/pub/week36/html/._week36-bs041.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -424,8 +309,6 @@ $$
49
50
51
- ...
- 78
»
diff --git a/doc/pub/week36/html/._week36-bs042.html b/doc/pub/week36/html/._week36-bs042.html
index eb533a713..5e87f317a 100644
--- a/doc/pub/week36/html/._week36-bs042.html
+++ b/doc/pub/week36/html/._week36-bs042.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -425,9 +310,6 @@ which is Bayes' theorem. It allows us to evaluate the uncertainty in in \( X \)
49
50
51
- 52
- ...
- 78
»
diff --git a/doc/pub/week36/html/._week36-bs043.html b/doc/pub/week36/html/._week36-bs043.html
index 6310d93a6..c907e1798 100644
--- a/doc/pub/week36/html/._week36-bs043.html
+++ b/doc/pub/week36/html/._week36-bs043.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -422,10 +307,6 @@ Let us try to illustrate Bayes' theorem through an example.
49
50
51
- 52
- 53
- ...
- 78
»
diff --git a/doc/pub/week36/html/._week36-bs044.html b/doc/pub/week36/html/._week36-bs044.html
index 2f14a4961..75e5def13 100644
--- a/doc/pub/week36/html/._week36-bs044.html
+++ b/doc/pub/week36/html/._week36-bs044.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -431,11 +316,6 @@ It is however not correct, as the following Bayesian analysis shows.
49
50
51
- 52
- 53
- 54
- ...
- 78
»
diff --git a/doc/pub/week36/html/._week36-bs045.html b/doc/pub/week36/html/._week36-bs045.html
index fa4ac8d8d..4ae0e583f 100644
--- a/doc/pub/week36/html/._week36-bs045.html
+++ b/doc/pub/week36/html/._week36-bs045.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -431,12 +316,6 @@ That is, in case of a positive test, there is only a \( 3\% \) chance of having
49
50
51
- 52
- 53
- 54
- 55
- ...
- 78
»
diff --git a/doc/pub/week36/html/._week36-bs046.html b/doc/pub/week36/html/._week36-bs046.html
index d5313b9d6..c0a166068 100644
--- a/doc/pub/week36/html/._week36-bs046.html
+++ b/doc/pub/week36/html/._week36-bs046.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -416,13 +301,6 @@ Before we proceed let us perform a Ridge, Lasso and OLS analysis of a polynomia
49
50
51
- 52
- 53
- 54
- 55
- 56
- ...
- 78
»
diff --git a/doc/pub/week36/html/._week36-bs047.html b/doc/pub/week36/html/._week36-bs047.html
index a14910b69..64d5af23a 100644
--- a/doc/pub/week36/html/._week36-bs047.html
+++ b/doc/pub/week36/html/._week36-bs047.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -486,14 +371,6 @@ How can we understand this?
49
50
51
- 52
- 53
- 54
- 55
- 56
- 57
- ...
- 78
»
diff --git a/doc/pub/week36/html/._week36-bs048.html b/doc/pub/week36/html/._week36-bs048.html
index b54ef4685..5a9c8b66e 100644
--- a/doc/pub/week36/html/._week36-bs048.html
+++ b/doc/pub/week36/html/._week36-bs048.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -435,15 +320,6 @@ We have a model for \( p(\boldsymbol{D}\vert\boldsymbol{\beta}) \) but need one
49
50
51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- ...
- 78
»
diff --git a/doc/pub/week36/html/._week36-bs049.html b/doc/pub/week36/html/._week36-bs049.html
index 8297c7e56..9edc8781f 100644
--- a/doc/pub/week36/html/._week36-bs049.html
+++ b/doc/pub/week36/html/._week36-bs049.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -440,16 +325,6 @@ which is our Ridge cost function! Nice, isn't it?
49
50
51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- ...
- 78
»
diff --git a/doc/pub/week36/html/._week36-bs050.html b/doc/pub/week36/html/._week36-bs050.html
index 44968fcb3..b2669039c 100644
--- a/doc/pub/week36/html/._week36-bs050.html
+++ b/doc/pub/week36/html/._week36-bs050.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -415,9 +300,8 @@ $$
C(\boldsymbol{\beta}=\frac{\vert\vert (\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})\vert\vert_2^2}{2\sigma^2}+\lambda\vert\vert\boldsymbol{\beta}\vert\vert_1,
$$
-which is our Lasso cost function!
+which is our Lasso cost function!
-
diff --git a/doc/pub/week36/html/week36-bs.html b/doc/pub/week36/html/week36-bs.html
index 923ed3495..11ff82d8c 100644
--- a/doc/pub/week36/html/week36-bs.html
+++ b/doc/pub/week36/html/week36-bs.html
@@ -167,95 +167,7 @@ Automatically generated HTML file from DocOnce source
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -343,33 +255,6 @@ MathJax.Hub.Config({
Invoking Bayes' theorem
Ridge and Bayes
Lasso and Bayes
- Why resampling methods
- Resampling methods
- Resampling approaches can be computationally expensive
- Why resampling methods ?
- Statistical analysis
- Resampling methods
- Resampling methods: Jackknife and Bootstrap
- Resampling methods: Jackknife
- Jackknife code example
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Code example for the Bootstrap method
- Various steps in cross-validation
- How to set up the cross-validation for Ridge and/or Lasso
- Cross-validation in brief
- Code Example for Cross-validation and \( k \)-fold Cross-validation
- The bias-variance tradeoff
- Example code for Bias-Variance tradeoff
- Understanding what happens
- Summing up
- Another Example from Scikit-Learn's Repository
- More examples on bootstrap and cross-validation and errors
- The same example but now with cross-validation
- Cross-validation with Ridge
@@ -428,7 +313,7 @@ MathJax.Hub.Config({
9
10
...
- 78
+ 51
»
diff --git a/doc/pub/week36/html/week36-reveal.html b/doc/pub/week36/html/week36-reveal.html
index 2f60327d9..e7ceb1224 100644
--- a/doc/pub/week36/html/week36-reveal.html
+++ b/doc/pub/week36/html/week36-reveal.html
@@ -2243,1100 +2243,6 @@ which is our Lasso cost function!
-
-Why resampling methods
-
-
-Before we proceed, we need to rethink what we have been doing. In our
-eager to fit the data, we have omitted several important elements in
-our regression analysis. In what follows we will
-
-
-- look at statistical properties, including a discussion of mean values, variance and the so-called bias-variance tradeoff
-- introduce resampling techniques like cross-validation, bootstrapping and jackknife and more
-
-
-
-This will allow us to link the standard linear algebra methods we have discussed above to a statistical interpretation of the methods.
-
-
-
-
-Resampling methods
-
-
-
-Resampling methods are an indispensable tool in modern
-statistics. They involve repeatedly drawing samples from a training
-set and refitting a model of interest on each sample in order to
-obtain additional information about the fitted model. For example, in
-order to estimate the variability of a linear regression fit, we can
-repeatedly draw different samples from the training data, fit a linear
-regression to each new sample, and then examine the extent to which
-the resulting fits differ. Such an approach may allow us to obtain
-information that would not be available from fitting the model only
-once using the original training sample.
-
-
-Two resampling methods are often used in Machine Learning analyses,
-
-
-- The bootstrap method
-- and Cross-Validation
-
-
-
-In addition there are several other methods such as the Jackknife and the Blocking methods. We will discuss in particular
-cross-validation and the bootstrap method.
-
-
-
-
-
-
-
-Resampling approaches can be computationally expensive
-
-
-
-Resampling approaches can be computationally expensive, because they
-involve fitting the same statistical method multiple times using
-different subsets of the training data. However, due to recent
-advances in computing power, the computational requirements of
-resampling methods generally are not prohibitive. In this chapter, we
-discuss two of the most commonly used resampling methods,
-cross-validation and the bootstrap. Both methods are important tools
-in the practical application of many statistical learning
-procedures. For example, cross-validation can be used to estimate the
-test error associated with a given statistical learning method in
-order to evaluate its performance, or to select the appropriate level
-of flexibility. The process of evaluating a model’s performance is
-known as model assessment, whereas the process of selecting the proper
-level of flexibility for a model is known as model selection. The
-bootstrap is widely used.
-
-
-
-
-
-
-
-Why resampling methods ?
-
-
Statistical analysis
-
-- Our simulations can be treated as computer experiments. This is particularly the case for Monte Carlo methods
-- The results can be analysed with the same statistical tools as we would use analysing experimental data.
-- As in all experiments, we are looking for expectation values and an estimate of how accurate they are, i.e., possible sources for errors.
-
-
-
-
-
-
-Statistical analysis
-
-
-
-- As in other experiments, many numerical experiments have two classes of errors:
-
-
-
-- Statistical errors
-
-- Systematical errors
-
-- Statistical errors can be estimated using standard tools from statistics
-- Systematical errors are method specific and must be treated differently from case to case.
-
-
-
-
-
-
-Resampling methods
-
-
-With all these analytical equations for both the OLS and Ridge
-regression, we will now outline how to assess a given model. This will
-lead us to a discussion of the so-called bias-variance tradeoff (see
-below) and so-called resampling methods.
-
-
-One of the quantities we have discussed as a way to measure errors is
-the mean-squared error (MSE), mainly used for fitting of continuous
-functions. Another choice is the absolute error.
-
-
-In the discussions below we will focus on the MSE and in particular since we will split the data into test and training data,
-we discuss the
-
-
-- prediction error or simply the test error \( \mathrm{Err_{Test}} \), where we have a fixed training set and the test error is the MSE arising from the data reserved for testing. We discuss also the
-- training error \( \mathrm{Err_{Train}} \), which is the average loss over the training data.
-
-
-
-As our model becomes more and more complex, more of the training data tends to used. The training may thence adapt to more complicated structures in the data. This may lead to a decrease in the bias (see below for code example) and a slight increase of the variance for the test error.
-For a certain level of complexity the test error will reach minimum, before starting to increase again. The
-training error reaches a saturation.
-
-
-
-
-Resampling methods: Jackknife and Bootstrap
-
-
-Two famous
-resampling methods are the independent bootstrap and the jackknife.
-
-
-The jackknife is a special case of the independent bootstrap. Still, the jackknife was made
-popular prior to the independent bootstrap. And as the popularity of
-the independent bootstrap soared, new variants, such as the dependent bootstrap.
-
-
-The Jackknife and independent bootstrap work for
-independent, identically distributed random variables.
-If these conditions are not
-satisfied, the methods will fail. Yet, it should be said that if the data are
-independent, identically distributed, and we only want to estimate the
-variance of \( \overline{X} \) (which often is the case), then there is no
-need for bootstrapping.
-
-
-
-
-Resampling methods: Jackknife
-
-
-The Jackknife works by making many replicas of the estimator \( \widehat{\theta} \).
-The jackknife is a resampling method where we systematically leave out one observation from the vector of observed values \( \boldsymbol{x} = (x_1,x_2,\cdots,X_n) \).
-Let \( \boldsymbol{x}_i \) denote the vector
-
-$$
-\boldsymbol{x}_i = (x_1,x_2,\cdots,x_{i-1},x_{i+1},\cdots,x_n),
-$$
-
-
-
-which equals the vector \( \boldsymbol{x} \) with the exception that observation
-number \( i \) is left out. Using this notation, define
-\( \widehat{\theta}_i \) to be the estimator
-\( \widehat{\theta} \) computed using \( \vec{X}_i \).
-
-
-
-
-Jackknife code example
-
-
-
-
from numpy import *
-from numpy.random import randint, randn
-from time import time
-
-def jackknife(data, stat):
- n = len(data);t = zeros(n); inds = arange(n); t0 = time()
- ## 'jackknifing' by leaving out an observation for each i
- for i in range(n):
- t[i] = stat(delete(data,i) )
-
- # analysis
- print("Runtime: %g sec" % (time()-t0)); print("Jackknife Statistics :")
- print("original bias std. error")
- print("%8g %14g %15g" % (stat(data),(n-1)*mean(t)/n, (n*var(t))**.5))
-
- return t
-
-
-# Returns mean of data samples
-def stat(data):
- return mean(data)
-
-
-mu, sigma = 100, 15
-datapoints = 10000
-x = mu + sigma*random.randn(datapoints)
-# jackknife returns the data sample
-t = jackknife(x, stat)
-
-
-
-
-
-Resampling methods: Bootstrap
-
-
-
-Bootstrapping is a nonparametric approach to statistical inference
-that substitutes computation for more traditional distributional
-assumptions and asymptotic results. Bootstrapping offers a number of
-advantages:
-
-
-- The bootstrap is quite general, although there are some cases in which it fails.
-
-- Because it does not require distributional assumptions (such as normally distributed errors), the bootstrap can provide more accurate inferences when the data are not well behaved or when the sample size is small.
-
-- It is possible to apply the bootstrap to statistics with sampling distributions that are difficult to derive, even asymptotically.
-- It is relatively simple to apply the bootstrap to complex data-collection plans (such as stratified and clustered samples).
-
-
-
-
-
-
-Resampling methods: Bootstrap background
-
-
-Since \( \widehat{\theta} = \widehat{\theta}(\boldsymbol{X}) \) is a function of random variables,
-\( \widehat{\theta} \) itself must be a random variable. Thus it has
-a pdf, call this function \( p(\boldsymbol{t}) \). The aim of the bootstrap is to
-estimate \( p(\boldsymbol{t}) \) by the relative frequency of
-\( \widehat{\theta} \). You can think of this as using a histogram
-in the place of \( p(\boldsymbol{t}) \). If the relative frequency closely
-resembles \( p(\vec{t}) \), then using numerics, it is straight forward to
-estimate all the interesting parameters of \( p(\boldsymbol{t}) \) using point
-estimators.
-
-
-
-
-Resampling methods: More Bootstrap background
-
-
-In the case that \( \widehat{\theta} \) has
-more than one component, and the components are independent, we use the
-same estimator on each component separately. If the probability
-density function of \( X_i \), \( p(x) \), had been known, then it would have
-been straight forward to do this by:
-
-
-- Drawing lots of numbers from \( p(x) \), suppose we call one such set of numbers \( (X_1^*, X_2^*, \cdots, X_n^*) \).
-- Then using these numbers, we could compute a replica of \( \widehat{\theta} \) called \( \widehat{\theta}^* \).
-
-
-
-By repeated use of (1) and (2), many
-estimates of \( \widehat{\theta} \) could have been obtained. The
-idea is to use the relative frequency of \( \widehat{\theta}^* \)
-(think of a histogram) as an estimate of \( p(\boldsymbol{t}) \).
-
-
-
-
-Resampling methods: Bootstrap approach
-
-
-But
-unless there is enough information available about the process that
-generated \( X_1,X_2,\cdots,X_n \), \( p(x) \) is in general
-unknown. Therefore, Efron in 1979 asked the
-question: What if we replace \( p(x) \) by the relative frequency
-of the observation \( X_i \); if we draw observations in accordance with
-the relative frequency of the observations, will we obtain the same
-result in some asymptotic sense? The answer is yes.
-
-
-Instead of generating the histogram for the relative
-frequency of the observation \( X_i \), just draw the values
-\( (X_1^*,X_2^*,\cdots,X_n^*) \) with replacement from the vector
-\( \boldsymbol{X} \).
-
-
-
-
-Resampling methods: Bootstrap steps
-
-
-The independent bootstrap works like this:
-
-
-- Draw with replacement \( n \) numbers for the observed variables \( \boldsymbol{x} = (x_1,x_2,\cdots,x_n) \).
-- Define a vector \( \boldsymbol{x}^* \) containing the values which were drawn from \( \boldsymbol{x} \).
-- Using the vector \( \boldsymbol{x}^* \) compute \( \widehat{\theta}^* \) by evaluating \( \widehat \theta \) under the observations \( \boldsymbol{x}^* \).
-- Repeat this process \( k \) times.
-
-
-
-When you are done, you can draw a histogram of the relative frequency
-of \( \widehat \theta^* \). This is your estimate of the probability
-distribution \( p(t) \). Using this probability distribution you can
-estimate any statistics thereof. In principle you never draw the
-histogram of the relative frequency of \( \widehat{\theta}^* \). Instead
-you use the estimators corresponding to the statistic of interest. For
-example, if you are interested in estimating the variance of \( \widehat
-\theta \), apply the etsimator \( \widehat \sigma^2 \) to the values
-\( \widehat \theta ^* \).
-
-
-
-
-Code example for the Bootstrap method
-
-
-The following code starts with a Gaussian distribution with mean value
-\( \mu =100 \) and variance \( \sigma=15 \). We use this to generate the data
-used in the bootstrap analysis. The bootstrap analysis returns a data
-set after a given number of bootstrap operations (as many as we have
-data points). This data set consists of estimated mean values for each
-bootstrap operation. The histogram generated by the bootstrap method
-shows that the distribution for these mean values is also a Gaussian,
-centered around the mean value \( \mu=100 \) but with standard deviation
-\( \sigma/\sqrt{n} \), where \( n \) is the number of bootstrap samples (in
-this case the same as the number of original data points). The value
-of the standard deviation is what we expect from the central limit
-theorem.
-
-
-
-
-
from numpy import *
-from numpy.random import randint, randn
-from time import time
-import matplotlib.mlab as mlab
-import matplotlib.pyplot as plt
-
-# Returns mean of bootstrap samples
-def stat(data):
- return mean(data)
-
-# Bootstrap algorithm
-def bootstrap(data, statistic, R):
- t = zeros(R); n = len(data); inds = arange(n); t0 = time()
- # non-parametric bootstrap
- for i in range(R):
- t[i] = statistic(data[randint(0,n,n)])
-
- # analysis
- print("Runtime: %g sec" % (time()-t0)); print("Bootstrap Statistics :")
- print("original bias std. error")
- print("%8g %8g %14g %15g" % (statistic(data), std(data),mean(t),std(t)))
- return t
-
-
-mu, sigma = 100, 15
-datapoints = 10000
-x = mu + sigma*random.randn(datapoints)
-# bootstrap returns the data sample
-t = bootstrap(x, stat, datapoints)
-# the histogram of the bootstrapped data
-n, binsboot, patches = plt.hist(t, 50, normed=1, facecolor='red', alpha=0.75)
-
-# add a 'best fit' line
-y = mlab.normpdf( binsboot, mean(t), std(t))
-lt = plt.plot(binsboot, y, 'r--', linewidth=1)
-plt.xlabel('Smarts')
-plt.ylabel('Probability')
-plt.axis([99.5, 100.6, 0, 3.0])
-plt.grid(True)
-
-plt.show()
-
-
-
-
-
-Various steps in cross-validation
-
-
-When the repetitive splitting of the data set is done randomly,
-samples may accidently end up in a fast majority of the splits in
-either training or test set. Such samples may have an unbalanced
-influence on either model building or prediction evaluation. To avoid
-this \( k \)-fold cross-validation structures the data splitting. The
-samples are divided into \( k \) more or less equally sized exhaustive and
-mutually exclusive subsets. In turn (at each split) one of these
-subsets plays the role of the test set while the union of the
-remaining subsets constitutes the training set. Such a splitting
-warrants a balanced representation of each sample in both training and
-test set over the splits. Still the division into the \( k \) subsets
-involves a degree of randomness. This may be fully excluded when
-choosing \( k=n \). This particular case is referred to as leave-one-out
-cross-validation (LOOCV).
-
-
-
-
-How to set up the cross-validation for Ridge and/or Lasso
-
-
-- Define a range of interest for the penalty parameter.
-- Divide the data set into training and test set comprising samples \( \{1, \ldots, n\} \setminus i \) and \( \{ i \} \), respectively.
-- Fit the linear regression model by means of ridge estimation for each \( \lambda \) in the grid using the training set, and the corresponding estimate of the error variance \( \boldsymbol{\sigma}_{-i}^2(\lambda) \), as
-
-
-$$
-\begin{align*}
-\boldsymbol{\beta}_{-i}(\lambda) & = ( \boldsymbol{X}_{-i, \ast}^{T}
-\boldsymbol{X}_{-i, \ast} + \lambda \boldsymbol{I}_{pp})^{-1}
-\boldsymbol{X}_{-i, \ast}^{T} \boldsymbol{y}_{-i}
-\end{align*}
-$$
-
-
-
-
-- Evaluate the prediction performance of these models on the test set by \( \log\{L[y_i, \boldsymbol{X}_{i, \ast}; \boldsymbol{\beta}_{-i}(\lambda), \boldsymbol{\sigma}_{-i}^2(\lambda)]\} \). Or, by the prediction error \( |y_i - \boldsymbol{X}_{i, \ast} \boldsymbol{\beta}_{-i}(\lambda)| \), the relative error, the error squared or the R2 score function.
-- Repeat the first three steps such that each sample plays the role of the test set once.
-- Average the prediction performances of the test sets at each grid point of the penalty bias/parameter. It is an estimate of the prediction performance of the model corresponding to this value of the penalty parameter on novel data. It is defined as
-
-
-$$
-\begin{align*}
-\frac{1}{n} \sum_{i = 1}^n \log\{L[y_i, \mathbf{X}_{i, \ast}; \boldsymbol{\beta}_{-i}(\lambda), \boldsymbol{\sigma}_{-i}^2(\lambda)]\}.
-\end{align*}
-$$
-
-
-
-
-
-Cross-validation in brief
-
-
-For the various values of \( k \)
-
-
-- shuffle the dataset randomly.
-- Split the dataset into \( k \) groups.
-- For each unique group:
-
-
-- Decide which group to use as set for test data
-- Take the remaining groups as a training data set
-- Fit a model on the training set and evaluate it on the test set
-- Retain the evaluation score and discard the model
-
- Summarize the model using the sample of model evaluation scores
-
-
-
-
-
-Code Example for Cross-validation and \( k \)-fold Cross-validation
-
-
-The code here uses Ridge regression with cross-validation (CV) resampling and \( k \)-fold CV in order to fit a specific polynomial.
-
-
-
-
import numpy as np
-import matplotlib.pyplot as plt
-from sklearn.model_selection import KFold
-from sklearn.linear_model import Ridge
-from sklearn.model_selection import cross_val_score
-from sklearn.preprocessing import PolynomialFeatures
-
-# A seed just to ensure that the random numbers are the same for every run.
-# Useful for eventual debugging.
-np.random.seed(3155)
-
-# Generate the data.
-nsamples = 100
-x = np.random.randn(nsamples)
-y = 3*x**2 + np.random.randn(nsamples)
-
-## Cross-validation on Ridge regression using KFold only
-
-# Decide degree on polynomial to fit
-poly = PolynomialFeatures(degree = 6)
-
-# Decide which values of lambda to use
-nlambdas = 500
-lambdas = np.logspace(-3, 5, nlambdas)
-
-# Initialize a KFold instance
-k = 5
-kfold = KFold(n_splits = k)
-
-# Perform the cross-validation to estimate MSE
-scores_KFold = np.zeros((nlambdas, k))
-
-i = 0
-for lmb in lambdas:
- ridge = Ridge(alpha = lmb)
- j = 0
- for train_inds, test_inds in kfold.split(x):
- xtrain = x[train_inds]
- ytrain = y[train_inds]
-
- xtest = x[test_inds]
- ytest = y[test_inds]
-
- Xtrain = poly.fit_transform(xtrain[:, np.newaxis])
- ridge.fit(Xtrain, ytrain[:, np.newaxis])
-
- Xtest = poly.fit_transform(xtest[:, np.newaxis])
- ypred = ridge.predict(Xtest)
-
- scores_KFold[i,j] = np.sum((ypred - ytest[:, np.newaxis])**2)/np.size(ypred)
-
- j += 1
- i += 1
-
-
-estimated_mse_KFold = np.mean(scores_KFold, axis = 1)
-
-## Cross-validation using cross_val_score from sklearn along with KFold
-
-# kfold is an instance initialized above as:
-# kfold = KFold(n_splits = k)
-
-estimated_mse_sklearn = np.zeros(nlambdas)
-i = 0
-for lmb in lambdas:
- ridge = Ridge(alpha = lmb)
-
- X = poly.fit_transform(x[:, np.newaxis])
- estimated_mse_folds = cross_val_score(ridge, X, y[:, np.newaxis], scoring='neg_mean_squared_error', cv=kfold)
-
- # cross_val_score return an array containing the estimated negative mse for every fold.
- # we have to the the mean of every array in order to get an estimate of the mse of the model
- estimated_mse_sklearn[i] = np.mean(-estimated_mse_folds)
-
- i += 1
-
-## Plot and compare the slightly different ways to perform cross-validation
-
-plt.figure()
-
-plt.plot(np.log10(lambdas), estimated_mse_sklearn, label = 'cross_val_score')
-plt.plot(np.log10(lambdas), estimated_mse_KFold, 'r--', label = 'KFold')
-
-plt.xlabel('log10(lambda)')
-plt.ylabel('mse')
-
-plt.legend()
-
-plt.show()
-
-
-
-
-
-The bias-variance tradeoff
-
-
-We will discuss the bias-variance tradeoff in the context of
-continuous predictions such as regression. However, many of the
-intuitions and ideas discussed here also carry over to classification
-tasks. Consider a dataset \( \mathcal{L} \) consisting of the data
-\( \mathbf{X}_\mathcal{L}=\{(y_j, \boldsymbol{x}_j), j=0\ldots n-1\} \).
-
-
-Let us assume that the true data is generated from a noisy model
-
-
-$$
-\boldsymbol{y}=f(\boldsymbol{x}) + \boldsymbol{\epsilon}
-$$
-
-
-
-where \( \epsilon \) is normally distributed with mean zero and standard deviation \( \sigma^2 \).
-
-
-In our derivation of the ordinary least squares method we defined then
-an approximation to the function \( f \) in terms of the parameters
-\( \boldsymbol{\beta} \) and the design matrix \( \boldsymbol{X} \) which embody our model,
-that is \( \boldsymbol{\tilde{y}}=\boldsymbol{X}\boldsymbol{\beta} \).
-
-
-Thereafter we found the parameters \( \boldsymbol{\beta} \) by optimizing the means squared error via the so-called cost function
-
-$$
-C(\boldsymbol{X},\boldsymbol{\beta}) =\frac{1}{n}\sum_{i=0}^{n-1}(y_i-\tilde{y}_i)^2=\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right].
-$$
-
-
-
-We can rewrite this as
-
-$$
-\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\frac{1}{n}\sum_i(f_i-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2+\frac{1}{n}\sum_i(\tilde{y}_i-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2+\sigma^2.
-$$
-
-
-
-The three terms represent the square of the bias of the learning
-method, which can be thought of as the error caused by the simplifying
-assumptions built into the method. The second term represents the
-variance of the chosen model and finally the last terms is variance of
-the error \( \boldsymbol{\epsilon} \).
-
-
-To derive this equation, we need to recall that the variance of \( \boldsymbol{y} \) and \( \boldsymbol{\epsilon} \) are both equal to \( \sigma^2 \). The mean value of \( \boldsymbol{\epsilon} \) is by definition equal to zero. Furthermore, the function \( f \) is not a stochastics variable, idem for \( \boldsymbol{\tilde{y}} \).
-We use a more compact notation in terms of the expectation value
-
-$$
-\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\mathbb{E}\left[(\boldsymbol{f}+\boldsymbol{\epsilon}-\boldsymbol{\tilde{y}})^2\right],
-$$
-
-
-and adding and subtracting \( \mathbb{E}\left[\boldsymbol{\tilde{y}}\right] \) we get
-
-$$
-\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\mathbb{E}\left[(\boldsymbol{f}+\boldsymbol{\epsilon}-\boldsymbol{\tilde{y}}+\mathbb{E}\left[\boldsymbol{\tilde{y}}\right]-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2\right],
-$$
-
-
-which, using the abovementioned expectation values can be rewritten as
-
-$$
-\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\mathbb{E}\left[(\boldsymbol{y}-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2\right]+\mathrm{Var}\left[\boldsymbol{\tilde{y}}\right]+\sigma^2,
-$$
-
-
-that is the rewriting in terms of the so-called bias, the variance of the model \( \boldsymbol{\tilde{y}} \) and the variance of \( \boldsymbol{\epsilon} \).
-
-
-
-
-Example code for Bias-Variance tradeoff
-
-
-
-
import matplotlib.pyplot as plt
-import numpy as np
-from sklearn.linear_model import LinearRegression, Ridge, Lasso
-from sklearn.preprocessing import PolynomialFeatures
-from sklearn.model_selection import train_test_split
-from sklearn.pipeline import make_pipeline
-from sklearn.utils import resample
-
-np.random.seed(2018)
-
-n = 500
-n_boostraps = 100
-degree = 18 # A quite high value, just to show.
-noise = 0.1
-
-# Make data set.
-x = np.linspace(-1, 3, n).reshape(-1, 1)
-y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2) + np.random.normal(0, 0.1, x.shape)
-
-# Hold out some test data that is never used in training.
-x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
-
-# Combine x transformation and model into one operation.
-# Not neccesary, but convenient.
-model = make_pipeline(PolynomialFeatures(degree=degree), LinearRegression(fit_intercept=False))
-
-# The following (m x n_bootstraps) matrix holds the column vectors y_pred
-# for each bootstrap iteration.
-y_pred = np.empty((y_test.shape[0], n_boostraps))
-for i in range(n_boostraps):
- x_, y_ = resample(x_train, y_train)
-
- # Evaluate the new model on the same test data each time.
- y_pred[:, i] = model.fit(x_, y_).predict(x_test).ravel()
-
-# Note: Expectations and variances taken w.r.t. different training
-# data sets, hence the axis=1. Subsequent means are taken across the test data
-# set in order to obtain a total value, but before this we have error/bias/variance
-# calculated per data point in the test set.
-# Note 2: The use of keepdims=True is important in the calculation of bias as this
-# maintains the column vector form. Dropping this yields very unexpected results.
-error = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) )
-bias = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 )
-variance = np.mean( np.var(y_pred, axis=1, keepdims=True) )
-print('Error:', error)
-print('Bias^2:', bias)
-print('Var:', variance)
-print('{} >= {} + {} = {}'.format(error, bias, variance, bias+variance))
-
-plt.plot(x[::5, :], y[::5, :], label='f(x)')
-plt.scatter(x_test, y_test, label='Data points')
-plt.scatter(x_test, np.mean(y_pred, axis=1), label='Pred')
-plt.legend()
-plt.show()
-
-
-
-
-
-Understanding what happens
-
-
-
-
import matplotlib.pyplot as plt
-import numpy as np
-from sklearn.linear_model import LinearRegression, Ridge, Lasso
-from sklearn.preprocessing import PolynomialFeatures
-from sklearn.model_selection import train_test_split
-from sklearn.pipeline import make_pipeline
-from sklearn.utils import resample
-
-np.random.seed(2018)
-
-n = 40
-n_boostraps = 100
-maxdegree = 14
-
-
-# Make data set.
-x = np.linspace(-3, 3, n).reshape(-1, 1)
-y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape)
-error = np.zeros(maxdegree)
-bias = np.zeros(maxdegree)
-variance = np.zeros(maxdegree)
-polydegree = np.zeros(maxdegree)
-x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
-
-for degree in range(maxdegree):
- model = make_pipeline(PolynomialFeatures(degree=degree), LinearRegression(fit_intercept=False))
- y_pred = np.empty((y_test.shape[0], n_boostraps))
- for i in range(n_boostraps):
- x_, y_ = resample(x_train, y_train)
- y_pred[:, i] = model.fit(x_, y_).predict(x_test).ravel()
-
- polydegree[degree] = degree
- error[degree] = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) )
- bias[degree] = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 )
- variance[degree] = np.mean( np.var(y_pred, axis=1, keepdims=True) )
- print('Polynomial degree:', degree)
- print('Error:', error[degree])
- print('Bias^2:', bias[degree])
- print('Var:', variance[degree])
- print('{} >= {} + {} = {}'.format(error[degree], bias[degree], variance[degree], bias[degree]+variance[degree]))
-
-plt.plot(polydegree, error, label='Error')
-plt.plot(polydegree, bias, label='bias')
-plt.plot(polydegree, variance, label='Variance')
-plt.legend()
-plt.show()
-
-
-
-
-
-Summing up
-
-
-The bias-variance tradeoff summarizes the fundamental tension in
-machine learning, particularly supervised learning, between the
-complexity of a model and the amount of training data needed to train
-it. Since data is often limited, in practice it is often useful to
-use a less-complex model with higher bias, that is a model whose asymptotic
-performance is worse than another model because it is easier to
-train and less sensitive to sampling noise arising from having a
-finite-sized training dataset (smaller variance).
-
-
-The above equations tell us that in
-order to minimize the expected test error, we need to select a
-statistical learning method that simultaneously achieves low variance
-and low bias. Note that variance is inherently a nonnegative quantity,
-and squared bias is also nonnegative. Hence, we see that the expected
-test MSE can never lie below \( Var(\epsilon) \), the irreducible error.
-
-
-What do we mean by the variance and bias of a statistical learning
-method? The variance refers to the amount by which our model would change if we
-estimated it using a different training data set. Since the training
-data are used to fit the statistical learning method, different
-training data sets will result in a different estimate. But ideally the
-estimate for our model should not vary too much between training
-sets. However, if a method has high variance then small changes in
-the training data can result in large changes in the model. In general, more
-flexible statistical methods have higher variance.
-
-
-You may also find this recent article of interest.
-
-
-
-
-Another Example from Scikit-Learn's Repository
-
-
-
-
"""
-============================
-Underfitting vs. Overfitting
-============================
-
-This example demonstrates the problems of underfitting and overfitting and
-how we can use linear regression with polynomial features to approximate
-nonlinear functions. The plot shows the function that we want to approximate,
-which is a part of the cosine function. In addition, the samples from the
-real function and the approximations of different models are displayed. The
-models have polynomial features of different degrees. We can see that a
-linear function (polynomial with degree 1) is not sufficient to fit the
-training samples. This is called **underfitting**. A polynomial of degree 4
-approximates the true function almost perfectly. However, for higher degrees
-the model will **overfit** the training data, i.e. it learns the noise of the
-training data.
-We evaluate quantitatively **overfitting** / **underfitting** by using
-cross-validation. We calculate the mean squared error (MSE) on the validation
-set, the higher, the less likely the model generalizes correctly from the
-training data.
-"""
-
-print(__doc__)
-
-import numpy as np
-import matplotlib.pyplot as plt
-from sklearn.pipeline import Pipeline
-from sklearn.preprocessing import PolynomialFeatures
-from sklearn.linear_model import LinearRegression
-from sklearn.model_selection import cross_val_score
-
-
-def true_fun(X):
- return np.cos(1.5 * np.pi * X)
-
-np.random.seed(0)
-
-n_samples = 30
-degrees = [1, 4, 15]
-
-X = np.sort(np.random.rand(n_samples))
-y = true_fun(X) + np.random.randn(n_samples) * 0.1
-
-plt.figure(figsize=(14, 5))
-for i in range(len(degrees)):
- ax = plt.subplot(1, len(degrees), i + 1)
- plt.setp(ax, xticks=(), yticks=())
-
- polynomial_features = PolynomialFeatures(degree=degrees[i],
- include_bias=False)
- linear_regression = LinearRegression()
- pipeline = Pipeline([("polynomial_features", polynomial_features),
- ("linear_regression", linear_regression)])
- pipeline.fit(X[:, np.newaxis], y)
-
- # Evaluate the models using crossvalidation
- scores = cross_val_score(pipeline, X[:, np.newaxis], y,
- scoring="neg_mean_squared_error", cv=10)
-
- X_test = np.linspace(0, 1, 100)
- plt.plot(X_test, pipeline.predict(X_test[:, np.newaxis]), label="Model")
- plt.plot(X_test, true_fun(X_test), label="True function")
- plt.scatter(X, y, edgecolor='b', s=20, label="Samples")
- plt.xlabel("x")
- plt.ylabel("y")
- plt.xlim((0, 1))
- plt.ylim((-2, 2))
- plt.legend(loc="best")
- plt.title("Degree {}\nMSE = {:.2e}(+/- {:.2e})".format(
- degrees[i], -scores.mean(), scores.std()))
-plt.show()
-
-
-
-
-
-More examples on bootstrap and cross-validation and errors
-
-
-
-
-
# Common imports
-import os
-import numpy as np
-import pandas as pd
-import matplotlib.pyplot as plt
-from sklearn.linear_model import LinearRegression, Ridge, Lasso
-from sklearn.model_selection import train_test_split
-from sklearn.utils import resample
-from sklearn.metrics import mean_squared_error
-# Where to save the figures and data files
-PROJECT_ROOT_DIR = "Results"
-FIGURE_ID = "Results/FigureFiles"
-DATA_ID = "DataFiles/"
-
-if not os.path.exists(PROJECT_ROOT_DIR):
- os.mkdir(PROJECT_ROOT_DIR)
-
-if not os.path.exists(FIGURE_ID):
- os.makedirs(FIGURE_ID)
-
-if not os.path.exists(DATA_ID):
- os.makedirs(DATA_ID)
-
-def image_path(fig_id):
- return os.path.join(FIGURE_ID, fig_id)
-
-def data_path(dat_id):
- return os.path.join(DATA_ID, dat_id)
-
-def save_fig(fig_id):
- plt.savefig(image_path(fig_id) + ".png", format='png')
-
-infile = open(data_path("EoS.csv"),'r')
-
-# Read the EoS data as csv file and organize the data into two arrays with density and energies
-EoS = pd.read_csv(infile, names=('Density', 'Energy'))
-EoS['Energy'] = pd.to_numeric(EoS['Energy'], errors='coerce')
-EoS = EoS.dropna()
-Energies = EoS['Energy']
-Density = EoS['Density']
-# The design matrix now as function of various polytrops
-
-Maxpolydegree = 30
-X = np.zeros((len(Density),Maxpolydegree))
-X[:,0] = 1.0
-testerror = np.zeros(Maxpolydegree)
-trainingerror = np.zeros(Maxpolydegree)
-polynomial = np.zeros(Maxpolydegree)
-
-trials = 100
-for polydegree in range(1, Maxpolydegree):
- polynomial[polydegree] = polydegree
- for degree in range(polydegree):
- X[:,degree] = Density**(degree/3.0)
-
-# loop over trials in order to estimate the expectation value of the MSE
- testerror[polydegree] = 0.0
- trainingerror[polydegree] = 0.0
- for samples in range(trials):
- x_train, x_test, y_train, y_test = train_test_split(X, Energies, test_size=0.2)
- model = LinearRegression(fit_intercept=True).fit(x_train, y_train)
- ypred = model.predict(x_train)
- ytilde = model.predict(x_test)
- testerror[polydegree] += mean_squared_error(y_test, ytilde)
- trainingerror[polydegree] += mean_squared_error(y_train, ypred)
-
- testerror[polydegree] /= trials
- trainingerror[polydegree] /= trials
- print("Degree of polynomial: %3d"% polynomial[polydegree])
- print("Mean squared error on training data: %.8f" % trainingerror[polydegree])
- print("Mean squared error on test data: %.8f" % testerror[polydegree])
-
-plt.plot(polynomial, np.log10(trainingerror), label='Training Error')
-plt.plot(polynomial, np.log10(testerror), label='Test Error')
-plt.xlabel('Polynomial degree')
-plt.ylabel('log10[MSE]')
-plt.legend()
-plt.show()
-
-
-
-
-
-The same example but now with cross-validation
-
-
-
-
-
# Common imports
-import os
-import numpy as np
-import pandas as pd
-import matplotlib.pyplot as plt
-from sklearn.linear_model import LinearRegression, Ridge, Lasso
-from sklearn.metrics import mean_squared_error
-from sklearn.model_selection import KFold
-from sklearn.model_selection import cross_val_score
-
-
-# Where to save the figures and data files
-PROJECT_ROOT_DIR = "Results"
-FIGURE_ID = "Results/FigureFiles"
-DATA_ID = "DataFiles/"
-
-if not os.path.exists(PROJECT_ROOT_DIR):
- os.mkdir(PROJECT_ROOT_DIR)
-
-if not os.path.exists(FIGURE_ID):
- os.makedirs(FIGURE_ID)
-
-if not os.path.exists(DATA_ID):
- os.makedirs(DATA_ID)
-
-def image_path(fig_id):
- return os.path.join(FIGURE_ID, fig_id)
-
-def data_path(dat_id):
- return os.path.join(DATA_ID, dat_id)
-
-def save_fig(fig_id):
- plt.savefig(image_path(fig_id) + ".png", format='png')
-
-infile = open(data_path("EoS.csv"),'r')
-
-# Read the EoS data as csv file and organize the data into two arrays with density and energies
-EoS = pd.read_csv(infile, names=('Density', 'Energy'))
-EoS['Energy'] = pd.to_numeric(EoS['Energy'], errors='coerce')
-EoS = EoS.dropna()
-Energies = EoS['Energy']
-Density = EoS['Density']
-# The design matrix now as function of various polytrops
-
-Maxpolydegree = 30
-X = np.zeros((len(Density),Maxpolydegree))
-X[:,0] = 1.0
-estimated_mse_sklearn = np.zeros(Maxpolydegree)
-polynomial = np.zeros(Maxpolydegree)
-k =5
-kfold = KFold(n_splits = k)
-
-for polydegree in range(1, Maxpolydegree):
- polynomial[polydegree] = polydegree
- for degree in range(polydegree):
- X[:,degree] = Density**(degree/3.0)
- OLS = LinearRegression()
-# loop over trials in order to estimate the expectation value of the MSE
- estimated_mse_folds = cross_val_score(OLS, X, Energies, scoring='neg_mean_squared_error', cv=kfold)
-#[:, np.newaxis]
- estimated_mse_sklearn[polydegree] = np.mean(-estimated_mse_folds)
-
-plt.plot(polynomial, np.log10(estimated_mse_sklearn), label='Test Error')
-plt.xlabel('Polynomial degree')
-plt.ylabel('log10[MSE]')
-plt.legend()
-plt.show()
-
-
-
-
-
-Cross-validation with Ridge
-
-
-
-
import numpy as np
-import matplotlib.pyplot as plt
-from sklearn.model_selection import KFold
-from sklearn.linear_model import Ridge
-from sklearn.model_selection import cross_val_score
-from sklearn.preprocessing import PolynomialFeatures
-
-# A seed just to ensure that the random numbers are the same for every run.
-np.random.seed(3155)
-# Generate the data.
-n = 100
-x = np.linspace(-3, 3, n).reshape(-1, 1)
-y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape)
-# Decide degree on polynomial to fit
-poly = PolynomialFeatures(degree = 10)
-
-# Decide which values of lambda to use
-nlambdas = 500
-lambdas = np.logspace(-3, 5, nlambdas)
-# Initialize a KFold instance
-k = 5
-kfold = KFold(n_splits = k)
-estimated_mse_sklearn = np.zeros(nlambdas)
-i = 0
-for lmb in lambdas:
- ridge = Ridge(alpha = lmb)
- estimated_mse_folds = cross_val_score(ridge, x, y, scoring='neg_mean_squared_error', cv=kfold)
- estimated_mse_sklearn[i] = np.mean(-estimated_mse_folds)
- i += 1
-plt.figure()
-plt.plot(np.log10(lambdas), estimated_mse_sklearn, label = 'cross_val_score')
-plt.xlabel('log10(lambda)')
-plt.ylabel('MSE')
-plt.legend()
-plt.show()
-
-
-
-
diff --git a/doc/pub/week36/html/week36-solarized.html b/doc/pub/week36/html/week36-solarized.html
index feac94625..4c72ddc80 100644
--- a/doc/pub/week36/html/week36-solarized.html
+++ b/doc/pub/week36/html/week36-solarized.html
@@ -187,95 +187,7 @@ div { text-align: justify; text-justify: inter-word; }
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -2206,1081 +2118,7 @@ $$
C(\boldsymbol{\beta}=\frac{\vert\vert (\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})\vert\vert_2^2}{2\sigma^2}+\lambda\vert\vert\boldsymbol{\beta}\vert\vert_1,
$$
-which is our Lasso cost function!
-
-
-
-
-
Why resampling methods
-
-
-Before we proceed, we need to rethink what we have been doing. In our
-eager to fit the data, we have omitted several important elements in
-our regression analysis. In what follows we will
-
-
-- look at statistical properties, including a discussion of mean values, variance and the so-called bias-variance tradeoff
-- introduce resampling techniques like cross-validation, bootstrapping and jackknife and more
-
-
-This will allow us to link the standard linear algebra methods we have discussed above to a statistical interpretation of the methods.
-
-
-
-
-
Resampling methods
-
-
-
-Resampling methods are an indispensable tool in modern
-statistics. They involve repeatedly drawing samples from a training
-set and refitting a model of interest on each sample in order to
-obtain additional information about the fitted model. For example, in
-order to estimate the variability of a linear regression fit, we can
-repeatedly draw different samples from the training data, fit a linear
-regression to each new sample, and then examine the extent to which
-the resulting fits differ. Such an approach may allow us to obtain
-information that would not be available from fitting the model only
-once using the original training sample.
-
-
-Two resampling methods are often used in Machine Learning analyses,
-
-
-- The bootstrap method
-- and Cross-Validation
-
-
-In addition there are several other methods such as the Jackknife and the Blocking methods. We will discuss in particular
-cross-validation and the bootstrap method.
-
-
-
-
-
-
-
-
-
Resampling approaches can be computationally expensive
-
-
-
-
-
-Resampling approaches can be computationally expensive, because they
-involve fitting the same statistical method multiple times using
-different subsets of the training data. However, due to recent
-advances in computing power, the computational requirements of
-resampling methods generally are not prohibitive. In this chapter, we
-discuss two of the most commonly used resampling methods,
-cross-validation and the bootstrap. Both methods are important tools
-in the practical application of many statistical learning
-procedures. For example, cross-validation can be used to estimate the
-test error associated with a given statistical learning method in
-order to evaluate its performance, or to select the appropriate level
-of flexibility. The process of evaluating a model’s performance is
-known as model assessment, whereas the process of selecting the proper
-level of flexibility for a model is known as model selection. The
-bootstrap is widely used.
-
-
-
-
-
-
-
-
-
Why resampling methods ?
-
-
Statistical analysis
-
-
-
-- Our simulations can be treated as computer experiments. This is particularly the case for Monte Carlo methods
-- The results can be analysed with the same statistical tools as we would use analysing experimental data.
-- As in all experiments, we are looking for expectation values and an estimate of how accurate they are, i.e., possible sources for errors.
-
-
-
-
-
-
-
-
Statistical analysis
-
-
-
-
-
-- As in other experiments, many numerical experiments have two classes of errors:
-
-
- - Statistical errors
- - Systematical errors
-
-
-- Statistical errors can be estimated using standard tools from statistics
-- Systematical errors are method specific and must be treated differently from case to case.
-
-
-
-
-
-
-
-
Resampling methods
-
-
-With all these analytical equations for both the OLS and Ridge
-regression, we will now outline how to assess a given model. This will
-lead us to a discussion of the so-called bias-variance tradeoff (see
-below) and so-called resampling methods.
-
-
-One of the quantities we have discussed as a way to measure errors is
-the mean-squared error (MSE), mainly used for fitting of continuous
-functions. Another choice is the absolute error.
-
-
-In the discussions below we will focus on the MSE and in particular since we will split the data into test and training data,
-we discuss the
-
-
-- prediction error or simply the test error \( \mathrm{Err_{Test}} \), where we have a fixed training set and the test error is the MSE arising from the data reserved for testing. We discuss also the
-- training error \( \mathrm{Err_{Train}} \), which is the average loss over the training data.
-
-
-As our model becomes more and more complex, more of the training data tends to used. The training may thence adapt to more complicated structures in the data. This may lead to a decrease in the bias (see below for code example) and a slight increase of the variance for the test error.
-For a certain level of complexity the test error will reach minimum, before starting to increase again. The
-training error reaches a saturation.
-
-
-
-
-
Resampling methods: Jackknife and Bootstrap
-
-
-Two famous
-resampling methods are the independent bootstrap and the jackknife.
-
-
-The jackknife is a special case of the independent bootstrap. Still, the jackknife was made
-popular prior to the independent bootstrap. And as the popularity of
-the independent bootstrap soared, new variants, such as the dependent bootstrap.
-
-
-The Jackknife and independent bootstrap work for
-independent, identically distributed random variables.
-If these conditions are not
-satisfied, the methods will fail. Yet, it should be said that if the data are
-independent, identically distributed, and we only want to estimate the
-variance of \( \overline{X} \) (which often is the case), then there is no
-need for bootstrapping.
-
-
-
-
-
Resampling methods: Jackknife
-
-
-The Jackknife works by making many replicas of the estimator \( \widehat{\theta} \).
-The jackknife is a resampling method where we systematically leave out one observation from the vector of observed values \( \boldsymbol{x} = (x_1,x_2,\cdots,X_n) \).
-Let \( \boldsymbol{x}_i \) denote the vector
-$$
-\boldsymbol{x}_i = (x_1,x_2,\cdots,x_{i-1},x_{i+1},\cdots,x_n),
-$$
-
-
-which equals the vector \( \boldsymbol{x} \) with the exception that observation
-number \( i \) is left out. Using this notation, define
-\( \widehat{\theta}_i \) to be the estimator
-\( \widehat{\theta} \) computed using \( \vec{X}_i \).
-
-
-
-
-
Jackknife code example
-
-
-
-
from numpy import *
-from numpy.random import randint, randn
-from time import time
-
-def jackknife(data, stat):
- n = len(data);t = zeros(n); inds = arange(n); t0 = time()
- ## 'jackknifing' by leaving out an observation for each i
- for i in range(n):
- t[i] = stat(delete(data,i) )
-
- # analysis
- print("Runtime: %g sec" % (time()-t0)); print("Jackknife Statistics :")
- print("original bias std. error")
- print("%8g %14g %15g" % (stat(data),(n-1)*mean(t)/n, (n*var(t))**.5))
-
- return t
-
-
-# Returns mean of data samples
-def stat(data):
- return mean(data)
-
-
-mu, sigma = 100, 15
-datapoints = 10000
-x = mu + sigma*random.randn(datapoints)
-# jackknife returns the data sample
-t = jackknife(x, stat)
-
-
-
-
-
Resampling methods: Bootstrap
-
-
-
-Bootstrapping is a nonparametric approach to statistical inference
-that substitutes computation for more traditional distributional
-assumptions and asymptotic results. Bootstrapping offers a number of
-advantages:
-
-
-- The bootstrap is quite general, although there are some cases in which it fails.
-- Because it does not require distributional assumptions (such as normally distributed errors), the bootstrap can provide more accurate inferences when the data are not well behaved or when the sample size is small.
-- It is possible to apply the bootstrap to statistics with sampling distributions that are difficult to derive, even asymptotically.
-- It is relatively simple to apply the bootstrap to complex data-collection plans (such as stratified and clustered samples).
-
-
-
-
-
-
-
-
Resampling methods: Bootstrap background
-
-
-Since \( \widehat{\theta} = \widehat{\theta}(\boldsymbol{X}) \) is a function of random variables,
-\( \widehat{\theta} \) itself must be a random variable. Thus it has
-a pdf, call this function \( p(\boldsymbol{t}) \). The aim of the bootstrap is to
-estimate \( p(\boldsymbol{t}) \) by the relative frequency of
-\( \widehat{\theta} \). You can think of this as using a histogram
-in the place of \( p(\boldsymbol{t}) \). If the relative frequency closely
-resembles \( p(\vec{t}) \), then using numerics, it is straight forward to
-estimate all the interesting parameters of \( p(\boldsymbol{t}) \) using point
-estimators.
-
-
-
-
-
Resampling methods: More Bootstrap background
-
-
-In the case that \( \widehat{\theta} \) has
-more than one component, and the components are independent, we use the
-same estimator on each component separately. If the probability
-density function of \( X_i \), \( p(x) \), had been known, then it would have
-been straight forward to do this by:
-
-
-- Drawing lots of numbers from \( p(x) \), suppose we call one such set of numbers \( (X_1^*, X_2^*, \cdots, X_n^*) \).
-- Then using these numbers, we could compute a replica of \( \widehat{\theta} \) called \( \widehat{\theta}^* \).
-
-
-By repeated use of (1) and (2), many
-estimates of \( \widehat{\theta} \) could have been obtained. The
-idea is to use the relative frequency of \( \widehat{\theta}^* \)
-(think of a histogram) as an estimate of \( p(\boldsymbol{t}) \).
-
-
-
-
-
Resampling methods: Bootstrap approach
-
-
-But
-unless there is enough information available about the process that
-generated \( X_1,X_2,\cdots,X_n \), \( p(x) \) is in general
-unknown. Therefore, Efron in 1979 asked the
-question: What if we replace \( p(x) \) by the relative frequency
-of the observation \( X_i \); if we draw observations in accordance with
-the relative frequency of the observations, will we obtain the same
-result in some asymptotic sense? The answer is yes.
-
-
-Instead of generating the histogram for the relative
-frequency of the observation \( X_i \), just draw the values
-\( (X_1^*,X_2^*,\cdots,X_n^*) \) with replacement from the vector
-\( \boldsymbol{X} \).
-
-
-
-
-
Resampling methods: Bootstrap steps
-
-
-The independent bootstrap works like this:
-
-
-- Draw with replacement \( n \) numbers for the observed variables \( \boldsymbol{x} = (x_1,x_2,\cdots,x_n) \).
-- Define a vector \( \boldsymbol{x}^* \) containing the values which were drawn from \( \boldsymbol{x} \).
-- Using the vector \( \boldsymbol{x}^* \) compute \( \widehat{\theta}^* \) by evaluating \( \widehat \theta \) under the observations \( \boldsymbol{x}^* \).
-- Repeat this process \( k \) times.
-
-
-When you are done, you can draw a histogram of the relative frequency
-of \( \widehat \theta^* \). This is your estimate of the probability
-distribution \( p(t) \). Using this probability distribution you can
-estimate any statistics thereof. In principle you never draw the
-histogram of the relative frequency of \( \widehat{\theta}^* \). Instead
-you use the estimators corresponding to the statistic of interest. For
-example, if you are interested in estimating the variance of \( \widehat
-\theta \), apply the etsimator \( \widehat \sigma^2 \) to the values
-\( \widehat \theta ^* \).
-
-
-
-
-
Code example for the Bootstrap method
-
-
-The following code starts with a Gaussian distribution with mean value
-\( \mu =100 \) and variance \( \sigma=15 \). We use this to generate the data
-used in the bootstrap analysis. The bootstrap analysis returns a data
-set after a given number of bootstrap operations (as many as we have
-data points). This data set consists of estimated mean values for each
-bootstrap operation. The histogram generated by the bootstrap method
-shows that the distribution for these mean values is also a Gaussian,
-centered around the mean value \( \mu=100 \) but with standard deviation
-\( \sigma/\sqrt{n} \), where \( n \) is the number of bootstrap samples (in
-this case the same as the number of original data points). The value
-of the standard deviation is what we expect from the central limit
-theorem.
-
-
-
-
-
from numpy import *
-from numpy.random import randint, randn
-from time import time
-import matplotlib.mlab as mlab
-import matplotlib.pyplot as plt
-
-# Returns mean of bootstrap samples
-def stat(data):
- return mean(data)
-
-# Bootstrap algorithm
-def bootstrap(data, statistic, R):
- t = zeros(R); n = len(data); inds = arange(n); t0 = time()
- # non-parametric bootstrap
- for i in range(R):
- t[i] = statistic(data[randint(0,n,n)])
-
- # analysis
- print("Runtime: %g sec" % (time()-t0)); print("Bootstrap Statistics :")
- print("original bias std. error")
- print("%8g %8g %14g %15g" % (statistic(data), std(data),mean(t),std(t)))
- return t
-
-
-mu, sigma = 100, 15
-datapoints = 10000
-x = mu + sigma*random.randn(datapoints)
-# bootstrap returns the data sample
-t = bootstrap(x, stat, datapoints)
-# the histogram of the bootstrapped data
-n, binsboot, patches = plt.hist(t, 50, normed=1, facecolor='red', alpha=0.75)
-
-# add a 'best fit' line
-y = mlab.normpdf( binsboot, mean(t), std(t))
-lt = plt.plot(binsboot, y, 'r--', linewidth=1)
-plt.xlabel('Smarts')
-plt.ylabel('Probability')
-plt.axis([99.5, 100.6, 0, 3.0])
-plt.grid(True)
-
-plt.show()
-
-
-
-
-
Various steps in cross-validation
-
-
-When the repetitive splitting of the data set is done randomly,
-samples may accidently end up in a fast majority of the splits in
-either training or test set. Such samples may have an unbalanced
-influence on either model building or prediction evaluation. To avoid
-this \( k \)-fold cross-validation structures the data splitting. The
-samples are divided into \( k \) more or less equally sized exhaustive and
-mutually exclusive subsets. In turn (at each split) one of these
-subsets plays the role of the test set while the union of the
-remaining subsets constitutes the training set. Such a splitting
-warrants a balanced representation of each sample in both training and
-test set over the splits. Still the division into the \( k \) subsets
-involves a degree of randomness. This may be fully excluded when
-choosing \( k=n \). This particular case is referred to as leave-one-out
-cross-validation (LOOCV).
-
-
-
-
-
How to set up the cross-validation for Ridge and/or Lasso
-
-
-- Define a range of interest for the penalty parameter.
-- Divide the data set into training and test set comprising samples \( \{1, \ldots, n\} \setminus i \) and \( \{ i \} \), respectively.
-- Fit the linear regression model by means of ridge estimation for each \( \lambda \) in the grid using the training set, and the corresponding estimate of the error variance \( \boldsymbol{\sigma}_{-i}^2(\lambda) \), as
-
-
-$$
-\begin{align*}
-\boldsymbol{\beta}_{-i}(\lambda) & = ( \boldsymbol{X}_{-i, \ast}^{T}
-\boldsymbol{X}_{-i, \ast} + \lambda \boldsymbol{I}_{pp})^{-1}
-\boldsymbol{X}_{-i, \ast}^{T} \boldsymbol{y}_{-i}
-\end{align*}
-$$
-
-
-
-- Evaluate the prediction performance of these models on the test set by \( \log\{L[y_i, \boldsymbol{X}_{i, \ast}; \boldsymbol{\beta}_{-i}(\lambda), \boldsymbol{\sigma}_{-i}^2(\lambda)]\} \). Or, by the prediction error \( |y_i - \boldsymbol{X}_{i, \ast} \boldsymbol{\beta}_{-i}(\lambda)| \), the relative error, the error squared or the R2 score function.
-- Repeat the first three steps such that each sample plays the role of the test set once.
-- Average the prediction performances of the test sets at each grid point of the penalty bias/parameter. It is an estimate of the prediction performance of the model corresponding to this value of the penalty parameter on novel data. It is defined as
-
-
-$$
-\begin{align*}
-\frac{1}{n} \sum_{i = 1}^n \log\{L[y_i, \mathbf{X}_{i, \ast}; \boldsymbol{\beta}_{-i}(\lambda), \boldsymbol{\sigma}_{-i}^2(\lambda)]\}.
-\end{align*}
-$$
-
-
-
-
-
Cross-validation in brief
-
-
-For the various values of \( k \)
-
-
-- shuffle the dataset randomly.
-- Split the dataset into \( k \) groups.
-- For each unique group:
-
-
-- Decide which group to use as set for test data
-- Take the remaining groups as a training data set
-- Fit a model on the training set and evaluate it on the test set
-- Retain the evaluation score and discard the model
-
-
- Summarize the model using the sample of model evaluation scores
-
-
-
-
-Code Example for Cross-validation and \( k \)-fold Cross-validation
-
-
-The code here uses Ridge regression with cross-validation (CV) resampling and \( k \)-fold CV in order to fit a specific polynomial.
-
-
-
-
import numpy as np
-import matplotlib.pyplot as plt
-from sklearn.model_selection import KFold
-from sklearn.linear_model import Ridge
-from sklearn.model_selection import cross_val_score
-from sklearn.preprocessing import PolynomialFeatures
-
-# A seed just to ensure that the random numbers are the same for every run.
-# Useful for eventual debugging.
-np.random.seed(3155)
-
-# Generate the data.
-nsamples = 100
-x = np.random.randn(nsamples)
-y = 3*x**2 + np.random.randn(nsamples)
-
-## Cross-validation on Ridge regression using KFold only
-
-# Decide degree on polynomial to fit
-poly = PolynomialFeatures(degree = 6)
-
-# Decide which values of lambda to use
-nlambdas = 500
-lambdas = np.logspace(-3, 5, nlambdas)
-
-# Initialize a KFold instance
-k = 5
-kfold = KFold(n_splits = k)
-
-# Perform the cross-validation to estimate MSE
-scores_KFold = np.zeros((nlambdas, k))
-
-i = 0
-for lmb in lambdas:
- ridge = Ridge(alpha = lmb)
- j = 0
- for train_inds, test_inds in kfold.split(x):
- xtrain = x[train_inds]
- ytrain = y[train_inds]
-
- xtest = x[test_inds]
- ytest = y[test_inds]
-
- Xtrain = poly.fit_transform(xtrain[:, np.newaxis])
- ridge.fit(Xtrain, ytrain[:, np.newaxis])
-
- Xtest = poly.fit_transform(xtest[:, np.newaxis])
- ypred = ridge.predict(Xtest)
-
- scores_KFold[i,j] = np.sum((ypred - ytest[:, np.newaxis])**2)/np.size(ypred)
-
- j += 1
- i += 1
-
-
-estimated_mse_KFold = np.mean(scores_KFold, axis = 1)
-
-## Cross-validation using cross_val_score from sklearn along with KFold
-
-# kfold is an instance initialized above as:
-# kfold = KFold(n_splits = k)
-
-estimated_mse_sklearn = np.zeros(nlambdas)
-i = 0
-for lmb in lambdas:
- ridge = Ridge(alpha = lmb)
-
- X = poly.fit_transform(x[:, np.newaxis])
- estimated_mse_folds = cross_val_score(ridge, X, y[:, np.newaxis], scoring='neg_mean_squared_error', cv=kfold)
-
- # cross_val_score return an array containing the estimated negative mse for every fold.
- # we have to the the mean of every array in order to get an estimate of the mse of the model
- estimated_mse_sklearn[i] = np.mean(-estimated_mse_folds)
-
- i += 1
-
-## Plot and compare the slightly different ways to perform cross-validation
-
-plt.figure()
-
-plt.plot(np.log10(lambdas), estimated_mse_sklearn, label = 'cross_val_score')
-plt.plot(np.log10(lambdas), estimated_mse_KFold, 'r--', label = 'KFold')
-
-plt.xlabel('log10(lambda)')
-plt.ylabel('mse')
-
-plt.legend()
-
-plt.show()
-
-
-
-
-
The bias-variance tradeoff
-
-
-We will discuss the bias-variance tradeoff in the context of
-continuous predictions such as regression. However, many of the
-intuitions and ideas discussed here also carry over to classification
-tasks. Consider a dataset \( \mathcal{L} \) consisting of the data
-\( \mathbf{X}_\mathcal{L}=\{(y_j, \boldsymbol{x}_j), j=0\ldots n-1\} \).
-
-
-Let us assume that the true data is generated from a noisy model
-
-$$
-\boldsymbol{y}=f(\boldsymbol{x}) + \boldsymbol{\epsilon}
-$$
-
-
-where \( \epsilon \) is normally distributed with mean zero and standard deviation \( \sigma^2 \).
-
-
-In our derivation of the ordinary least squares method we defined then
-an approximation to the function \( f \) in terms of the parameters
-\( \boldsymbol{\beta} \) and the design matrix \( \boldsymbol{X} \) which embody our model,
-that is \( \boldsymbol{\tilde{y}}=\boldsymbol{X}\boldsymbol{\beta} \).
-
-
-Thereafter we found the parameters \( \boldsymbol{\beta} \) by optimizing the means squared error via the so-called cost function
-$$
-C(\boldsymbol{X},\boldsymbol{\beta}) =\frac{1}{n}\sum_{i=0}^{n-1}(y_i-\tilde{y}_i)^2=\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right].
-$$
-
-
-We can rewrite this as
-$$
-\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\frac{1}{n}\sum_i(f_i-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2+\frac{1}{n}\sum_i(\tilde{y}_i-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2+\sigma^2.
-$$
-
-
-The three terms represent the square of the bias of the learning
-method, which can be thought of as the error caused by the simplifying
-assumptions built into the method. The second term represents the
-variance of the chosen model and finally the last terms is variance of
-the error \( \boldsymbol{\epsilon} \).
-
-
-To derive this equation, we need to recall that the variance of \( \boldsymbol{y} \) and \( \boldsymbol{\epsilon} \) are both equal to \( \sigma^2 \). The mean value of \( \boldsymbol{\epsilon} \) is by definition equal to zero. Furthermore, the function \( f \) is not a stochastics variable, idem for \( \boldsymbol{\tilde{y}} \).
-We use a more compact notation in terms of the expectation value
-$$
-\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\mathbb{E}\left[(\boldsymbol{f}+\boldsymbol{\epsilon}-\boldsymbol{\tilde{y}})^2\right],
-$$
-
-and adding and subtracting \( \mathbb{E}\left[\boldsymbol{\tilde{y}}\right] \) we get
-$$
-\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\mathbb{E}\left[(\boldsymbol{f}+\boldsymbol{\epsilon}-\boldsymbol{\tilde{y}}+\mathbb{E}\left[\boldsymbol{\tilde{y}}\right]-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2\right],
-$$
-
-which, using the abovementioned expectation values can be rewritten as
-$$
-\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\mathbb{E}\left[(\boldsymbol{y}-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2\right]+\mathrm{Var}\left[\boldsymbol{\tilde{y}}\right]+\sigma^2,
-$$
-
-that is the rewriting in terms of the so-called bias, the variance of the model \( \boldsymbol{\tilde{y}} \) and the variance of \( \boldsymbol{\epsilon} \).
-
-
-
-
-
Example code for Bias-Variance tradeoff
-
-
-
-
import matplotlib.pyplot as plt
-import numpy as np
-from sklearn.linear_model import LinearRegression, Ridge, Lasso
-from sklearn.preprocessing import PolynomialFeatures
-from sklearn.model_selection import train_test_split
-from sklearn.pipeline import make_pipeline
-from sklearn.utils import resample
-
-np.random.seed(2018)
-
-n = 500
-n_boostraps = 100
-degree = 18 # A quite high value, just to show.
-noise = 0.1
-
-# Make data set.
-x = np.linspace(-1, 3, n).reshape(-1, 1)
-y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2) + np.random.normal(0, 0.1, x.shape)
-
-# Hold out some test data that is never used in training.
-x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
-
-# Combine x transformation and model into one operation.
-# Not neccesary, but convenient.
-model = make_pipeline(PolynomialFeatures(degree=degree), LinearRegression(fit_intercept=False))
-
-# The following (m x n_bootstraps) matrix holds the column vectors y_pred
-# for each bootstrap iteration.
-y_pred = np.empty((y_test.shape[0], n_boostraps))
-for i in range(n_boostraps):
- x_, y_ = resample(x_train, y_train)
-
- # Evaluate the new model on the same test data each time.
- y_pred[:, i] = model.fit(x_, y_).predict(x_test).ravel()
-
-# Note: Expectations and variances taken w.r.t. different training
-# data sets, hence the axis=1. Subsequent means are taken across the test data
-# set in order to obtain a total value, but before this we have error/bias/variance
-# calculated per data point in the test set.
-# Note 2: The use of keepdims=True is important in the calculation of bias as this
-# maintains the column vector form. Dropping this yields very unexpected results.
-error = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) )
-bias = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 )
-variance = np.mean( np.var(y_pred, axis=1, keepdims=True) )
-print('Error:', error)
-print('Bias^2:', bias)
-print('Var:', variance)
-print('{} >= {} + {} = {}'.format(error, bias, variance, bias+variance))
-
-plt.plot(x[::5, :], y[::5, :], label='f(x)')
-plt.scatter(x_test, y_test, label='Data points')
-plt.scatter(x_test, np.mean(y_pred, axis=1), label='Pred')
-plt.legend()
-plt.show()
-
-
-
-
-
Understanding what happens
-
-
-
-
import matplotlib.pyplot as plt
-import numpy as np
-from sklearn.linear_model import LinearRegression, Ridge, Lasso
-from sklearn.preprocessing import PolynomialFeatures
-from sklearn.model_selection import train_test_split
-from sklearn.pipeline import make_pipeline
-from sklearn.utils import resample
-
-np.random.seed(2018)
-
-n = 40
-n_boostraps = 100
-maxdegree = 14
-
-
-# Make data set.
-x = np.linspace(-3, 3, n).reshape(-1, 1)
-y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape)
-error = np.zeros(maxdegree)
-bias = np.zeros(maxdegree)
-variance = np.zeros(maxdegree)
-polydegree = np.zeros(maxdegree)
-x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
-
-for degree in range(maxdegree):
- model = make_pipeline(PolynomialFeatures(degree=degree), LinearRegression(fit_intercept=False))
- y_pred = np.empty((y_test.shape[0], n_boostraps))
- for i in range(n_boostraps):
- x_, y_ = resample(x_train, y_train)
- y_pred[:, i] = model.fit(x_, y_).predict(x_test).ravel()
-
- polydegree[degree] = degree
- error[degree] = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) )
- bias[degree] = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 )
- variance[degree] = np.mean( np.var(y_pred, axis=1, keepdims=True) )
- print('Polynomial degree:', degree)
- print('Error:', error[degree])
- print('Bias^2:', bias[degree])
- print('Var:', variance[degree])
- print('{} >= {} + {} = {}'.format(error[degree], bias[degree], variance[degree], bias[degree]+variance[degree]))
-
-plt.plot(polydegree, error, label='Error')
-plt.plot(polydegree, bias, label='bias')
-plt.plot(polydegree, variance, label='Variance')
-plt.legend()
-plt.show()
-
-
-
-
-
Summing up
-
-
-The bias-variance tradeoff summarizes the fundamental tension in
-machine learning, particularly supervised learning, between the
-complexity of a model and the amount of training data needed to train
-it. Since data is often limited, in practice it is often useful to
-use a less-complex model with higher bias, that is a model whose asymptotic
-performance is worse than another model because it is easier to
-train and less sensitive to sampling noise arising from having a
-finite-sized training dataset (smaller variance).
-
-
-The above equations tell us that in
-order to minimize the expected test error, we need to select a
-statistical learning method that simultaneously achieves low variance
-and low bias. Note that variance is inherently a nonnegative quantity,
-and squared bias is also nonnegative. Hence, we see that the expected
-test MSE can never lie below \( Var(\epsilon) \), the irreducible error.
-
-
-What do we mean by the variance and bias of a statistical learning
-method? The variance refers to the amount by which our model would change if we
-estimated it using a different training data set. Since the training
-data are used to fit the statistical learning method, different
-training data sets will result in a different estimate. But ideally the
-estimate for our model should not vary too much between training
-sets. However, if a method has high variance then small changes in
-the training data can result in large changes in the model. In general, more
-flexible statistical methods have higher variance.
-
-
-You may also find this recent article of interest.
-
-
-
-
-
Another Example from Scikit-Learn's Repository
-
-
-
-
"""
-============================
-Underfitting vs. Overfitting
-============================
-
-This example demonstrates the problems of underfitting and overfitting and
-how we can use linear regression with polynomial features to approximate
-nonlinear functions. The plot shows the function that we want to approximate,
-which is a part of the cosine function. In addition, the samples from the
-real function and the approximations of different models are displayed. The
-models have polynomial features of different degrees. We can see that a
-linear function (polynomial with degree 1) is not sufficient to fit the
-training samples. This is called **underfitting**. A polynomial of degree 4
-approximates the true function almost perfectly. However, for higher degrees
-the model will **overfit** the training data, i.e. it learns the noise of the
-training data.
-We evaluate quantitatively **overfitting** / **underfitting** by using
-cross-validation. We calculate the mean squared error (MSE) on the validation
-set, the higher, the less likely the model generalizes correctly from the
-training data.
-"""
-
-print(__doc__)
-
-import numpy as np
-import matplotlib.pyplot as plt
-from sklearn.pipeline import Pipeline
-from sklearn.preprocessing import PolynomialFeatures
-from sklearn.linear_model import LinearRegression
-from sklearn.model_selection import cross_val_score
-
-
-def true_fun(X):
- return np.cos(1.5 * np.pi * X)
-
-np.random.seed(0)
-
-n_samples = 30
-degrees = [1, 4, 15]
-
-X = np.sort(np.random.rand(n_samples))
-y = true_fun(X) + np.random.randn(n_samples) * 0.1
-
-plt.figure(figsize=(14, 5))
-for i in range(len(degrees)):
- ax = plt.subplot(1, len(degrees), i + 1)
- plt.setp(ax, xticks=(), yticks=())
-
- polynomial_features = PolynomialFeatures(degree=degrees[i],
- include_bias=False)
- linear_regression = LinearRegression()
- pipeline = Pipeline([("polynomial_features", polynomial_features),
- ("linear_regression", linear_regression)])
- pipeline.fit(X[:, np.newaxis], y)
-
- # Evaluate the models using crossvalidation
- scores = cross_val_score(pipeline, X[:, np.newaxis], y,
- scoring="neg_mean_squared_error", cv=10)
-
- X_test = np.linspace(0, 1, 100)
- plt.plot(X_test, pipeline.predict(X_test[:, np.newaxis]), label="Model")
- plt.plot(X_test, true_fun(X_test), label="True function")
- plt.scatter(X, y, edgecolor='b', s=20, label="Samples")
- plt.xlabel("x")
- plt.ylabel("y")
- plt.xlim((0, 1))
- plt.ylim((-2, 2))
- plt.legend(loc="best")
- plt.title("Degree {}\nMSE = {:.2e}(+/- {:.2e})".format(
- degrees[i], -scores.mean(), scores.std()))
-plt.show()
-
-
-
-
-
More examples on bootstrap and cross-validation and errors
-
-
-
-
-
# Common imports
-import os
-import numpy as np
-import pandas as pd
-import matplotlib.pyplot as plt
-from sklearn.linear_model import LinearRegression, Ridge, Lasso
-from sklearn.model_selection import train_test_split
-from sklearn.utils import resample
-from sklearn.metrics import mean_squared_error
-# Where to save the figures and data files
-PROJECT_ROOT_DIR = "Results"
-FIGURE_ID = "Results/FigureFiles"
-DATA_ID = "DataFiles/"
-
-if not os.path.exists(PROJECT_ROOT_DIR):
- os.mkdir(PROJECT_ROOT_DIR)
-
-if not os.path.exists(FIGURE_ID):
- os.makedirs(FIGURE_ID)
-
-if not os.path.exists(DATA_ID):
- os.makedirs(DATA_ID)
-
-def image_path(fig_id):
- return os.path.join(FIGURE_ID, fig_id)
-
-def data_path(dat_id):
- return os.path.join(DATA_ID, dat_id)
-
-def save_fig(fig_id):
- plt.savefig(image_path(fig_id) + ".png", format='png')
-
-infile = open(data_path("EoS.csv"),'r')
-
-# Read the EoS data as csv file and organize the data into two arrays with density and energies
-EoS = pd.read_csv(infile, names=('Density', 'Energy'))
-EoS['Energy'] = pd.to_numeric(EoS['Energy'], errors='coerce')
-EoS = EoS.dropna()
-Energies = EoS['Energy']
-Density = EoS['Density']
-# The design matrix now as function of various polytrops
-
-Maxpolydegree = 30
-X = np.zeros((len(Density),Maxpolydegree))
-X[:,0] = 1.0
-testerror = np.zeros(Maxpolydegree)
-trainingerror = np.zeros(Maxpolydegree)
-polynomial = np.zeros(Maxpolydegree)
-
-trials = 100
-for polydegree in range(1, Maxpolydegree):
- polynomial[polydegree] = polydegree
- for degree in range(polydegree):
- X[:,degree] = Density**(degree/3.0)
-
-# loop over trials in order to estimate the expectation value of the MSE
- testerror[polydegree] = 0.0
- trainingerror[polydegree] = 0.0
- for samples in range(trials):
- x_train, x_test, y_train, y_test = train_test_split(X, Energies, test_size=0.2)
- model = LinearRegression(fit_intercept=True).fit(x_train, y_train)
- ypred = model.predict(x_train)
- ytilde = model.predict(x_test)
- testerror[polydegree] += mean_squared_error(y_test, ytilde)
- trainingerror[polydegree] += mean_squared_error(y_train, ypred)
-
- testerror[polydegree] /= trials
- trainingerror[polydegree] /= trials
- print("Degree of polynomial: %3d"% polynomial[polydegree])
- print("Mean squared error on training data: %.8f" % trainingerror[polydegree])
- print("Mean squared error on test data: %.8f" % testerror[polydegree])
-
-plt.plot(polynomial, np.log10(trainingerror), label='Training Error')
-plt.plot(polynomial, np.log10(testerror), label='Test Error')
-plt.xlabel('Polynomial degree')
-plt.ylabel('log10[MSE]')
-plt.legend()
-plt.show()
-
-
-
-
-
The same example but now with cross-validation
-
-
-
-
-
# Common imports
-import os
-import numpy as np
-import pandas as pd
-import matplotlib.pyplot as plt
-from sklearn.linear_model import LinearRegression, Ridge, Lasso
-from sklearn.metrics import mean_squared_error
-from sklearn.model_selection import KFold
-from sklearn.model_selection import cross_val_score
-
-
-# Where to save the figures and data files
-PROJECT_ROOT_DIR = "Results"
-FIGURE_ID = "Results/FigureFiles"
-DATA_ID = "DataFiles/"
-
-if not os.path.exists(PROJECT_ROOT_DIR):
- os.mkdir(PROJECT_ROOT_DIR)
-
-if not os.path.exists(FIGURE_ID):
- os.makedirs(FIGURE_ID)
-
-if not os.path.exists(DATA_ID):
- os.makedirs(DATA_ID)
-
-def image_path(fig_id):
- return os.path.join(FIGURE_ID, fig_id)
-
-def data_path(dat_id):
- return os.path.join(DATA_ID, dat_id)
-
-def save_fig(fig_id):
- plt.savefig(image_path(fig_id) + ".png", format='png')
-
-infile = open(data_path("EoS.csv"),'r')
-
-# Read the EoS data as csv file and organize the data into two arrays with density and energies
-EoS = pd.read_csv(infile, names=('Density', 'Energy'))
-EoS['Energy'] = pd.to_numeric(EoS['Energy'], errors='coerce')
-EoS = EoS.dropna()
-Energies = EoS['Energy']
-Density = EoS['Density']
-# The design matrix now as function of various polytrops
-
-Maxpolydegree = 30
-X = np.zeros((len(Density),Maxpolydegree))
-X[:,0] = 1.0
-estimated_mse_sklearn = np.zeros(Maxpolydegree)
-polynomial = np.zeros(Maxpolydegree)
-k =5
-kfold = KFold(n_splits = k)
-
-for polydegree in range(1, Maxpolydegree):
- polynomial[polydegree] = polydegree
- for degree in range(polydegree):
- X[:,degree] = Density**(degree/3.0)
- OLS = LinearRegression()
-# loop over trials in order to estimate the expectation value of the MSE
- estimated_mse_folds = cross_val_score(OLS, X, Energies, scoring='neg_mean_squared_error', cv=kfold)
-#[:, np.newaxis]
- estimated_mse_sklearn[polydegree] = np.mean(-estimated_mse_folds)
-
-plt.plot(polynomial, np.log10(estimated_mse_sklearn), label='Test Error')
-plt.xlabel('Polynomial degree')
-plt.ylabel('log10[MSE]')
-plt.legend()
-plt.show()
-
-
-
-
-
Cross-validation with Ridge
-
-
-
-
import numpy as np
-import matplotlib.pyplot as plt
-from sklearn.model_selection import KFold
-from sklearn.linear_model import Ridge
-from sklearn.model_selection import cross_val_score
-from sklearn.preprocessing import PolynomialFeatures
-
-# A seed just to ensure that the random numbers are the same for every run.
-np.random.seed(3155)
-# Generate the data.
-n = 100
-x = np.linspace(-3, 3, n).reshape(-1, 1)
-y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape)
-# Decide degree on polynomial to fit
-poly = PolynomialFeatures(degree = 10)
-
-# Decide which values of lambda to use
-nlambdas = 500
-lambdas = np.logspace(-3, 5, nlambdas)
-# Initialize a KFold instance
-k = 5
-kfold = KFold(n_splits = k)
-estimated_mse_sklearn = np.zeros(nlambdas)
-i = 0
-for lmb in lambdas:
- ridge = Ridge(alpha = lmb)
- estimated_mse_folds = cross_val_score(ridge, x, y, scoring='neg_mean_squared_error', cv=kfold)
- estimated_mse_sklearn[i] = np.mean(-estimated_mse_folds)
- i += 1
-plt.figure()
-plt.plot(np.log10(lambdas), estimated_mse_sklearn, label = 'cross_val_score')
-plt.xlabel('log10(lambda)')
-plt.ylabel('MSE')
-plt.legend()
-plt.show()
-
-
+which is our Lasso cost function!
diff --git a/doc/pub/week36/html/week36.html b/doc/pub/week36/html/week36.html
index 7d5c6abe0..bff48eb27 100644
--- a/doc/pub/week36/html/week36.html
+++ b/doc/pub/week36/html/week36.html
@@ -192,95 +192,7 @@ div { text-align: justify; text-justify: inter-word; }
'test-function-for-what-happens-with-ols-ridge-and-lasso'),
("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'),
- ('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'),
- ('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'),
- ('The bias-variance tradeoff',
- 2,
- None,
- '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'),
- ('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'),
- ('Cross-validation with Ridge',
- 2,
- None,
- 'cross-validation-with-ridge')]}
+ ('Lasso and Bayes', 2, None, 'lasso-and-bayes')]}
end of tocinfo -->
@@ -2211,1081 +2123,7 @@ $$
C(\boldsymbol{\beta}=\frac{\vert\vert (\boldsymbol{y}-\boldsymbol{X}\boldsymbol{\beta})\vert\vert_2^2}{2\sigma^2}+\lambda\vert\vert\boldsymbol{\beta}\vert\vert_1,
$$
-which is our Lasso cost function!
-
-
-
-
-
Why resampling methods
-
-
-Before we proceed, we need to rethink what we have been doing. In our
-eager to fit the data, we have omitted several important elements in
-our regression analysis. In what follows we will
-
-
-- look at statistical properties, including a discussion of mean values, variance and the so-called bias-variance tradeoff
-- introduce resampling techniques like cross-validation, bootstrapping and jackknife and more
-
-
-This will allow us to link the standard linear algebra methods we have discussed above to a statistical interpretation of the methods.
-
-
-
-
-
Resampling methods
-
-
-
-Resampling methods are an indispensable tool in modern
-statistics. They involve repeatedly drawing samples from a training
-set and refitting a model of interest on each sample in order to
-obtain additional information about the fitted model. For example, in
-order to estimate the variability of a linear regression fit, we can
-repeatedly draw different samples from the training data, fit a linear
-regression to each new sample, and then examine the extent to which
-the resulting fits differ. Such an approach may allow us to obtain
-information that would not be available from fitting the model only
-once using the original training sample.
-
-
-Two resampling methods are often used in Machine Learning analyses,
-
-
-- The bootstrap method
-- and Cross-Validation
-
-
-In addition there are several other methods such as the Jackknife and the Blocking methods. We will discuss in particular
-cross-validation and the bootstrap method.
-
-
-
-
-
-
-
-
-
Resampling approaches can be computationally expensive
-
-
-
-
-
-Resampling approaches can be computationally expensive, because they
-involve fitting the same statistical method multiple times using
-different subsets of the training data. However, due to recent
-advances in computing power, the computational requirements of
-resampling methods generally are not prohibitive. In this chapter, we
-discuss two of the most commonly used resampling methods,
-cross-validation and the bootstrap. Both methods are important tools
-in the practical application of many statistical learning
-procedures. For example, cross-validation can be used to estimate the
-test error associated with a given statistical learning method in
-order to evaluate its performance, or to select the appropriate level
-of flexibility. The process of evaluating a model’s performance is
-known as model assessment, whereas the process of selecting the proper
-level of flexibility for a model is known as model selection. The
-bootstrap is widely used.
-
-
-
-
-
-
-
-
-
Why resampling methods ?
-
-
Statistical analysis
-
-
-
-- Our simulations can be treated as computer experiments. This is particularly the case for Monte Carlo methods
-- The results can be analysed with the same statistical tools as we would use analysing experimental data.
-- As in all experiments, we are looking for expectation values and an estimate of how accurate they are, i.e., possible sources for errors.
-
-
-
-
-
-
-
-
Statistical analysis
-
-
-
-
-
-- As in other experiments, many numerical experiments have two classes of errors:
-
-
- - Statistical errors
- - Systematical errors
-
-
-- Statistical errors can be estimated using standard tools from statistics
-- Systematical errors are method specific and must be treated differently from case to case.
-
-
-
-
-
-
-
-
Resampling methods
-
-
-With all these analytical equations for both the OLS and Ridge
-regression, we will now outline how to assess a given model. This will
-lead us to a discussion of the so-called bias-variance tradeoff (see
-below) and so-called resampling methods.
-
-
-One of the quantities we have discussed as a way to measure errors is
-the mean-squared error (MSE), mainly used for fitting of continuous
-functions. Another choice is the absolute error.
-
-
-In the discussions below we will focus on the MSE and in particular since we will split the data into test and training data,
-we discuss the
-
-
-- prediction error or simply the test error \( \mathrm{Err_{Test}} \), where we have a fixed training set and the test error is the MSE arising from the data reserved for testing. We discuss also the
-- training error \( \mathrm{Err_{Train}} \), which is the average loss over the training data.
-
-
-As our model becomes more and more complex, more of the training data tends to used. The training may thence adapt to more complicated structures in the data. This may lead to a decrease in the bias (see below for code example) and a slight increase of the variance for the test error.
-For a certain level of complexity the test error will reach minimum, before starting to increase again. The
-training error reaches a saturation.
-
-
-
-
-
Resampling methods: Jackknife and Bootstrap
-
-
-Two famous
-resampling methods are the independent bootstrap and the jackknife.
-
-
-The jackknife is a special case of the independent bootstrap. Still, the jackknife was made
-popular prior to the independent bootstrap. And as the popularity of
-the independent bootstrap soared, new variants, such as the dependent bootstrap.
-
-
-The Jackknife and independent bootstrap work for
-independent, identically distributed random variables.
-If these conditions are not
-satisfied, the methods will fail. Yet, it should be said that if the data are
-independent, identically distributed, and we only want to estimate the
-variance of \( \overline{X} \) (which often is the case), then there is no
-need for bootstrapping.
-
-
-
-
-
Resampling methods: Jackknife
-
-
-The Jackknife works by making many replicas of the estimator \( \widehat{\theta} \).
-The jackknife is a resampling method where we systematically leave out one observation from the vector of observed values \( \boldsymbol{x} = (x_1,x_2,\cdots,X_n) \).
-Let \( \boldsymbol{x}_i \) denote the vector
-$$
-\boldsymbol{x}_i = (x_1,x_2,\cdots,x_{i-1},x_{i+1},\cdots,x_n),
-$$
-
-
-which equals the vector \( \boldsymbol{x} \) with the exception that observation
-number \( i \) is left out. Using this notation, define
-\( \widehat{\theta}_i \) to be the estimator
-\( \widehat{\theta} \) computed using \( \vec{X}_i \).
-
-
-
-
-
Jackknife code example
-
-
-
-
from numpy import *
-from numpy.random import randint, randn
-from time import time
-
-def jackknife(data, stat):
- n = len(data);t = zeros(n); inds = arange(n); t0 = time()
- ## 'jackknifing' by leaving out an observation for each i
- for i in range(n):
- t[i] = stat(delete(data,i) )
-
- # analysis
- print("Runtime: %g sec" % (time()-t0)); print("Jackknife Statistics :")
- print("original bias std. error")
- print("%8g %14g %15g" % (stat(data),(n-1)*mean(t)/n, (n*var(t))**.5))
-
- return t
-
-
-# Returns mean of data samples
-def stat(data):
- return mean(data)
-
-
-mu, sigma = 100, 15
-datapoints = 10000
-x = mu + sigma*random.randn(datapoints)
-# jackknife returns the data sample
-t = jackknife(x, stat)
-
-
-
-
-
Resampling methods: Bootstrap
-
-
-
-Bootstrapping is a nonparametric approach to statistical inference
-that substitutes computation for more traditional distributional
-assumptions and asymptotic results. Bootstrapping offers a number of
-advantages:
-
-
-- The bootstrap is quite general, although there are some cases in which it fails.
-- Because it does not require distributional assumptions (such as normally distributed errors), the bootstrap can provide more accurate inferences when the data are not well behaved or when the sample size is small.
-- It is possible to apply the bootstrap to statistics with sampling distributions that are difficult to derive, even asymptotically.
-- It is relatively simple to apply the bootstrap to complex data-collection plans (such as stratified and clustered samples).
-
-
-
-
-
-
-
-
Resampling methods: Bootstrap background
-
-
-Since \( \widehat{\theta} = \widehat{\theta}(\boldsymbol{X}) \) is a function of random variables,
-\( \widehat{\theta} \) itself must be a random variable. Thus it has
-a pdf, call this function \( p(\boldsymbol{t}) \). The aim of the bootstrap is to
-estimate \( p(\boldsymbol{t}) \) by the relative frequency of
-\( \widehat{\theta} \). You can think of this as using a histogram
-in the place of \( p(\boldsymbol{t}) \). If the relative frequency closely
-resembles \( p(\vec{t}) \), then using numerics, it is straight forward to
-estimate all the interesting parameters of \( p(\boldsymbol{t}) \) using point
-estimators.
-
-
-
-
-
Resampling methods: More Bootstrap background
-
-
-In the case that \( \widehat{\theta} \) has
-more than one component, and the components are independent, we use the
-same estimator on each component separately. If the probability
-density function of \( X_i \), \( p(x) \), had been known, then it would have
-been straight forward to do this by:
-
-
-- Drawing lots of numbers from \( p(x) \), suppose we call one such set of numbers \( (X_1^*, X_2^*, \cdots, X_n^*) \).
-- Then using these numbers, we could compute a replica of \( \widehat{\theta} \) called \( \widehat{\theta}^* \).
-
-
-By repeated use of (1) and (2), many
-estimates of \( \widehat{\theta} \) could have been obtained. The
-idea is to use the relative frequency of \( \widehat{\theta}^* \)
-(think of a histogram) as an estimate of \( p(\boldsymbol{t}) \).
-
-
-
-
-
Resampling methods: Bootstrap approach
-
-
-But
-unless there is enough information available about the process that
-generated \( X_1,X_2,\cdots,X_n \), \( p(x) \) is in general
-unknown. Therefore, Efron in 1979 asked the
-question: What if we replace \( p(x) \) by the relative frequency
-of the observation \( X_i \); if we draw observations in accordance with
-the relative frequency of the observations, will we obtain the same
-result in some asymptotic sense? The answer is yes.
-
-
-Instead of generating the histogram for the relative
-frequency of the observation \( X_i \), just draw the values
-\( (X_1^*,X_2^*,\cdots,X_n^*) \) with replacement from the vector
-\( \boldsymbol{X} \).
-
-
-
-
-
Resampling methods: Bootstrap steps
-
-
-The independent bootstrap works like this:
-
-
-- Draw with replacement \( n \) numbers for the observed variables \( \boldsymbol{x} = (x_1,x_2,\cdots,x_n) \).
-- Define a vector \( \boldsymbol{x}^* \) containing the values which were drawn from \( \boldsymbol{x} \).
-- Using the vector \( \boldsymbol{x}^* \) compute \( \widehat{\theta}^* \) by evaluating \( \widehat \theta \) under the observations \( \boldsymbol{x}^* \).
-- Repeat this process \( k \) times.
-
-
-When you are done, you can draw a histogram of the relative frequency
-of \( \widehat \theta^* \). This is your estimate of the probability
-distribution \( p(t) \). Using this probability distribution you can
-estimate any statistics thereof. In principle you never draw the
-histogram of the relative frequency of \( \widehat{\theta}^* \). Instead
-you use the estimators corresponding to the statistic of interest. For
-example, if you are interested in estimating the variance of \( \widehat
-\theta \), apply the etsimator \( \widehat \sigma^2 \) to the values
-\( \widehat \theta ^* \).
-
-
-
-
-
Code example for the Bootstrap method
-
-
-The following code starts with a Gaussian distribution with mean value
-\( \mu =100 \) and variance \( \sigma=15 \). We use this to generate the data
-used in the bootstrap analysis. The bootstrap analysis returns a data
-set after a given number of bootstrap operations (as many as we have
-data points). This data set consists of estimated mean values for each
-bootstrap operation. The histogram generated by the bootstrap method
-shows that the distribution for these mean values is also a Gaussian,
-centered around the mean value \( \mu=100 \) but with standard deviation
-\( \sigma/\sqrt{n} \), where \( n \) is the number of bootstrap samples (in
-this case the same as the number of original data points). The value
-of the standard deviation is what we expect from the central limit
-theorem.
-
-
-
-
-
from numpy import *
-from numpy.random import randint, randn
-from time import time
-import matplotlib.mlab as mlab
-import matplotlib.pyplot as plt
-
-# Returns mean of bootstrap samples
-def stat(data):
- return mean(data)
-
-# Bootstrap algorithm
-def bootstrap(data, statistic, R):
- t = zeros(R); n = len(data); inds = arange(n); t0 = time()
- # non-parametric bootstrap
- for i in range(R):
- t[i] = statistic(data[randint(0,n,n)])
-
- # analysis
- print("Runtime: %g sec" % (time()-t0)); print("Bootstrap Statistics :")
- print("original bias std. error")
- print("%8g %8g %14g %15g" % (statistic(data), std(data),mean(t),std(t)))
- return t
-
-
-mu, sigma = 100, 15
-datapoints = 10000
-x = mu + sigma*random.randn(datapoints)
-# bootstrap returns the data sample
-t = bootstrap(x, stat, datapoints)
-# the histogram of the bootstrapped data
-n, binsboot, patches = plt.hist(t, 50, normed=1, facecolor='red', alpha=0.75)
-
-# add a 'best fit' line
-y = mlab.normpdf( binsboot, mean(t), std(t))
-lt = plt.plot(binsboot, y, 'r--', linewidth=1)
-plt.xlabel('Smarts')
-plt.ylabel('Probability')
-plt.axis([99.5, 100.6, 0, 3.0])
-plt.grid(True)
-
-plt.show()
-
-
-
-
-
Various steps in cross-validation
-
-
-When the repetitive splitting of the data set is done randomly,
-samples may accidently end up in a fast majority of the splits in
-either training or test set. Such samples may have an unbalanced
-influence on either model building or prediction evaluation. To avoid
-this \( k \)-fold cross-validation structures the data splitting. The
-samples are divided into \( k \) more or less equally sized exhaustive and
-mutually exclusive subsets. In turn (at each split) one of these
-subsets plays the role of the test set while the union of the
-remaining subsets constitutes the training set. Such a splitting
-warrants a balanced representation of each sample in both training and
-test set over the splits. Still the division into the \( k \) subsets
-involves a degree of randomness. This may be fully excluded when
-choosing \( k=n \). This particular case is referred to as leave-one-out
-cross-validation (LOOCV).
-
-
-
-
-
How to set up the cross-validation for Ridge and/or Lasso
-
-
-- Define a range of interest for the penalty parameter.
-- Divide the data set into training and test set comprising samples \( \{1, \ldots, n\} \setminus i \) and \( \{ i \} \), respectively.
-- Fit the linear regression model by means of ridge estimation for each \( \lambda \) in the grid using the training set, and the corresponding estimate of the error variance \( \boldsymbol{\sigma}_{-i}^2(\lambda) \), as
-
-
-$$
-\begin{align*}
-\boldsymbol{\beta}_{-i}(\lambda) & = ( \boldsymbol{X}_{-i, \ast}^{T}
-\boldsymbol{X}_{-i, \ast} + \lambda \boldsymbol{I}_{pp})^{-1}
-\boldsymbol{X}_{-i, \ast}^{T} \boldsymbol{y}_{-i}
-\end{align*}
-$$
-
-
-
-- Evaluate the prediction performance of these models on the test set by \( \log\{L[y_i, \boldsymbol{X}_{i, \ast}; \boldsymbol{\beta}_{-i}(\lambda), \boldsymbol{\sigma}_{-i}^2(\lambda)]\} \). Or, by the prediction error \( |y_i - \boldsymbol{X}_{i, \ast} \boldsymbol{\beta}_{-i}(\lambda)| \), the relative error, the error squared or the R2 score function.
-- Repeat the first three steps such that each sample plays the role of the test set once.
-- Average the prediction performances of the test sets at each grid point of the penalty bias/parameter. It is an estimate of the prediction performance of the model corresponding to this value of the penalty parameter on novel data. It is defined as
-
-
-$$
-\begin{align*}
-\frac{1}{n} \sum_{i = 1}^n \log\{L[y_i, \mathbf{X}_{i, \ast}; \boldsymbol{\beta}_{-i}(\lambda), \boldsymbol{\sigma}_{-i}^2(\lambda)]\}.
-\end{align*}
-$$
-
-
-
-
-
Cross-validation in brief
-
-
-For the various values of \( k \)
-
-
-- shuffle the dataset randomly.
-- Split the dataset into \( k \) groups.
-- For each unique group:
-
-
-- Decide which group to use as set for test data
-- Take the remaining groups as a training data set
-- Fit a model on the training set and evaluate it on the test set
-- Retain the evaluation score and discard the model
-
-
- Summarize the model using the sample of model evaluation scores
-
-
-
-
-Code Example for Cross-validation and \( k \)-fold Cross-validation
-
-
-The code here uses Ridge regression with cross-validation (CV) resampling and \( k \)-fold CV in order to fit a specific polynomial.
-
-
-
-
import numpy as np
-import matplotlib.pyplot as plt
-from sklearn.model_selection import KFold
-from sklearn.linear_model import Ridge
-from sklearn.model_selection import cross_val_score
-from sklearn.preprocessing import PolynomialFeatures
-
-# A seed just to ensure that the random numbers are the same for every run.
-# Useful for eventual debugging.
-np.random.seed(3155)
-
-# Generate the data.
-nsamples = 100
-x = np.random.randn(nsamples)
-y = 3*x**2 + np.random.randn(nsamples)
-
-## Cross-validation on Ridge regression using KFold only
-
-# Decide degree on polynomial to fit
-poly = PolynomialFeatures(degree = 6)
-
-# Decide which values of lambda to use
-nlambdas = 500
-lambdas = np.logspace(-3, 5, nlambdas)
-
-# Initialize a KFold instance
-k = 5
-kfold = KFold(n_splits = k)
-
-# Perform the cross-validation to estimate MSE
-scores_KFold = np.zeros((nlambdas, k))
-
-i = 0
-for lmb in lambdas:
- ridge = Ridge(alpha = lmb)
- j = 0
- for train_inds, test_inds in kfold.split(x):
- xtrain = x[train_inds]
- ytrain = y[train_inds]
-
- xtest = x[test_inds]
- ytest = y[test_inds]
-
- Xtrain = poly.fit_transform(xtrain[:, np.newaxis])
- ridge.fit(Xtrain, ytrain[:, np.newaxis])
-
- Xtest = poly.fit_transform(xtest[:, np.newaxis])
- ypred = ridge.predict(Xtest)
-
- scores_KFold[i,j] = np.sum((ypred - ytest[:, np.newaxis])**2)/np.size(ypred)
-
- j += 1
- i += 1
-
-
-estimated_mse_KFold = np.mean(scores_KFold, axis = 1)
-
-## Cross-validation using cross_val_score from sklearn along with KFold
-
-# kfold is an instance initialized above as:
-# kfold = KFold(n_splits = k)
-
-estimated_mse_sklearn = np.zeros(nlambdas)
-i = 0
-for lmb in lambdas:
- ridge = Ridge(alpha = lmb)
-
- X = poly.fit_transform(x[:, np.newaxis])
- estimated_mse_folds = cross_val_score(ridge, X, y[:, np.newaxis], scoring='neg_mean_squared_error', cv=kfold)
-
- # cross_val_score return an array containing the estimated negative mse for every fold.
- # we have to the the mean of every array in order to get an estimate of the mse of the model
- estimated_mse_sklearn[i] = np.mean(-estimated_mse_folds)
-
- i += 1
-
-## Plot and compare the slightly different ways to perform cross-validation
-
-plt.figure()
-
-plt.plot(np.log10(lambdas), estimated_mse_sklearn, label = 'cross_val_score')
-plt.plot(np.log10(lambdas), estimated_mse_KFold, 'r--', label = 'KFold')
-
-plt.xlabel('log10(lambda)')
-plt.ylabel('mse')
-
-plt.legend()
-
-plt.show()
-
-
-
-
-
The bias-variance tradeoff
-
-
-We will discuss the bias-variance tradeoff in the context of
-continuous predictions such as regression. However, many of the
-intuitions and ideas discussed here also carry over to classification
-tasks. Consider a dataset \( \mathcal{L} \) consisting of the data
-\( \mathbf{X}_\mathcal{L}=\{(y_j, \boldsymbol{x}_j), j=0\ldots n-1\} \).
-
-
-Let us assume that the true data is generated from a noisy model
-
-$$
-\boldsymbol{y}=f(\boldsymbol{x}) + \boldsymbol{\epsilon}
-$$
-
-
-where \( \epsilon \) is normally distributed with mean zero and standard deviation \( \sigma^2 \).
-
-
-In our derivation of the ordinary least squares method we defined then
-an approximation to the function \( f \) in terms of the parameters
-\( \boldsymbol{\beta} \) and the design matrix \( \boldsymbol{X} \) which embody our model,
-that is \( \boldsymbol{\tilde{y}}=\boldsymbol{X}\boldsymbol{\beta} \).
-
-
-Thereafter we found the parameters \( \boldsymbol{\beta} \) by optimizing the means squared error via the so-called cost function
-$$
-C(\boldsymbol{X},\boldsymbol{\beta}) =\frac{1}{n}\sum_{i=0}^{n-1}(y_i-\tilde{y}_i)^2=\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right].
-$$
-
-
-We can rewrite this as
-$$
-\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\frac{1}{n}\sum_i(f_i-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2+\frac{1}{n}\sum_i(\tilde{y}_i-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2+\sigma^2.
-$$
-
-
-The three terms represent the square of the bias of the learning
-method, which can be thought of as the error caused by the simplifying
-assumptions built into the method. The second term represents the
-variance of the chosen model and finally the last terms is variance of
-the error \( \boldsymbol{\epsilon} \).
-
-
-To derive this equation, we need to recall that the variance of \( \boldsymbol{y} \) and \( \boldsymbol{\epsilon} \) are both equal to \( \sigma^2 \). The mean value of \( \boldsymbol{\epsilon} \) is by definition equal to zero. Furthermore, the function \( f \) is not a stochastics variable, idem for \( \boldsymbol{\tilde{y}} \).
-We use a more compact notation in terms of the expectation value
-$$
-\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\mathbb{E}\left[(\boldsymbol{f}+\boldsymbol{\epsilon}-\boldsymbol{\tilde{y}})^2\right],
-$$
-
-and adding and subtracting \( \mathbb{E}\left[\boldsymbol{\tilde{y}}\right] \) we get
-$$
-\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\mathbb{E}\left[(\boldsymbol{f}+\boldsymbol{\epsilon}-\boldsymbol{\tilde{y}}+\mathbb{E}\left[\boldsymbol{\tilde{y}}\right]-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2\right],
-$$
-
-which, using the abovementioned expectation values can be rewritten as
-$$
-\mathbb{E}\left[(\boldsymbol{y}-\boldsymbol{\tilde{y}})^2\right]=\mathbb{E}\left[(\boldsymbol{y}-\mathbb{E}\left[\boldsymbol{\tilde{y}}\right])^2\right]+\mathrm{Var}\left[\boldsymbol{\tilde{y}}\right]+\sigma^2,
-$$
-
-that is the rewriting in terms of the so-called bias, the variance of the model \( \boldsymbol{\tilde{y}} \) and the variance of \( \boldsymbol{\epsilon} \).
-
-
-
-
-
Example code for Bias-Variance tradeoff
-
-
-
-
import matplotlib.pyplot as plt
-import numpy as np
-from sklearn.linear_model import LinearRegression, Ridge, Lasso
-from sklearn.preprocessing import PolynomialFeatures
-from sklearn.model_selection import train_test_split
-from sklearn.pipeline import make_pipeline
-from sklearn.utils import resample
-
-np.random.seed(2018)
-
-n = 500
-n_boostraps = 100
-degree = 18 # A quite high value, just to show.
-noise = 0.1
-
-# Make data set.
-x = np.linspace(-1, 3, n).reshape(-1, 1)
-y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2) + np.random.normal(0, 0.1, x.shape)
-
-# Hold out some test data that is never used in training.
-x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
-
-# Combine x transformation and model into one operation.
-# Not neccesary, but convenient.
-model = make_pipeline(PolynomialFeatures(degree=degree), LinearRegression(fit_intercept=False))
-
-# The following (m x n_bootstraps) matrix holds the column vectors y_pred
-# for each bootstrap iteration.
-y_pred = np.empty((y_test.shape[0], n_boostraps))
-for i in range(n_boostraps):
- x_, y_ = resample(x_train, y_train)
-
- # Evaluate the new model on the same test data each time.
- y_pred[:, i] = model.fit(x_, y_).predict(x_test).ravel()
-
-# Note: Expectations and variances taken w.r.t. different training
-# data sets, hence the axis=1. Subsequent means are taken across the test data
-# set in order to obtain a total value, but before this we have error/bias/variance
-# calculated per data point in the test set.
-# Note 2: The use of keepdims=True is important in the calculation of bias as this
-# maintains the column vector form. Dropping this yields very unexpected results.
-error = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) )
-bias = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 )
-variance = np.mean( np.var(y_pred, axis=1, keepdims=True) )
-print('Error:', error)
-print('Bias^2:', bias)
-print('Var:', variance)
-print('{} >= {} + {} = {}'.format(error, bias, variance, bias+variance))
-
-plt.plot(x[::5, :], y[::5, :], label='f(x)')
-plt.scatter(x_test, y_test, label='Data points')
-plt.scatter(x_test, np.mean(y_pred, axis=1), label='Pred')
-plt.legend()
-plt.show()
-
-
-
-
-
Understanding what happens
-
-
-
-
import matplotlib.pyplot as plt
-import numpy as np
-from sklearn.linear_model import LinearRegression, Ridge, Lasso
-from sklearn.preprocessing import PolynomialFeatures
-from sklearn.model_selection import train_test_split
-from sklearn.pipeline import make_pipeline
-from sklearn.utils import resample
-
-np.random.seed(2018)
-
-n = 40
-n_boostraps = 100
-maxdegree = 14
-
-
-# Make data set.
-x = np.linspace(-3, 3, n).reshape(-1, 1)
-y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape)
-error = np.zeros(maxdegree)
-bias = np.zeros(maxdegree)
-variance = np.zeros(maxdegree)
-polydegree = np.zeros(maxdegree)
-x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
-
-for degree in range(maxdegree):
- model = make_pipeline(PolynomialFeatures(degree=degree), LinearRegression(fit_intercept=False))
- y_pred = np.empty((y_test.shape[0], n_boostraps))
- for i in range(n_boostraps):
- x_, y_ = resample(x_train, y_train)
- y_pred[:, i] = model.fit(x_, y_).predict(x_test).ravel()
-
- polydegree[degree] = degree
- error[degree] = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) )
- bias[degree] = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 )
- variance[degree] = np.mean( np.var(y_pred, axis=1, keepdims=True) )
- print('Polynomial degree:', degree)
- print('Error:', error[degree])
- print('Bias^2:', bias[degree])
- print('Var:', variance[degree])
- print('{} >= {} + {} = {}'.format(error[degree], bias[degree], variance[degree], bias[degree]+variance[degree]))
-
-plt.plot(polydegree, error, label='Error')
-plt.plot(polydegree, bias, label='bias')
-plt.plot(polydegree, variance, label='Variance')
-plt.legend()
-plt.show()
-
-
-
-
-
Summing up
-
-
-The bias-variance tradeoff summarizes the fundamental tension in
-machine learning, particularly supervised learning, between the
-complexity of a model and the amount of training data needed to train
-it. Since data is often limited, in practice it is often useful to
-use a less-complex model with higher bias, that is a model whose asymptotic
-performance is worse than another model because it is easier to
-train and less sensitive to sampling noise arising from having a
-finite-sized training dataset (smaller variance).
-
-
-The above equations tell us that in
-order to minimize the expected test error, we need to select a
-statistical learning method that simultaneously achieves low variance
-and low bias. Note that variance is inherently a nonnegative quantity,
-and squared bias is also nonnegative. Hence, we see that the expected
-test MSE can never lie below \( Var(\epsilon) \), the irreducible error.
-
-
-What do we mean by the variance and bias of a statistical learning
-method? The variance refers to the amount by which our model would change if we
-estimated it using a different training data set. Since the training
-data are used to fit the statistical learning method, different
-training data sets will result in a different estimate. But ideally the
-estimate for our model should not vary too much between training
-sets. However, if a method has high variance then small changes in
-the training data can result in large changes in the model. In general, more
-flexible statistical methods have higher variance.
-
-
-You may also find this recent article of interest.
-
-
-
-
-
Another Example from Scikit-Learn's Repository
-
-
-
-
"""
-============================
-Underfitting vs. Overfitting
-============================
-
-This example demonstrates the problems of underfitting and overfitting and
-how we can use linear regression with polynomial features to approximate
-nonlinear functions. The plot shows the function that we want to approximate,
-which is a part of the cosine function. In addition, the samples from the
-real function and the approximations of different models are displayed. The
-models have polynomial features of different degrees. We can see that a
-linear function (polynomial with degree 1) is not sufficient to fit the
-training samples. This is called **underfitting**. A polynomial of degree 4
-approximates the true function almost perfectly. However, for higher degrees
-the model will **overfit** the training data, i.e. it learns the noise of the
-training data.
-We evaluate quantitatively **overfitting** / **underfitting** by using
-cross-validation. We calculate the mean squared error (MSE) on the validation
-set, the higher, the less likely the model generalizes correctly from the
-training data.
-"""
-
-print(__doc__)
-
-import numpy as np
-import matplotlib.pyplot as plt
-from sklearn.pipeline import Pipeline
-from sklearn.preprocessing import PolynomialFeatures
-from sklearn.linear_model import LinearRegression
-from sklearn.model_selection import cross_val_score
-
-
-def true_fun(X):
- return np.cos(1.5 * np.pi * X)
-
-np.random.seed(0)
-
-n_samples = 30
-degrees = [1, 4, 15]
-
-X = np.sort(np.random.rand(n_samples))
-y = true_fun(X) + np.random.randn(n_samples) * 0.1
-
-plt.figure(figsize=(14, 5))
-for i in range(len(degrees)):
- ax = plt.subplot(1, len(degrees), i + 1)
- plt.setp(ax, xticks=(), yticks=())
-
- polynomial_features = PolynomialFeatures(degree=degrees[i],
- include_bias=False)
- linear_regression = LinearRegression()
- pipeline = Pipeline([("polynomial_features", polynomial_features),
- ("linear_regression", linear_regression)])
- pipeline.fit(X[:, np.newaxis], y)
-
- # Evaluate the models using crossvalidation
- scores = cross_val_score(pipeline, X[:, np.newaxis], y,
- scoring="neg_mean_squared_error", cv=10)
-
- X_test = np.linspace(0, 1, 100)
- plt.plot(X_test, pipeline.predict(X_test[:, np.newaxis]), label="Model")
- plt.plot(X_test, true_fun(X_test), label="True function")
- plt.scatter(X, y, edgecolor='b', s=20, label="Samples")
- plt.xlabel("x")
- plt.ylabel("y")
- plt.xlim((0, 1))
- plt.ylim((-2, 2))
- plt.legend(loc="best")
- plt.title("Degree {}\nMSE = {:.2e}(+/- {:.2e})".format(
- degrees[i], -scores.mean(), scores.std()))
-plt.show()
-
-
-
-
-
More examples on bootstrap and cross-validation and errors
-
-
-
-
-
# Common imports
-import os
-import numpy as np
-import pandas as pd
-import matplotlib.pyplot as plt
-from sklearn.linear_model import LinearRegression, Ridge, Lasso
-from sklearn.model_selection import train_test_split
-from sklearn.utils import resample
-from sklearn.metrics import mean_squared_error
-# Where to save the figures and data files
-PROJECT_ROOT_DIR = "Results"
-FIGURE_ID = "Results/FigureFiles"
-DATA_ID = "DataFiles/"
-
-if not os.path.exists(PROJECT_ROOT_DIR):
- os.mkdir(PROJECT_ROOT_DIR)
-
-if not os.path.exists(FIGURE_ID):
- os.makedirs(FIGURE_ID)
-
-if not os.path.exists(DATA_ID):
- os.makedirs(DATA_ID)
-
-def image_path(fig_id):
- return os.path.join(FIGURE_ID, fig_id)
-
-def data_path(dat_id):
- return os.path.join(DATA_ID, dat_id)
-
-def save_fig(fig_id):
- plt.savefig(image_path(fig_id) + ".png", format='png')
-
-infile = open(data_path("EoS.csv"),'r')
-
-# Read the EoS data as csv file and organize the data into two arrays with density and energies
-EoS = pd.read_csv(infile, names=('Density', 'Energy'))
-EoS['Energy'] = pd.to_numeric(EoS['Energy'], errors='coerce')
-EoS = EoS.dropna()
-Energies = EoS['Energy']
-Density = EoS['Density']
-# The design matrix now as function of various polytrops
-
-Maxpolydegree = 30
-X = np.zeros((len(Density),Maxpolydegree))
-X[:,0] = 1.0
-testerror = np.zeros(Maxpolydegree)
-trainingerror = np.zeros(Maxpolydegree)
-polynomial = np.zeros(Maxpolydegree)
-
-trials = 100
-for polydegree in range(1, Maxpolydegree):
- polynomial[polydegree] = polydegree
- for degree in range(polydegree):
- X[:,degree] = Density**(degree/3.0)
-
-# loop over trials in order to estimate the expectation value of the MSE
- testerror[polydegree] = 0.0
- trainingerror[polydegree] = 0.0
- for samples in range(trials):
- x_train, x_test, y_train, y_test = train_test_split(X, Energies, test_size=0.2)
- model = LinearRegression(fit_intercept=True).fit(x_train, y_train)
- ypred = model.predict(x_train)
- ytilde = model.predict(x_test)
- testerror[polydegree] += mean_squared_error(y_test, ytilde)
- trainingerror[polydegree] += mean_squared_error(y_train, ypred)
-
- testerror[polydegree] /= trials
- trainingerror[polydegree] /= trials
- print("Degree of polynomial: %3d"% polynomial[polydegree])
- print("Mean squared error on training data: %.8f" % trainingerror[polydegree])
- print("Mean squared error on test data: %.8f" % testerror[polydegree])
-
-plt.plot(polynomial, np.log10(trainingerror), label='Training Error')
-plt.plot(polynomial, np.log10(testerror), label='Test Error')
-plt.xlabel('Polynomial degree')
-plt.ylabel('log10[MSE]')
-plt.legend()
-plt.show()
-
-
-
-
-
The same example but now with cross-validation
-
-
-
-
-
# Common imports
-import os
-import numpy as np
-import pandas as pd
-import matplotlib.pyplot as plt
-from sklearn.linear_model import LinearRegression, Ridge, Lasso
-from sklearn.metrics import mean_squared_error
-from sklearn.model_selection import KFold
-from sklearn.model_selection import cross_val_score
-
-
-# Where to save the figures and data files
-PROJECT_ROOT_DIR = "Results"
-FIGURE_ID = "Results/FigureFiles"
-DATA_ID = "DataFiles/"
-
-if not os.path.exists(PROJECT_ROOT_DIR):
- os.mkdir(PROJECT_ROOT_DIR)
-
-if not os.path.exists(FIGURE_ID):
- os.makedirs(FIGURE_ID)
-
-if not os.path.exists(DATA_ID):
- os.makedirs(DATA_ID)
-
-def image_path(fig_id):
- return os.path.join(FIGURE_ID, fig_id)
-
-def data_path(dat_id):
- return os.path.join(DATA_ID, dat_id)
-
-def save_fig(fig_id):
- plt.savefig(image_path(fig_id) + ".png", format='png')
-
-infile = open(data_path("EoS.csv"),'r')
-
-# Read the EoS data as csv file and organize the data into two arrays with density and energies
-EoS = pd.read_csv(infile, names=('Density', 'Energy'))
-EoS['Energy'] = pd.to_numeric(EoS['Energy'], errors='coerce')
-EoS = EoS.dropna()
-Energies = EoS['Energy']
-Density = EoS['Density']
-# The design matrix now as function of various polytrops
-
-Maxpolydegree = 30
-X = np.zeros((len(Density),Maxpolydegree))
-X[:,0] = 1.0
-estimated_mse_sklearn = np.zeros(Maxpolydegree)
-polynomial = np.zeros(Maxpolydegree)
-k =5
-kfold = KFold(n_splits = k)
-
-for polydegree in range(1, Maxpolydegree):
- polynomial[polydegree] = polydegree
- for degree in range(polydegree):
- X[:,degree] = Density**(degree/3.0)
- OLS = LinearRegression()
-# loop over trials in order to estimate the expectation value of the MSE
- estimated_mse_folds = cross_val_score(OLS, X, Energies, scoring='neg_mean_squared_error', cv=kfold)
-#[:, np.newaxis]
- estimated_mse_sklearn[polydegree] = np.mean(-estimated_mse_folds)
-
-plt.plot(polynomial, np.log10(estimated_mse_sklearn), label='Test Error')
-plt.xlabel('Polynomial degree')
-plt.ylabel('log10[MSE]')
-plt.legend()
-plt.show()
-
-
-
-
-
Cross-validation with Ridge
-
-
-
-
import numpy as np
-import matplotlib.pyplot as plt
-from sklearn.model_selection import KFold
-from sklearn.linear_model import Ridge
-from sklearn.model_selection import cross_val_score
-from sklearn.preprocessing import PolynomialFeatures
-
-# A seed just to ensure that the random numbers are the same for every run.
-np.random.seed(3155)
-# Generate the data.
-n = 100
-x = np.linspace(-3, 3, n).reshape(-1, 1)
-y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape)
-# Decide degree on polynomial to fit
-poly = PolynomialFeatures(degree = 10)
-
-# Decide which values of lambda to use
-nlambdas = 500
-lambdas = np.logspace(-3, 5, nlambdas)
-# Initialize a KFold instance
-k = 5
-kfold = KFold(n_splits = k)
-estimated_mse_sklearn = np.zeros(nlambdas)
-i = 0
-for lmb in lambdas:
- ridge = Ridge(alpha = lmb)
- estimated_mse_folds = cross_val_score(ridge, x, y, scoring='neg_mean_squared_error', cv=kfold)
- estimated_mse_sklearn[i] = np.mean(-estimated_mse_folds)
- i += 1
-plt.figure()
-plt.plot(np.log10(lambdas), estimated_mse_sklearn, label = 'cross_val_score')
-plt.xlabel('log10(lambda)')
-plt.ylabel('MSE')
-plt.legend()
-plt.show()
-
-
+which is our Lasso cost function!
diff --git a/doc/pub/week36/ipynb/ipynb-week36-src.tar.gz b/doc/pub/week36/ipynb/ipynb-week36-src.tar.gz
index 7b259faa9..c492f019c 100644
Binary files a/doc/pub/week36/ipynb/ipynb-week36-src.tar.gz and b/doc/pub/week36/ipynb/ipynb-week36-src.tar.gz differ
diff --git a/doc/pub/week36/ipynb/week36.ipynb b/doc/pub/week36/ipynb/week36.ipynb
index ce23f4f65..28ddb3cf6 100644
--- a/doc/pub/week36/ipynb/week36.ipynb
+++ b/doc/pub/week36/ipynb/week36.ipynb
@@ -2793,1183 +2793,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "which is our Lasso cost function! \n",
- "\n",
- "\n",
- "\n",
- "## Why resampling methods\n",
- "\n",
- "Before we proceed, we need to rethink what we have been doing. In our\n",
- "eager to fit the data, we have omitted several important elements in\n",
- "our regression analysis. In what follows we will\n",
- "1. look at statistical properties, including a discussion of mean values, variance and the so-called bias-variance tradeoff\n",
- "\n",
- "2. introduce resampling techniques like cross-validation, bootstrapping and jackknife and more\n",
- "\n",
- "This will allow us to link the standard linear algebra methods we have discussed above to a statistical interpretation of the methods. \n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "## Resampling methods\n",
- "Resampling methods are an indispensable tool in modern\n",
- "statistics. They involve repeatedly drawing samples from a training\n",
- "set and refitting a model of interest on each sample in order to\n",
- "obtain additional information about the fitted model. For example, in\n",
- "order to estimate the variability of a linear regression fit, we can\n",
- "repeatedly draw different samples from the training data, fit a linear\n",
- "regression to each new sample, and then examine the extent to which\n",
- "the resulting fits differ. Such an approach may allow us to obtain\n",
- "information that would not be available from fitting the model only\n",
- "once using the original training sample.\n",
- "\n",
- "Two resampling methods are often used in Machine Learning analyses,\n",
- "1. The **bootstrap method**\n",
- "\n",
- "2. and **Cross-Validation**\n",
- "\n",
- "In addition there are several other methods such as the Jackknife and the Blocking methods. We will discuss in particular\n",
- "cross-validation and the bootstrap method.\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "## Resampling approaches can be computationally expensive\n",
- "\n",
- "Resampling approaches can be computationally expensive, because they\n",
- "involve fitting the same statistical method multiple times using\n",
- "different subsets of the training data. However, due to recent\n",
- "advances in computing power, the computational requirements of\n",
- "resampling methods generally are not prohibitive. In this chapter, we\n",
- "discuss two of the most commonly used resampling methods,\n",
- "cross-validation and the bootstrap. Both methods are important tools\n",
- "in the practical application of many statistical learning\n",
- "procedures. For example, cross-validation can be used to estimate the\n",
- "test error associated with a given statistical learning method in\n",
- "order to evaluate its performance, or to select the appropriate level\n",
- "of flexibility. The process of evaluating a model’s performance is\n",
- "known as model assessment, whereas the process of selecting the proper\n",
- "level of flexibility for a model is known as model selection. The\n",
- "bootstrap is widely used.\n",
- "\n",
- "\n",
- "\n",
- "## Why resampling methods ?\n",
- "**Statistical analysis.**\n",
- "\n",
- "\n",
- "* Our simulations can be treated as *computer experiments*. This is particularly the case for Monte Carlo methods\n",
- "\n",
- "* The results can be analysed with the same statistical tools as we would use analysing experimental data.\n",
- "\n",
- "* As in all experiments, we are looking for expectation values and an estimate of how accurate they are, i.e., possible sources for errors.\n",
- "\n",
- " \n",
- "\n",
- "## Statistical analysis\n",
- "\n",
- "* As in other experiments, many numerical experiments have two classes of errors:\n",
- "\n",
- " * Statistical errors\n",
- "\n",
- " * Systematical errors\n",
- "\n",
- "\n",
- "* Statistical errors can be estimated using standard tools from statistics\n",
- "\n",
- "* Systematical errors are method specific and must be treated differently from case to case.\n",
- "\n",
- " \n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "## Resampling methods\n",
- "\n",
- "With all these analytical equations for both the OLS and Ridge\n",
- "regression, we will now outline how to assess a given model. This will\n",
- "lead us to a discussion of the so-called bias-variance tradeoff (see\n",
- "below) and so-called resampling methods.\n",
- "\n",
- "One of the quantities we have discussed as a way to measure errors is\n",
- "the mean-squared error (MSE), mainly used for fitting of continuous\n",
- "functions. Another choice is the absolute error.\n",
- "\n",
- "In the discussions below we will focus on the MSE and in particular since we will split the data into test and training data,\n",
- "we discuss the\n",
- "1. prediction error or simply the **test error** $\\mathrm{Err_{Test}}$, where we have a fixed training set and the test error is the MSE arising from the data reserved for testing. We discuss also the \n",
- "\n",
- "2. training error $\\mathrm{Err_{Train}}$, which is the average loss over the training data.\n",
- "\n",
- "As our model becomes more and more complex, more of the training data tends to used. The training may thence adapt to more complicated structures in the data. This may lead to a decrease in the bias (see below for code example) and a slight increase of the variance for the test error.\n",
- "For a certain level of complexity the test error will reach minimum, before starting to increase again. The\n",
- "training error reaches a saturation.\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "## Resampling methods: Jackknife and Bootstrap\n",
- "\n",
- "Two famous\n",
- "resampling methods are the **independent bootstrap** and **the jackknife**. \n",
- "\n",
- "The jackknife is a special case of the independent bootstrap. Still, the jackknife was made\n",
- "popular prior to the independent bootstrap. And as the popularity of\n",
- "the independent bootstrap soared, new variants, such as **the dependent bootstrap**.\n",
- "\n",
- "The Jackknife and independent bootstrap work for\n",
- "independent, identically distributed random variables.\n",
- "If these conditions are not\n",
- "satisfied, the methods will fail. Yet, it should be said that if the data are\n",
- "independent, identically distributed, and we only want to estimate the\n",
- "variance of $\\overline{X}$ (which often is the case), then there is no\n",
- "need for bootstrapping. \n",
- "\n",
- "## Resampling methods: Jackknife\n",
- "\n",
- "The Jackknife works by making many replicas of the estimator $\\widehat{\\theta}$. \n",
- "The jackknife is a resampling method where we systematically leave out one observation from the vector of observed values $\\boldsymbol{x} = (x_1,x_2,\\cdots,X_n)$. \n",
- "Let $\\boldsymbol{x}_i$ denote the vector"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "$$\n",
- "\\boldsymbol{x}_i = (x_1,x_2,\\cdots,x_{i-1},x_{i+1},\\cdots,x_n),\n",
- "$$"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "which equals the vector $\\boldsymbol{x}$ with the exception that observation\n",
- "number $i$ is left out. Using this notation, define\n",
- "$\\widehat{\\theta}_i$ to be the estimator\n",
- "$\\widehat{\\theta}$ computed using $\\vec{X}_i$. \n",
- "\n",
- "\n",
- "## Jackknife code example"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": false,
- "editable": true
- },
- "outputs": [],
- "source": [
- "from numpy import *\n",
- "from numpy.random import randint, randn\n",
- "from time import time\n",
- "\n",
- "def jackknife(data, stat):\n",
- " n = len(data);t = zeros(n); inds = arange(n); t0 = time()\n",
- " ## 'jackknifing' by leaving out an observation for each i \n",
- " for i in range(n):\n",
- " t[i] = stat(delete(data,i) )\n",
- "\n",
- " # analysis \n",
- " print(\"Runtime: %g sec\" % (time()-t0)); print(\"Jackknife Statistics :\")\n",
- " print(\"original bias std. error\")\n",
- " print(\"%8g %14g %15g\" % (stat(data),(n-1)*mean(t)/n, (n*var(t))**.5))\n",
- "\n",
- " return t\n",
- "\n",
- "\n",
- "# Returns mean of data samples \n",
- "def stat(data):\n",
- " return mean(data)\n",
- "\n",
- "\n",
- "mu, sigma = 100, 15\n",
- "datapoints = 10000\n",
- "x = mu + sigma*random.randn(datapoints)\n",
- "# jackknife returns the data sample \n",
- "t = jackknife(x, stat)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Resampling methods: Bootstrap\n",
- "Bootstrapping is a nonparametric approach to statistical inference\n",
- "that substitutes computation for more traditional distributional\n",
- "assumptions and asymptotic results. Bootstrapping offers a number of\n",
- "advantages: \n",
- "1. The bootstrap is quite general, although there are some cases in which it fails. \n",
- "\n",
- "2. Because it does not require distributional assumptions (such as normally distributed errors), the bootstrap can provide more accurate inferences when the data are not well behaved or when the sample size is small. \n",
- "\n",
- "3. It is possible to apply the bootstrap to statistics with sampling distributions that are difficult to derive, even asymptotically. \n",
- "\n",
- "4. It is relatively simple to apply the bootstrap to complex data-collection plans (such as stratified and clustered samples).\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "## Resampling methods: Bootstrap background\n",
- "\n",
- "Since $\\widehat{\\theta} = \\widehat{\\theta}(\\boldsymbol{X})$ is a function of random variables,\n",
- "$\\widehat{\\theta}$ itself must be a random variable. Thus it has\n",
- "a pdf, call this function $p(\\boldsymbol{t})$. The aim of the bootstrap is to\n",
- "estimate $p(\\boldsymbol{t})$ by the relative frequency of\n",
- "$\\widehat{\\theta}$. You can think of this as using a histogram\n",
- "in the place of $p(\\boldsymbol{t})$. If the relative frequency closely\n",
- "resembles $p(\\vec{t})$, then using numerics, it is straight forward to\n",
- "estimate all the interesting parameters of $p(\\boldsymbol{t})$ using point\n",
- "estimators. \n",
- "\n",
- "\n",
- "## Resampling methods: More Bootstrap background\n",
- "\n",
- "In the case that $\\widehat{\\theta}$ has\n",
- "more than one component, and the components are independent, we use the\n",
- "same estimator on each component separately. If the probability\n",
- "density function of $X_i$, $p(x)$, had been known, then it would have\n",
- "been straight forward to do this by: \n",
- "1. Drawing lots of numbers from $p(x)$, suppose we call one such set of numbers $(X_1^*, X_2^*, \\cdots, X_n^*)$. \n",
- "\n",
- "2. Then using these numbers, we could compute a replica of $\\widehat{\\theta}$ called $\\widehat{\\theta}^*$. \n",
- "\n",
- "By repeated use of (1) and (2), many\n",
- "estimates of $\\widehat{\\theta}$ could have been obtained. The\n",
- "idea is to use the relative frequency of $\\widehat{\\theta}^*$\n",
- "(think of a histogram) as an estimate of $p(\\boldsymbol{t})$.\n",
- "\n",
- "## Resampling methods: Bootstrap approach\n",
- "\n",
- "But\n",
- "unless there is enough information available about the process that\n",
- "generated $X_1,X_2,\\cdots,X_n$, $p(x)$ is in general\n",
- "unknown. Therefore, [Efron in 1979](https://projecteuclid.org/euclid.aos/1176344552) asked the\n",
- "question: What if we replace $p(x)$ by the relative frequency\n",
- "of the observation $X_i$; if we draw observations in accordance with\n",
- "the relative frequency of the observations, will we obtain the same\n",
- "result in some asymptotic sense? The answer is yes.\n",
- "\n",
- "\n",
- "Instead of generating the histogram for the relative\n",
- "frequency of the observation $X_i$, just draw the values\n",
- "$(X_1^*,X_2^*,\\cdots,X_n^*)$ with replacement from the vector\n",
- "$\\boldsymbol{X}$. \n",
- "\n",
- "## Resampling methods: Bootstrap steps\n",
- "\n",
- "The independent bootstrap works like this: \n",
- "\n",
- "1. Draw with replacement $n$ numbers for the observed variables $\\boldsymbol{x} = (x_1,x_2,\\cdots,x_n)$. \n",
- "\n",
- "2. Define a vector $\\boldsymbol{x}^*$ containing the values which were drawn from $\\boldsymbol{x}$. \n",
- "\n",
- "3. Using the vector $\\boldsymbol{x}^*$ compute $\\widehat{\\theta}^*$ by evaluating $\\widehat \\theta$ under the observations $\\boldsymbol{x}^*$. \n",
- "\n",
- "4. Repeat this process $k$ times. \n",
- "\n",
- "When you are done, you can draw a histogram of the relative frequency\n",
- "of $\\widehat \\theta^*$. This is your estimate of the probability\n",
- "distribution $p(t)$. Using this probability distribution you can\n",
- "estimate any statistics thereof. In principle you never draw the\n",
- "histogram of the relative frequency of $\\widehat{\\theta}^*$. Instead\n",
- "you use the estimators corresponding to the statistic of interest. For\n",
- "example, if you are interested in estimating the variance of $\\widehat\n",
- "\\theta$, apply the etsimator $\\widehat \\sigma^2$ to the values\n",
- "$\\widehat \\theta ^*$.\n",
- "\n",
- "\n",
- "## Code example for the Bootstrap method\n",
- "\n",
- "The following code starts with a Gaussian distribution with mean value\n",
- "$\\mu =100$ and variance $\\sigma=15$. We use this to generate the data\n",
- "used in the bootstrap analysis. The bootstrap analysis returns a data\n",
- "set after a given number of bootstrap operations (as many as we have\n",
- "data points). This data set consists of estimated mean values for each\n",
- "bootstrap operation. The histogram generated by the bootstrap method\n",
- "shows that the distribution for these mean values is also a Gaussian,\n",
- "centered around the mean value $\\mu=100$ but with standard deviation\n",
- "$\\sigma/\\sqrt{n}$, where $n$ is the number of bootstrap samples (in\n",
- "this case the same as the number of original data points). The value\n",
- "of the standard deviation is what we expect from the central limit\n",
- "theorem."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": false,
- "editable": true
- },
- "outputs": [],
- "source": [
- "from numpy import *\n",
- "from numpy.random import randint, randn\n",
- "from time import time\n",
- "import matplotlib.mlab as mlab\n",
- "import matplotlib.pyplot as plt\n",
- "\n",
- "# Returns mean of bootstrap samples \n",
- "def stat(data):\n",
- " return mean(data)\n",
- "\n",
- "# Bootstrap algorithm\n",
- "def bootstrap(data, statistic, R):\n",
- " t = zeros(R); n = len(data); inds = arange(n); t0 = time()\n",
- " # non-parametric bootstrap \n",
- " for i in range(R):\n",
- " t[i] = statistic(data[randint(0,n,n)])\n",
- "\n",
- " # analysis \n",
- " print(\"Runtime: %g sec\" % (time()-t0)); print(\"Bootstrap Statistics :\")\n",
- " print(\"original bias std. error\")\n",
- " print(\"%8g %8g %14g %15g\" % (statistic(data), std(data),mean(t),std(t)))\n",
- " return t\n",
- "\n",
- "\n",
- "mu, sigma = 100, 15\n",
- "datapoints = 10000\n",
- "x = mu + sigma*random.randn(datapoints)\n",
- "# bootstrap returns the data sample \n",
- "t = bootstrap(x, stat, datapoints)\n",
- "# the histogram of the bootstrapped data \n",
- "n, binsboot, patches = plt.hist(t, 50, normed=1, facecolor='red', alpha=0.75)\n",
- "\n",
- "# add a 'best fit' line \n",
- "y = mlab.normpdf( binsboot, mean(t), std(t))\n",
- "lt = plt.plot(binsboot, y, 'r--', linewidth=1)\n",
- "plt.xlabel('Smarts')\n",
- "plt.ylabel('Probability')\n",
- "plt.axis([99.5, 100.6, 0, 3.0])\n",
- "plt.grid(True)\n",
- "\n",
- "plt.show()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "\n",
- "## Various steps in cross-validation\n",
- "\n",
- "When the repetitive splitting of the data set is done randomly,\n",
- "samples may accidently end up in a fast majority of the splits in\n",
- "either training or test set. Such samples may have an unbalanced\n",
- "influence on either model building or prediction evaluation. To avoid\n",
- "this $k$-fold cross-validation structures the data splitting. The\n",
- "samples are divided into $k$ more or less equally sized exhaustive and\n",
- "mutually exclusive subsets. In turn (at each split) one of these\n",
- "subsets plays the role of the test set while the union of the\n",
- "remaining subsets constitutes the training set. Such a splitting\n",
- "warrants a balanced representation of each sample in both training and\n",
- "test set over the splits. Still the division into the $k$ subsets\n",
- "involves a degree of randomness. This may be fully excluded when\n",
- "choosing $k=n$. This particular case is referred to as leave-one-out\n",
- "cross-validation (LOOCV). \n",
- "\n",
- "\n",
- "## How to set up the cross-validation for Ridge and/or Lasso\n",
- "\n",
- "* Define a range of interest for the penalty parameter.\n",
- "\n",
- "* Divide the data set into training and test set comprising samples $\\{1, \\ldots, n\\} \\setminus i$ and $\\{ i \\}$, respectively.\n",
- "\n",
- "* Fit the linear regression model by means of ridge estimation for each $\\lambda$ in the grid using the training set, and the corresponding estimate of the error variance $\\boldsymbol{\\sigma}_{-i}^2(\\lambda)$, as"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "$$\n",
- "\\begin{align*}\n",
- "\\boldsymbol{\\beta}_{-i}(\\lambda) & = ( \\boldsymbol{X}_{-i, \\ast}^{T}\n",
- "\\boldsymbol{X}_{-i, \\ast} + \\lambda \\boldsymbol{I}_{pp})^{-1}\n",
- "\\boldsymbol{X}_{-i, \\ast}^{T} \\boldsymbol{y}_{-i}\n",
- "\\end{align*}\n",
- "$$"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "* Evaluate the prediction performance of these models on the test set by $\\log\\{L[y_i, \\boldsymbol{X}_{i, \\ast}; \\boldsymbol{\\beta}_{-i}(\\lambda), \\boldsymbol{\\sigma}_{-i}^2(\\lambda)]\\}$. Or, by the prediction error $|y_i - \\boldsymbol{X}_{i, \\ast} \\boldsymbol{\\beta}_{-i}(\\lambda)|$, the relative error, the error squared or the R2 score function.\n",
- "\n",
- "* Repeat the first three steps such that each sample plays the role of the test set once.\n",
- "\n",
- "* Average the prediction performances of the test sets at each grid point of the penalty bias/parameter. It is an estimate of the prediction performance of the model corresponding to this value of the penalty parameter on novel data. It is defined as"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "$$\n",
- "\\begin{align*}\n",
- "\\frac{1}{n} \\sum_{i = 1}^n \\log\\{L[y_i, \\mathbf{X}_{i, \\ast}; \\boldsymbol{\\beta}_{-i}(\\lambda), \\boldsymbol{\\sigma}_{-i}^2(\\lambda)]\\}.\n",
- "\\end{align*}\n",
- "$$"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Cross-validation in brief\n",
- "\n",
- "For the various values of $k$\n",
- "\n",
- "1. shuffle the dataset randomly.\n",
- "\n",
- "2. Split the dataset into $k$ groups.\n",
- "\n",
- "3. For each unique group:\n",
- "\n",
- "a. Decide which group to use as set for test data\n",
- "\n",
- "b. Take the remaining groups as a training data set\n",
- "\n",
- "c. Fit a model on the training set and evaluate it on the test set\n",
- "\n",
- "d. Retain the evaluation score and discard the model\n",
- "\n",
- "\n",
- "5. Summarize the model using the sample of model evaluation scores\n",
- "\n",
- "## Code Example for Cross-validation and $k$-fold Cross-validation\n",
- "\n",
- "The code here uses Ridge regression with cross-validation (CV) resampling and $k$-fold CV in order to fit a specific polynomial."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": false,
- "editable": true
- },
- "outputs": [],
- "source": [
- "import numpy as np\n",
- "import matplotlib.pyplot as plt\n",
- "from sklearn.model_selection import KFold\n",
- "from sklearn.linear_model import Ridge\n",
- "from sklearn.model_selection import cross_val_score\n",
- "from sklearn.preprocessing import PolynomialFeatures\n",
- "\n",
- "# A seed just to ensure that the random numbers are the same for every run.\n",
- "# Useful for eventual debugging.\n",
- "np.random.seed(3155)\n",
- "\n",
- "# Generate the data.\n",
- "nsamples = 100\n",
- "x = np.random.randn(nsamples)\n",
- "y = 3*x**2 + np.random.randn(nsamples)\n",
- "\n",
- "## Cross-validation on Ridge regression using KFold only\n",
- "\n",
- "# Decide degree on polynomial to fit\n",
- "poly = PolynomialFeatures(degree = 6)\n",
- "\n",
- "# Decide which values of lambda to use\n",
- "nlambdas = 500\n",
- "lambdas = np.logspace(-3, 5, nlambdas)\n",
- "\n",
- "# Initialize a KFold instance\n",
- "k = 5\n",
- "kfold = KFold(n_splits = k)\n",
- "\n",
- "# Perform the cross-validation to estimate MSE\n",
- "scores_KFold = np.zeros((nlambdas, k))\n",
- "\n",
- "i = 0\n",
- "for lmb in lambdas:\n",
- " ridge = Ridge(alpha = lmb)\n",
- " j = 0\n",
- " for train_inds, test_inds in kfold.split(x):\n",
- " xtrain = x[train_inds]\n",
- " ytrain = y[train_inds]\n",
- "\n",
- " xtest = x[test_inds]\n",
- " ytest = y[test_inds]\n",
- "\n",
- " Xtrain = poly.fit_transform(xtrain[:, np.newaxis])\n",
- " ridge.fit(Xtrain, ytrain[:, np.newaxis])\n",
- "\n",
- " Xtest = poly.fit_transform(xtest[:, np.newaxis])\n",
- " ypred = ridge.predict(Xtest)\n",
- "\n",
- " scores_KFold[i,j] = np.sum((ypred - ytest[:, np.newaxis])**2)/np.size(ypred)\n",
- "\n",
- " j += 1\n",
- " i += 1\n",
- "\n",
- "\n",
- "estimated_mse_KFold = np.mean(scores_KFold, axis = 1)\n",
- "\n",
- "## Cross-validation using cross_val_score from sklearn along with KFold\n",
- "\n",
- "# kfold is an instance initialized above as:\n",
- "# kfold = KFold(n_splits = k)\n",
- "\n",
- "estimated_mse_sklearn = np.zeros(nlambdas)\n",
- "i = 0\n",
- "for lmb in lambdas:\n",
- " ridge = Ridge(alpha = lmb)\n",
- "\n",
- " X = poly.fit_transform(x[:, np.newaxis])\n",
- " estimated_mse_folds = cross_val_score(ridge, X, y[:, np.newaxis], scoring='neg_mean_squared_error', cv=kfold)\n",
- "\n",
- " # cross_val_score return an array containing the estimated negative mse for every fold.\n",
- " # we have to the the mean of every array in order to get an estimate of the mse of the model\n",
- " estimated_mse_sklearn[i] = np.mean(-estimated_mse_folds)\n",
- "\n",
- " i += 1\n",
- "\n",
- "## Plot and compare the slightly different ways to perform cross-validation\n",
- "\n",
- "plt.figure()\n",
- "\n",
- "plt.plot(np.log10(lambdas), estimated_mse_sklearn, label = 'cross_val_score')\n",
- "plt.plot(np.log10(lambdas), estimated_mse_KFold, 'r--', label = 'KFold')\n",
- "\n",
- "plt.xlabel('log10(lambda)')\n",
- "plt.ylabel('mse')\n",
- "\n",
- "plt.legend()\n",
- "\n",
- "plt.show()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## The bias-variance tradeoff\n",
- "\n",
- "\n",
- "We will discuss the bias-variance tradeoff in the context of\n",
- "continuous predictions such as regression. However, many of the\n",
- "intuitions and ideas discussed here also carry over to classification\n",
- "tasks. Consider a dataset $\\mathcal{L}$ consisting of the data\n",
- "$\\mathbf{X}_\\mathcal{L}=\\{(y_j, \\boldsymbol{x}_j), j=0\\ldots n-1\\}$. \n",
- "\n",
- "Let us assume that the true data is generated from a noisy model"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "$$\n",
- "\\boldsymbol{y}=f(\\boldsymbol{x}) + \\boldsymbol{\\epsilon}\n",
- "$$"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "where $\\epsilon$ is normally distributed with mean zero and standard deviation $\\sigma^2$.\n",
- "\n",
- "In our derivation of the ordinary least squares method we defined then\n",
- "an approximation to the function $f$ in terms of the parameters\n",
- "$\\boldsymbol{\\beta}$ and the design matrix $\\boldsymbol{X}$ which embody our model,\n",
- "that is $\\boldsymbol{\\tilde{y}}=\\boldsymbol{X}\\boldsymbol{\\beta}$. \n",
- "\n",
- "Thereafter we found the parameters $\\boldsymbol{\\beta}$ by optimizing the means squared error via the so-called cost function"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "$$\n",
- "C(\\boldsymbol{X},\\boldsymbol{\\beta}) =\\frac{1}{n}\\sum_{i=0}^{n-1}(y_i-\\tilde{y}_i)^2=\\mathbb{E}\\left[(\\boldsymbol{y}-\\boldsymbol{\\tilde{y}})^2\\right].\n",
- "$$"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "We can rewrite this as"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "$$\n",
- "\\mathbb{E}\\left[(\\boldsymbol{y}-\\boldsymbol{\\tilde{y}})^2\\right]=\\frac{1}{n}\\sum_i(f_i-\\mathbb{E}\\left[\\boldsymbol{\\tilde{y}}\\right])^2+\\frac{1}{n}\\sum_i(\\tilde{y}_i-\\mathbb{E}\\left[\\boldsymbol{\\tilde{y}}\\right])^2+\\sigma^2.\n",
- "$$"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "The three terms represent the square of the bias of the learning\n",
- "method, which can be thought of as the error caused by the simplifying\n",
- "assumptions built into the method. The second term represents the\n",
- "variance of the chosen model and finally the last terms is variance of\n",
- "the error $\\boldsymbol{\\epsilon}$.\n",
- "\n",
- "To derive this equation, we need to recall that the variance of $\\boldsymbol{y}$ and $\\boldsymbol{\\epsilon}$ are both equal to $\\sigma^2$. The mean value of $\\boldsymbol{\\epsilon}$ is by definition equal to zero. Furthermore, the function $f$ is not a stochastics variable, idem for $\\boldsymbol{\\tilde{y}}$.\n",
- "We use a more compact notation in terms of the expectation value"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "$$\n",
- "\\mathbb{E}\\left[(\\boldsymbol{y}-\\boldsymbol{\\tilde{y}})^2\\right]=\\mathbb{E}\\left[(\\boldsymbol{f}+\\boldsymbol{\\epsilon}-\\boldsymbol{\\tilde{y}})^2\\right],\n",
- "$$"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "and adding and subtracting $\\mathbb{E}\\left[\\boldsymbol{\\tilde{y}}\\right]$ we get"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "$$\n",
- "\\mathbb{E}\\left[(\\boldsymbol{y}-\\boldsymbol{\\tilde{y}})^2\\right]=\\mathbb{E}\\left[(\\boldsymbol{f}+\\boldsymbol{\\epsilon}-\\boldsymbol{\\tilde{y}}+\\mathbb{E}\\left[\\boldsymbol{\\tilde{y}}\\right]-\\mathbb{E}\\left[\\boldsymbol{\\tilde{y}}\\right])^2\\right],\n",
- "$$"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "which, using the abovementioned expectation values can be rewritten as"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "$$\n",
- "\\mathbb{E}\\left[(\\boldsymbol{y}-\\boldsymbol{\\tilde{y}})^2\\right]=\\mathbb{E}\\left[(\\boldsymbol{y}-\\mathbb{E}\\left[\\boldsymbol{\\tilde{y}}\\right])^2\\right]+\\mathrm{Var}\\left[\\boldsymbol{\\tilde{y}}\\right]+\\sigma^2,\n",
- "$$"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "that is the rewriting in terms of the so-called bias, the variance of the model $\\boldsymbol{\\tilde{y}}$ and the variance of $\\boldsymbol{\\epsilon}$.\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "## Example code for Bias-Variance tradeoff"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": false,
- "editable": true
- },
- "outputs": [],
- "source": [
- "import matplotlib.pyplot as plt\n",
- "import numpy as np\n",
- "from sklearn.linear_model import LinearRegression, Ridge, Lasso\n",
- "from sklearn.preprocessing import PolynomialFeatures\n",
- "from sklearn.model_selection import train_test_split\n",
- "from sklearn.pipeline import make_pipeline\n",
- "from sklearn.utils import resample\n",
- "\n",
- "np.random.seed(2018)\n",
- "\n",
- "n = 500\n",
- "n_boostraps = 100\n",
- "degree = 18 # A quite high value, just to show.\n",
- "noise = 0.1\n",
- "\n",
- "# Make data set.\n",
- "x = np.linspace(-1, 3, n).reshape(-1, 1)\n",
- "y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2) + np.random.normal(0, 0.1, x.shape)\n",
- "\n",
- "# Hold out some test data that is never used in training.\n",
- "x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)\n",
- "\n",
- "# Combine x transformation and model into one operation.\n",
- "# Not neccesary, but convenient.\n",
- "model = make_pipeline(PolynomialFeatures(degree=degree), LinearRegression(fit_intercept=False))\n",
- "\n",
- "# The following (m x n_bootstraps) matrix holds the column vectors y_pred\n",
- "# for each bootstrap iteration.\n",
- "y_pred = np.empty((y_test.shape[0], n_boostraps))\n",
- "for i in range(n_boostraps):\n",
- " x_, y_ = resample(x_train, y_train)\n",
- "\n",
- " # Evaluate the new model on the same test data each time.\n",
- " y_pred[:, i] = model.fit(x_, y_).predict(x_test).ravel()\n",
- "\n",
- "# Note: Expectations and variances taken w.r.t. different training\n",
- "# data sets, hence the axis=1. Subsequent means are taken across the test data\n",
- "# set in order to obtain a total value, but before this we have error/bias/variance\n",
- "# calculated per data point in the test set.\n",
- "# Note 2: The use of keepdims=True is important in the calculation of bias as this \n",
- "# maintains the column vector form. Dropping this yields very unexpected results.\n",
- "error = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) )\n",
- "bias = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 )\n",
- "variance = np.mean( np.var(y_pred, axis=1, keepdims=True) )\n",
- "print('Error:', error)\n",
- "print('Bias^2:', bias)\n",
- "print('Var:', variance)\n",
- "print('{} >= {} + {} = {}'.format(error, bias, variance, bias+variance))\n",
- "\n",
- "plt.plot(x[::5, :], y[::5, :], label='f(x)')\n",
- "plt.scatter(x_test, y_test, label='Data points')\n",
- "plt.scatter(x_test, np.mean(y_pred, axis=1), label='Pred')\n",
- "plt.legend()\n",
- "plt.show()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Understanding what happens"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": false,
- "editable": true
- },
- "outputs": [],
- "source": [
- "import matplotlib.pyplot as plt\n",
- "import numpy as np\n",
- "from sklearn.linear_model import LinearRegression, Ridge, Lasso\n",
- "from sklearn.preprocessing import PolynomialFeatures\n",
- "from sklearn.model_selection import train_test_split\n",
- "from sklearn.pipeline import make_pipeline\n",
- "from sklearn.utils import resample\n",
- "\n",
- "np.random.seed(2018)\n",
- "\n",
- "n = 40\n",
- "n_boostraps = 100\n",
- "maxdegree = 14\n",
- "\n",
- "\n",
- "# Make data set.\n",
- "x = np.linspace(-3, 3, n).reshape(-1, 1)\n",
- "y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape)\n",
- "error = np.zeros(maxdegree)\n",
- "bias = np.zeros(maxdegree)\n",
- "variance = np.zeros(maxdegree)\n",
- "polydegree = np.zeros(maxdegree)\n",
- "x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)\n",
- "\n",
- "for degree in range(maxdegree):\n",
- " model = make_pipeline(PolynomialFeatures(degree=degree), LinearRegression(fit_intercept=False))\n",
- " y_pred = np.empty((y_test.shape[0], n_boostraps))\n",
- " for i in range(n_boostraps):\n",
- " x_, y_ = resample(x_train, y_train)\n",
- " y_pred[:, i] = model.fit(x_, y_).predict(x_test).ravel()\n",
- "\n",
- " polydegree[degree] = degree\n",
- " error[degree] = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) )\n",
- " bias[degree] = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 )\n",
- " variance[degree] = np.mean( np.var(y_pred, axis=1, keepdims=True) )\n",
- " print('Polynomial degree:', degree)\n",
- " print('Error:', error[degree])\n",
- " print('Bias^2:', bias[degree])\n",
- " print('Var:', variance[degree])\n",
- " print('{} >= {} + {} = {}'.format(error[degree], bias[degree], variance[degree], bias[degree]+variance[degree]))\n",
- "\n",
- "plt.plot(polydegree, error, label='Error')\n",
- "plt.plot(polydegree, bias, label='bias')\n",
- "plt.plot(polydegree, variance, label='Variance')\n",
- "plt.legend()\n",
- "plt.show()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "\n",
- "## Summing up\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "The bias-variance tradeoff summarizes the fundamental tension in\n",
- "machine learning, particularly supervised learning, between the\n",
- "complexity of a model and the amount of training data needed to train\n",
- "it. Since data is often limited, in practice it is often useful to\n",
- "use a less-complex model with higher bias, that is a model whose asymptotic\n",
- "performance is worse than another model because it is easier to\n",
- "train and less sensitive to sampling noise arising from having a\n",
- "finite-sized training dataset (smaller variance). \n",
- "\n",
- "\n",
- "\n",
- "The above equations tell us that in\n",
- "order to minimize the expected test error, we need to select a\n",
- "statistical learning method that simultaneously achieves low variance\n",
- "and low bias. Note that variance is inherently a nonnegative quantity,\n",
- "and squared bias is also nonnegative. Hence, we see that the expected\n",
- "test MSE can never lie below $Var(\\epsilon)$, the irreducible error.\n",
- "\n",
- "\n",
- "What do we mean by the variance and bias of a statistical learning\n",
- "method? The variance refers to the amount by which our model would change if we\n",
- "estimated it using a different training data set. Since the training\n",
- "data are used to fit the statistical learning method, different\n",
- "training data sets will result in a different estimate. But ideally the\n",
- "estimate for our model should not vary too much between training\n",
- "sets. However, if a method has high variance then small changes in\n",
- "the training data can result in large changes in the model. In general, more\n",
- "flexible statistical methods have higher variance.\n",
- "\n",
- "\n",
- "You may also find this recent [article](https://www.pnas.org/content/116/32/15849) of interest.\n",
- "\n",
- "## Another Example from Scikit-Learn's Repository"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": false,
- "editable": true
- },
- "outputs": [],
- "source": [
- "\"\"\"\n",
- "============================\n",
- "Underfitting vs. Overfitting\n",
- "============================\n",
- "\n",
- "This example demonstrates the problems of underfitting and overfitting and\n",
- "how we can use linear regression with polynomial features to approximate\n",
- "nonlinear functions. The plot shows the function that we want to approximate,\n",
- "which is a part of the cosine function. In addition, the samples from the\n",
- "real function and the approximations of different models are displayed. The\n",
- "models have polynomial features of different degrees. We can see that a\n",
- "linear function (polynomial with degree 1) is not sufficient to fit the\n",
- "training samples. This is called **underfitting**. A polynomial of degree 4\n",
- "approximates the true function almost perfectly. However, for higher degrees\n",
- "the model will **overfit** the training data, i.e. it learns the noise of the\n",
- "training data.\n",
- "We evaluate quantitatively **overfitting** / **underfitting** by using\n",
- "cross-validation. We calculate the mean squared error (MSE) on the validation\n",
- "set, the higher, the less likely the model generalizes correctly from the\n",
- "training data.\n",
- "\"\"\"\n",
- "\n",
- "print(__doc__)\n",
- "\n",
- "import numpy as np\n",
- "import matplotlib.pyplot as plt\n",
- "from sklearn.pipeline import Pipeline\n",
- "from sklearn.preprocessing import PolynomialFeatures\n",
- "from sklearn.linear_model import LinearRegression\n",
- "from sklearn.model_selection import cross_val_score\n",
- "\n",
- "\n",
- "def true_fun(X):\n",
- " return np.cos(1.5 * np.pi * X)\n",
- "\n",
- "np.random.seed(0)\n",
- "\n",
- "n_samples = 30\n",
- "degrees = [1, 4, 15]\n",
- "\n",
- "X = np.sort(np.random.rand(n_samples))\n",
- "y = true_fun(X) + np.random.randn(n_samples) * 0.1\n",
- "\n",
- "plt.figure(figsize=(14, 5))\n",
- "for i in range(len(degrees)):\n",
- " ax = plt.subplot(1, len(degrees), i + 1)\n",
- " plt.setp(ax, xticks=(), yticks=())\n",
- "\n",
- " polynomial_features = PolynomialFeatures(degree=degrees[i],\n",
- " include_bias=False)\n",
- " linear_regression = LinearRegression()\n",
- " pipeline = Pipeline([(\"polynomial_features\", polynomial_features),\n",
- " (\"linear_regression\", linear_regression)])\n",
- " pipeline.fit(X[:, np.newaxis], y)\n",
- "\n",
- " # Evaluate the models using crossvalidation\n",
- " scores = cross_val_score(pipeline, X[:, np.newaxis], y,\n",
- " scoring=\"neg_mean_squared_error\", cv=10)\n",
- "\n",
- " X_test = np.linspace(0, 1, 100)\n",
- " plt.plot(X_test, pipeline.predict(X_test[:, np.newaxis]), label=\"Model\")\n",
- " plt.plot(X_test, true_fun(X_test), label=\"True function\")\n",
- " plt.scatter(X, y, edgecolor='b', s=20, label=\"Samples\")\n",
- " plt.xlabel(\"x\")\n",
- " plt.ylabel(\"y\")\n",
- " plt.xlim((0, 1))\n",
- " plt.ylim((-2, 2))\n",
- " plt.legend(loc=\"best\")\n",
- " plt.title(\"Degree {}\\nMSE = {:.2e}(+/- {:.2e})\".format(\n",
- " degrees[i], -scores.mean(), scores.std()))\n",
- "plt.show()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## More examples on bootstrap and cross-validation and errors"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": false,
- "editable": true
- },
- "outputs": [],
- "source": [
- "# Common imports\n",
- "import os\n",
- "import numpy as np\n",
- "import pandas as pd\n",
- "import matplotlib.pyplot as plt\n",
- "from sklearn.linear_model import LinearRegression, Ridge, Lasso\n",
- "from sklearn.model_selection import train_test_split\n",
- "from sklearn.utils import resample\n",
- "from sklearn.metrics import mean_squared_error\n",
- "# Where to save the figures and data files\n",
- "PROJECT_ROOT_DIR = \"Results\"\n",
- "FIGURE_ID = \"Results/FigureFiles\"\n",
- "DATA_ID = \"DataFiles/\"\n",
- "\n",
- "if not os.path.exists(PROJECT_ROOT_DIR):\n",
- " os.mkdir(PROJECT_ROOT_DIR)\n",
- "\n",
- "if not os.path.exists(FIGURE_ID):\n",
- " os.makedirs(FIGURE_ID)\n",
- "\n",
- "if not os.path.exists(DATA_ID):\n",
- " os.makedirs(DATA_ID)\n",
- "\n",
- "def image_path(fig_id):\n",
- " return os.path.join(FIGURE_ID, fig_id)\n",
- "\n",
- "def data_path(dat_id):\n",
- " return os.path.join(DATA_ID, dat_id)\n",
- "\n",
- "def save_fig(fig_id):\n",
- " plt.savefig(image_path(fig_id) + \".png\", format='png')\n",
- "\n",
- "infile = open(data_path(\"EoS.csv\"),'r')\n",
- "\n",
- "# Read the EoS data as csv file and organize the data into two arrays with density and energies\n",
- "EoS = pd.read_csv(infile, names=('Density', 'Energy'))\n",
- "EoS['Energy'] = pd.to_numeric(EoS['Energy'], errors='coerce')\n",
- "EoS = EoS.dropna()\n",
- "Energies = EoS['Energy']\n",
- "Density = EoS['Density']\n",
- "# The design matrix now as function of various polytrops\n",
- "\n",
- "Maxpolydegree = 30\n",
- "X = np.zeros((len(Density),Maxpolydegree))\n",
- "X[:,0] = 1.0\n",
- "testerror = np.zeros(Maxpolydegree)\n",
- "trainingerror = np.zeros(Maxpolydegree)\n",
- "polynomial = np.zeros(Maxpolydegree)\n",
- "\n",
- "trials = 100\n",
- "for polydegree in range(1, Maxpolydegree):\n",
- " polynomial[polydegree] = polydegree\n",
- " for degree in range(polydegree):\n",
- " X[:,degree] = Density**(degree/3.0)\n",
- "\n",
- "# loop over trials in order to estimate the expectation value of the MSE\n",
- " testerror[polydegree] = 0.0\n",
- " trainingerror[polydegree] = 0.0\n",
- " for samples in range(trials):\n",
- " x_train, x_test, y_train, y_test = train_test_split(X, Energies, test_size=0.2)\n",
- " model = LinearRegression(fit_intercept=True).fit(x_train, y_train)\n",
- " ypred = model.predict(x_train)\n",
- " ytilde = model.predict(x_test)\n",
- " testerror[polydegree] += mean_squared_error(y_test, ytilde)\n",
- " trainingerror[polydegree] += mean_squared_error(y_train, ypred) \n",
- "\n",
- " testerror[polydegree] /= trials\n",
- " trainingerror[polydegree] /= trials\n",
- " print(\"Degree of polynomial: %3d\"% polynomial[polydegree])\n",
- " print(\"Mean squared error on training data: %.8f\" % trainingerror[polydegree])\n",
- " print(\"Mean squared error on test data: %.8f\" % testerror[polydegree])\n",
- "\n",
- "plt.plot(polynomial, np.log10(trainingerror), label='Training Error')\n",
- "plt.plot(polynomial, np.log10(testerror), label='Test Error')\n",
- "plt.xlabel('Polynomial degree')\n",
- "plt.ylabel('log10[MSE]')\n",
- "plt.legend()\n",
- "plt.show()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "\n",
- "## The same example but now with cross-validation"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": false,
- "editable": true
- },
- "outputs": [],
- "source": [
- "# Common imports\n",
- "import os\n",
- "import numpy as np\n",
- "import pandas as pd\n",
- "import matplotlib.pyplot as plt\n",
- "from sklearn.linear_model import LinearRegression, Ridge, Lasso\n",
- "from sklearn.metrics import mean_squared_error\n",
- "from sklearn.model_selection import KFold\n",
- "from sklearn.model_selection import cross_val_score\n",
- "\n",
- "\n",
- "# Where to save the figures and data files\n",
- "PROJECT_ROOT_DIR = \"Results\"\n",
- "FIGURE_ID = \"Results/FigureFiles\"\n",
- "DATA_ID = \"DataFiles/\"\n",
- "\n",
- "if not os.path.exists(PROJECT_ROOT_DIR):\n",
- " os.mkdir(PROJECT_ROOT_DIR)\n",
- "\n",
- "if not os.path.exists(FIGURE_ID):\n",
- " os.makedirs(FIGURE_ID)\n",
- "\n",
- "if not os.path.exists(DATA_ID):\n",
- " os.makedirs(DATA_ID)\n",
- "\n",
- "def image_path(fig_id):\n",
- " return os.path.join(FIGURE_ID, fig_id)\n",
- "\n",
- "def data_path(dat_id):\n",
- " return os.path.join(DATA_ID, dat_id)\n",
- "\n",
- "def save_fig(fig_id):\n",
- " plt.savefig(image_path(fig_id) + \".png\", format='png')\n",
- "\n",
- "infile = open(data_path(\"EoS.csv\"),'r')\n",
- "\n",
- "# Read the EoS data as csv file and organize the data into two arrays with density and energies\n",
- "EoS = pd.read_csv(infile, names=('Density', 'Energy'))\n",
- "EoS['Energy'] = pd.to_numeric(EoS['Energy'], errors='coerce')\n",
- "EoS = EoS.dropna()\n",
- "Energies = EoS['Energy']\n",
- "Density = EoS['Density']\n",
- "# The design matrix now as function of various polytrops\n",
- "\n",
- "Maxpolydegree = 30\n",
- "X = np.zeros((len(Density),Maxpolydegree))\n",
- "X[:,0] = 1.0\n",
- "estimated_mse_sklearn = np.zeros(Maxpolydegree)\n",
- "polynomial = np.zeros(Maxpolydegree)\n",
- "k =5\n",
- "kfold = KFold(n_splits = k)\n",
- "\n",
- "for polydegree in range(1, Maxpolydegree):\n",
- " polynomial[polydegree] = polydegree\n",
- " for degree in range(polydegree):\n",
- " X[:,degree] = Density**(degree/3.0)\n",
- " OLS = LinearRegression()\n",
- "# loop over trials in order to estimate the expectation value of the MSE\n",
- " estimated_mse_folds = cross_val_score(OLS, X, Energies, scoring='neg_mean_squared_error', cv=kfold)\n",
- "#[:, np.newaxis]\n",
- " estimated_mse_sklearn[polydegree] = np.mean(-estimated_mse_folds)\n",
- "\n",
- "plt.plot(polynomial, np.log10(estimated_mse_sklearn), label='Test Error')\n",
- "plt.xlabel('Polynomial degree')\n",
- "plt.ylabel('log10[MSE]')\n",
- "plt.legend()\n",
- "plt.show()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Cross-validation with Ridge"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": false,
- "editable": true
- },
- "outputs": [],
- "source": [
- "import numpy as np\n",
- "import matplotlib.pyplot as plt\n",
- "from sklearn.model_selection import KFold\n",
- "from sklearn.linear_model import Ridge\n",
- "from sklearn.model_selection import cross_val_score\n",
- "from sklearn.preprocessing import PolynomialFeatures\n",
- "\n",
- "# A seed just to ensure that the random numbers are the same for every run.\n",
- "np.random.seed(3155)\n",
- "# Generate the data.\n",
- "n = 100\n",
- "x = np.linspace(-3, 3, n).reshape(-1, 1)\n",
- "y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape)\n",
- "# Decide degree on polynomial to fit\n",
- "poly = PolynomialFeatures(degree = 10)\n",
- "\n",
- "# Decide which values of lambda to use\n",
- "nlambdas = 500\n",
- "lambdas = np.logspace(-3, 5, nlambdas)\n",
- "# Initialize a KFold instance\n",
- "k = 5\n",
- "kfold = KFold(n_splits = k)\n",
- "estimated_mse_sklearn = np.zeros(nlambdas)\n",
- "i = 0\n",
- "for lmb in lambdas:\n",
- " ridge = Ridge(alpha = lmb)\n",
- " estimated_mse_folds = cross_val_score(ridge, x, y, scoring='neg_mean_squared_error', cv=kfold)\n",
- " estimated_mse_sklearn[i] = np.mean(-estimated_mse_folds)\n",
- " i += 1\n",
- "plt.figure()\n",
- "plt.plot(np.log10(lambdas), estimated_mse_sklearn, label = 'cross_val_score')\n",
- "plt.xlabel('log10(lambda)')\n",
- "plt.ylabel('MSE')\n",
- "plt.legend()\n",
- "plt.show()"
+ "which is our Lasso cost function!"
]
}
],
diff --git a/doc/src/week36/week36.do.txt b/doc/src/week36/week36.do.txt
index b0ae2bd4e..450a493d2 100644
--- a/doc/src/week36/week36.do.txt
+++ b/doc/src/week36/week36.do.txt
@@ -1834,998 +1834,3 @@ C(\bm{\beta}=\frac{\vert\vert (\bm{y}-\bm{X}\bm{\beta})\vert\vert_2^2}{2\sigma^2
!et
which is our Lasso cost function!
-
-
-!split
-===== Why resampling methods =====
-
-Before we proceed, we need to rethink what we have been doing. In our
-eager to fit the data, we have omitted several important elements in
-our regression analysis. In what follows we will
-o look at statistical properties, including a discussion of mean values, variance and the so-called bias-variance tradeoff
-o introduce resampling techniques like cross-validation, bootstrapping and jackknife and more
-
-This will allow us to link the standard linear algebra methods we have discussed above to a statistical interpretation of the methods.
-
-
-
-
-
-!split
-===== Resampling methods =====
-!bblock
-Resampling methods are an indispensable tool in modern
-statistics. They involve repeatedly drawing samples from a training
-set and refitting a model of interest on each sample in order to
-obtain additional information about the fitted model. For example, in
-order to estimate the variability of a linear regression fit, we can
-repeatedly draw different samples from the training data, fit a linear
-regression to each new sample, and then examine the extent to which
-the resulting fits differ. Such an approach may allow us to obtain
-information that would not be available from fitting the model only
-once using the original training sample.
-
-Two resampling methods are often used in Machine Learning analyses,
-o The _bootstrap method_
-o and _Cross-Validation_
-
-In addition there are several other methods such as the Jackknife and the Blocking methods. We will discuss in particular
-cross-validation and the bootstrap method.
-
-
-!eblock
-
-
-!split
-===== Resampling approaches can be computationally expensive =====
-!bblock
-
-Resampling approaches can be computationally expensive, because they
-involve fitting the same statistical method multiple times using
-different subsets of the training data. However, due to recent
-advances in computing power, the computational requirements of
-resampling methods generally are not prohibitive. In this chapter, we
-discuss two of the most commonly used resampling methods,
-cross-validation and the bootstrap. Both methods are important tools
-in the practical application of many statistical learning
-procedures. For example, cross-validation can be used to estimate the
-test error associated with a given statistical learning method in
-order to evaluate its performance, or to select the appropriate level
-of flexibility. The process of evaluating a model’s performance is
-known as model assessment, whereas the process of selecting the proper
-level of flexibility for a model is known as model selection. The
-bootstrap is widely used.
-
-!eblock
-
-!split
-===== Why resampling methods ? =====
-!bblock Statistical analysis
-
-* Our simulations can be treated as *computer experiments*. This is particularly the case for Monte Carlo methods
-* The results can be analysed with the same statistical tools as we would use analysing experimental data.
-* As in all experiments, we are looking for expectation values and an estimate of how accurate they are, i.e., possible sources for errors.
-
-
-!eblock
-
-!split
-===== Statistical analysis =====
-!bblock
-
-* As in other experiments, many numerical experiments have two classes of errors:
- * Statistical errors
- * Systematical errors
-* Statistical errors can be estimated using standard tools from statistics
-* Systematical errors are method specific and must be treated differently from case to case.
-!eblock
-
-
-
-
-
-!split
-===== Resampling methods =====
-
-With all these analytical equations for both the OLS and Ridge
-regression, we will now outline how to assess a given model. This will
-lead us to a discussion of the so-called bias-variance tradeoff (see
-below) and so-called resampling methods.
-
-One of the quantities we have discussed as a way to measure errors is
-the mean-squared error (MSE), mainly used for fitting of continuous
-functions. Another choice is the absolute error.
-
-In the discussions below we will focus on the MSE and in particular since we will split the data into test and training data,
-we discuss the
-o prediction error or simply the _test error_ $\mathrm{Err_{Test}}$, where we have a fixed training set and the test error is the MSE arising from the data reserved for testing. We discuss also the
-o training error $\mathrm{Err_{Train}}$, which is the average loss over the training data.
-
-As our model becomes more and more complex, more of the training data tends to used. The training may thence adapt to more complicated structures in the data. This may lead to a decrease in the bias (see below for code example) and a slight increase of the variance for the test error.
-For a certain level of complexity the test error will reach minimum, before starting to increase again. The
-training error reaches a saturation.
-
-
-
-
-!split
-===== Resampling methods: Jackknife and Bootstrap =====
-
-Two famous
-resampling methods are the _independent bootstrap_ and _the jackknife_.
-
-The jackknife is a special case of the independent bootstrap. Still, the jackknife was made
-popular prior to the independent bootstrap. And as the popularity of
-the independent bootstrap soared, new variants, such as _the dependent bootstrap_.
-
-The Jackknife and independent bootstrap work for
-independent, identically distributed random variables.
-If these conditions are not
-satisfied, the methods will fail. Yet, it should be said that if the data are
-independent, identically distributed, and we only want to estimate the
-variance of $\overline{X}$ (which often is the case), then there is no
-need for bootstrapping.
-
-!split
-===== Resampling methods: Jackknife =====
-
-The Jackknife works by making many replicas of the estimator $\widehat{\theta}$.
-The jackknife is a resampling method where we systematically leave out one observation from the vector of observed values $\bm{x} = (x_1,x_2,\cdots,X_n)$.
-Let $\bm{x}_i$ denote the vector
-!bt
-\[
-\bm{x}_i = (x_1,x_2,\cdots,x_{i-1},x_{i+1},\cdots,x_n),
-\]
-!et
-
-which equals the vector $\bm{x}$ with the exception that observation
-number $i$ is left out. Using this notation, define
-$\widehat{\theta}_i$ to be the estimator
-$\widehat{\theta}$ computed using $\vec{X}_i$.
-
-
-!split
-===== Jackknife code example =====
-!bc pycod
-from numpy import *
-from numpy.random import randint, randn
-from time import time
-
-def jackknife(data, stat):
- n = len(data);t = zeros(n); inds = arange(n); t0 = time()
- ## 'jackknifing' by leaving out an observation for each i
- for i in range(n):
- t[i] = stat(delete(data,i) )
-
- # analysis
- print("Runtime: %g sec" % (time()-t0)); print("Jackknife Statistics :")
- print("original bias std. error")
- print("%8g %14g %15g" % (stat(data),(n-1)*mean(t)/n, (n*var(t))**.5))
-
- return t
-
-
-# Returns mean of data samples
-def stat(data):
- return mean(data)
-
-
-mu, sigma = 100, 15
-datapoints = 10000
-x = mu + sigma*random.randn(datapoints)
-# jackknife returns the data sample
-t = jackknife(x, stat)
-
-!ec
-
-
-!split
-===== Resampling methods: Bootstrap =====
-!bblock
-Bootstrapping is a nonparametric approach to statistical inference
-that substitutes computation for more traditional distributional
-assumptions and asymptotic results. Bootstrapping offers a number of
-advantages:
-o The bootstrap is quite general, although there are some cases in which it fails.
-o Because it does not require distributional assumptions (such as normally distributed errors), the bootstrap can provide more accurate inferences when the data are not well behaved or when the sample size is small.
-o It is possible to apply the bootstrap to statistics with sampling distributions that are difficult to derive, even asymptotically.
-o It is relatively simple to apply the bootstrap to complex data-collection plans (such as stratified and clustered samples).
-!eblock
-
-
-!split
-===== Resampling methods: Bootstrap background =====
-
-Since $\widehat{\theta} = \widehat{\theta}(\bm{X})$ is a function of random variables,
-$\widehat{\theta}$ itself must be a random variable. Thus it has
-a pdf, call this function $p(\bm{t})$. The aim of the bootstrap is to
-estimate $p(\bm{t})$ by the relative frequency of
-$\widehat{\theta}$. You can think of this as using a histogram
-in the place of $p(\bm{t})$. If the relative frequency closely
-resembles $p(\vec{t})$, then using numerics, it is straight forward to
-estimate all the interesting parameters of $p(\bm{t})$ using point
-estimators.
-
-
-!split
-===== Resampling methods: More Bootstrap background =====
-
-In the case that $\widehat{\theta}$ has
-more than one component, and the components are independent, we use the
-same estimator on each component separately. If the probability
-density function of $X_i$, $p(x)$, had been known, then it would have
-been straight forward to do this by:
-o Drawing lots of numbers from $p(x)$, suppose we call one such set of numbers $(X_1^*, X_2^*, \cdots, X_n^*)$.
-o Then using these numbers, we could compute a replica of $\widehat{\theta}$ called $\widehat{\theta}^*$.
-
-By repeated use of (1) and (2), many
-estimates of $\widehat{\theta}$ could have been obtained. The
-idea is to use the relative frequency of $\widehat{\theta}^*$
-(think of a histogram) as an estimate of $p(\bm{t})$.
-
-!split
-===== Resampling methods: Bootstrap approach =====
-
-But
-unless there is enough information available about the process that
-generated $X_1,X_2,\cdots,X_n$, $p(x)$ is in general
-unknown. Therefore, "Efron in 1979":"https://projecteuclid.org/euclid.aos/1176344552" asked the
-question: What if we replace $p(x)$ by the relative frequency
-of the observation $X_i$; if we draw observations in accordance with
-the relative frequency of the observations, will we obtain the same
-result in some asymptotic sense? The answer is yes.
-
-
-Instead of generating the histogram for the relative
-frequency of the observation $X_i$, just draw the values
-$(X_1^*,X_2^*,\cdots,X_n^*)$ with replacement from the vector
-$\bm{X}$.
-
-!split
-===== Resampling methods: Bootstrap steps =====
-
-The independent bootstrap works like this:
-
-o Draw with replacement $n$ numbers for the observed variables $\bm{x} = (x_1,x_2,\cdots,x_n)$.
-o Define a vector $\bm{x}^*$ containing the values which were drawn from $\bm{x}$.
-o Using the vector $\bm{x}^*$ compute $\widehat{\theta}^*$ by evaluating $\widehat \theta$ under the observations $\bm{x}^*$.
-o Repeat this process $k$ times.
-
-When you are done, you can draw a histogram of the relative frequency
-of $\widehat \theta^*$. This is your estimate of the probability
-distribution $p(t)$. Using this probability distribution you can
-estimate any statistics thereof. In principle you never draw the
-histogram of the relative frequency of $\widehat{\theta}^*$. Instead
-you use the estimators corresponding to the statistic of interest. For
-example, if you are interested in estimating the variance of $\widehat
-\theta$, apply the etsimator $\widehat \sigma^2$ to the values
-$\widehat \theta ^*$.
-
-
-!split
-===== Code example for the Bootstrap method =====
-
-The following code starts with a Gaussian distribution with mean value
-$\mu =100$ and variance $\sigma=15$. We use this to generate the data
-used in the bootstrap analysis. The bootstrap analysis returns a data
-set after a given number of bootstrap operations (as many as we have
-data points). This data set consists of estimated mean values for each
-bootstrap operation. The histogram generated by the bootstrap method
-shows that the distribution for these mean values is also a Gaussian,
-centered around the mean value $\mu=100$ but with standard deviation
-$\sigma/\sqrt{n}$, where $n$ is the number of bootstrap samples (in
-this case the same as the number of original data points). The value
-of the standard deviation is what we expect from the central limit
-theorem.
-
-
-!bc pycod
-from numpy import *
-from numpy.random import randint, randn
-from time import time
-import matplotlib.mlab as mlab
-import matplotlib.pyplot as plt
-
-# Returns mean of bootstrap samples
-def stat(data):
- return mean(data)
-
-# Bootstrap algorithm
-def bootstrap(data, statistic, R):
- t = zeros(R); n = len(data); inds = arange(n); t0 = time()
- # non-parametric bootstrap
- for i in range(R):
- t[i] = statistic(data[randint(0,n,n)])
-
- # analysis
- print("Runtime: %g sec" % (time()-t0)); print("Bootstrap Statistics :")
- print("original bias std. error")
- print("%8g %8g %14g %15g" % (statistic(data), std(data),mean(t),std(t)))
- return t
-
-
-mu, sigma = 100, 15
-datapoints = 10000
-x = mu + sigma*random.randn(datapoints)
-# bootstrap returns the data sample
-t = bootstrap(x, stat, datapoints)
-# the histogram of the bootstrapped data
-n, binsboot, patches = plt.hist(t, 50, normed=1, facecolor='red', alpha=0.75)
-
-# add a 'best fit' line
-y = mlab.normpdf( binsboot, mean(t), std(t))
-lt = plt.plot(binsboot, y, 'r--', linewidth=1)
-plt.xlabel('Smarts')
-plt.ylabel('Probability')
-plt.axis([99.5, 100.6, 0, 3.0])
-plt.grid(True)
-
-plt.show()
-
-!ec
-
-
-!split
-===== Various steps in cross-validation =====
-
-When the repetitive splitting of the data set is done randomly,
-samples may accidently end up in a fast majority of the splits in
-either training or test set. Such samples may have an unbalanced
-influence on either model building or prediction evaluation. To avoid
-this $k$-fold cross-validation structures the data splitting. The
-samples are divided into $k$ more or less equally sized exhaustive and
-mutually exclusive subsets. In turn (at each split) one of these
-subsets plays the role of the test set while the union of the
-remaining subsets constitutes the training set. Such a splitting
-warrants a balanced representation of each sample in both training and
-test set over the splits. Still the division into the $k$ subsets
-involves a degree of randomness. This may be fully excluded when
-choosing $k=n$. This particular case is referred to as leave-one-out
-cross-validation (LOOCV).
-
-!split
-===== How to set up the cross-validation for Ridge and/or Lasso =====
-
-* Define a range of interest for the penalty parameter.
-
-* Divide the data set into training and test set comprising samples $\{1, \ldots, n\} \setminus i$ and $\{ i \}$, respectively.
-
-* Fit the linear regression model by means of ridge estimation for each $\lambda$ in the grid using the training set, and the corresponding estimate of the error variance $\bm{\sigma}_{-i}^2(\lambda)$, as
-!bt
-\begin{align*}
-\bm{\beta}_{-i}(\lambda) & = ( \bm{X}_{-i, \ast}^{T}
-\bm{X}_{-i, \ast} + \lambda \bm{I}_{pp})^{-1}
-\bm{X}_{-i, \ast}^{T} \bm{y}_{-i}
-\end{align*}
-!et
-
-* Evaluate the prediction performance of these models on the test set by $\log\{L[y_i, \bm{X}_{i, \ast}; \bm{\beta}_{-i}(\lambda), \bm{\sigma}_{-i}^2(\lambda)]\}$. Or, by the prediction error $|y_i - \bm{X}_{i, \ast} \bm{\beta}_{-i}(\lambda)|$, the relative error, the error squared or the R2 score function.
-
-* Repeat the first three steps such that each sample plays the role of the test set once.
-
-* Average the prediction performances of the test sets at each grid point of the penalty bias/parameter. It is an estimate of the prediction performance of the model corresponding to this value of the penalty parameter on novel data. It is defined as
-!bt
-\begin{align*}
-\frac{1}{n} \sum_{i = 1}^n \log\{L[y_i, \mathbf{X}_{i, \ast}; \bm{\beta}_{-i}(\lambda), \bm{\sigma}_{-i}^2(\lambda)]\}.
-\end{align*}
-!et
-
-!split
-===== Cross-validation in brief =====
-
-For the various values of $k$
-
-o shuffle the dataset randomly.
-o Split the dataset into $k$ groups.
-o For each unique group:
- o Decide which group to use as set for test data
- o Take the remaining groups as a training data set
- o Fit a model on the training set and evaluate it on the test set
- o Retain the evaluation score and discard the model
-o Summarize the model using the sample of model evaluation scores
-
-
-
-!split
-===== Code Example for Cross-validation and $k$-fold Cross-validation =====
-
-The code here uses Ridge regression with cross-validation (CV) resampling and $k$-fold CV in order to fit a specific polynomial.
-!bc pycod
-import numpy as np
-import matplotlib.pyplot as plt
-from sklearn.model_selection import KFold
-from sklearn.linear_model import Ridge
-from sklearn.model_selection import cross_val_score
-from sklearn.preprocessing import PolynomialFeatures
-
-# A seed just to ensure that the random numbers are the same for every run.
-# Useful for eventual debugging.
-np.random.seed(3155)
-
-# Generate the data.
-nsamples = 100
-x = np.random.randn(nsamples)
-y = 3*x**2 + np.random.randn(nsamples)
-
-## Cross-validation on Ridge regression using KFold only
-
-# Decide degree on polynomial to fit
-poly = PolynomialFeatures(degree = 6)
-
-# Decide which values of lambda to use
-nlambdas = 500
-lambdas = np.logspace(-3, 5, nlambdas)
-
-# Initialize a KFold instance
-k = 5
-kfold = KFold(n_splits = k)
-
-# Perform the cross-validation to estimate MSE
-scores_KFold = np.zeros((nlambdas, k))
-
-i = 0
-for lmb in lambdas:
- ridge = Ridge(alpha = lmb)
- j = 0
- for train_inds, test_inds in kfold.split(x):
- xtrain = x[train_inds]
- ytrain = y[train_inds]
-
- xtest = x[test_inds]
- ytest = y[test_inds]
-
- Xtrain = poly.fit_transform(xtrain[:, np.newaxis])
- ridge.fit(Xtrain, ytrain[:, np.newaxis])
-
- Xtest = poly.fit_transform(xtest[:, np.newaxis])
- ypred = ridge.predict(Xtest)
-
- scores_KFold[i,j] = np.sum((ypred - ytest[:, np.newaxis])**2)/np.size(ypred)
-
- j += 1
- i += 1
-
-
-estimated_mse_KFold = np.mean(scores_KFold, axis = 1)
-
-## Cross-validation using cross_val_score from sklearn along with KFold
-
-# kfold is an instance initialized above as:
-# kfold = KFold(n_splits = k)
-
-estimated_mse_sklearn = np.zeros(nlambdas)
-i = 0
-for lmb in lambdas:
- ridge = Ridge(alpha = lmb)
-
- X = poly.fit_transform(x[:, np.newaxis])
- estimated_mse_folds = cross_val_score(ridge, X, y[:, np.newaxis], scoring='neg_mean_squared_error', cv=kfold)
-
- # cross_val_score return an array containing the estimated negative mse for every fold.
- # we have to the the mean of every array in order to get an estimate of the mse of the model
- estimated_mse_sklearn[i] = np.mean(-estimated_mse_folds)
-
- i += 1
-
-## Plot and compare the slightly different ways to perform cross-validation
-
-plt.figure()
-
-plt.plot(np.log10(lambdas), estimated_mse_sklearn, label = 'cross_val_score')
-plt.plot(np.log10(lambdas), estimated_mse_KFold, 'r--', label = 'KFold')
-
-plt.xlabel('log10(lambda)')
-plt.ylabel('mse')
-
-plt.legend()
-
-plt.show()
-
-!ec
-
-
-!split
-===== The bias-variance tradeoff =====
-
-
-We will discuss the bias-variance tradeoff in the context of
-continuous predictions such as regression. However, many of the
-intuitions and ideas discussed here also carry over to classification
-tasks. Consider a dataset $\mathcal{L}$ consisting of the data
-$\mathbf{X}_\mathcal{L}=\{(y_j, \boldsymbol{x}_j), j=0\ldots n-1\}$.
-
-Let us assume that the true data is generated from a noisy model
-
-!bt
-\[
-\bm{y}=f(\boldsymbol{x}) + \bm{\epsilon}
-\]
-!et
-
-where $\epsilon$ is normally distributed with mean zero and standard deviation $\sigma^2$.
-
-In our derivation of the ordinary least squares method we defined then
-an approximation to the function $f$ in terms of the parameters
-$\bm{\beta}$ and the design matrix $\bm{X}$ which embody our model,
-that is $\bm{\tilde{y}}=\bm{X}\bm{\beta}$.
-
-Thereafter we found the parameters $\bm{\beta}$ by optimizing the means squared error via the so-called cost function
-!bt
-\[
-C(\bm{X},\bm{\beta}) =\frac{1}{n}\sum_{i=0}^{n-1}(y_i-\tilde{y}_i)^2=\mathbb{E}\left[(\bm{y}-\bm{\tilde{y}})^2\right].
-\]
-!et
-
-We can rewrite this as
-!bt
-\[
-\mathbb{E}\left[(\bm{y}-\bm{\tilde{y}})^2\right]=\frac{1}{n}\sum_i(f_i-\mathbb{E}\left[\bm{\tilde{y}}\right])^2+\frac{1}{n}\sum_i(\tilde{y}_i-\mathbb{E}\left[\bm{\tilde{y}}\right])^2+\sigma^2.
-\]
-!et
-
-The three terms represent the square of the bias of the learning
-method, which can be thought of as the error caused by the simplifying
-assumptions built into the method. The second term represents the
-variance of the chosen model and finally the last terms is variance of
-the error $\bm{\epsilon}$.
-
-To derive this equation, we need to recall that the variance of $\bm{y}$ and $\bm{\epsilon}$ are both equal to $\sigma^2$. The mean value of $\bm{\epsilon}$ is by definition equal to zero. Furthermore, the function $f$ is not a stochastics variable, idem for $\bm{\tilde{y}}$.
-We use a more compact notation in terms of the expectation value
-!bt
-\[
-\mathbb{E}\left[(\bm{y}-\bm{\tilde{y}})^2\right]=\mathbb{E}\left[(\bm{f}+\bm{\epsilon}-\bm{\tilde{y}})^2\right],
-\]
-!et
-and adding and subtracting $\mathbb{E}\left[\bm{\tilde{y}}\right]$ we get
-!bt
-\[
-\mathbb{E}\left[(\bm{y}-\bm{\tilde{y}})^2\right]=\mathbb{E}\left[(\bm{f}+\bm{\epsilon}-\bm{\tilde{y}}+\mathbb{E}\left[\bm{\tilde{y}}\right]-\mathbb{E}\left[\bm{\tilde{y}}\right])^2\right],
-\]
-!et
-which, using the abovementioned expectation values can be rewritten as
-!bt
-\[
-\mathbb{E}\left[(\bm{y}-\bm{\tilde{y}})^2\right]=\mathbb{E}\left[(\bm{y}-\mathbb{E}\left[\bm{\tilde{y}}\right])^2\right]+\mathrm{Var}\left[\bm{\tilde{y}}\right]+\sigma^2,
-\]
-!et
-that is the rewriting in terms of the so-called bias, the variance of the model $\bm{\tilde{y}}$ and the variance of $\bm{\epsilon}$.
-
-
-
-
-
-!split
-===== Example code for Bias-Variance tradeoff =====
-!bc pycod
-import matplotlib.pyplot as plt
-import numpy as np
-from sklearn.linear_model import LinearRegression, Ridge, Lasso
-from sklearn.preprocessing import PolynomialFeatures
-from sklearn.model_selection import train_test_split
-from sklearn.pipeline import make_pipeline
-from sklearn.utils import resample
-
-np.random.seed(2018)
-
-n = 500
-n_boostraps = 100
-degree = 18 # A quite high value, just to show.
-noise = 0.1
-
-# Make data set.
-x = np.linspace(-1, 3, n).reshape(-1, 1)
-y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2) + np.random.normal(0, 0.1, x.shape)
-
-# Hold out some test data that is never used in training.
-x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
-
-# Combine x transformation and model into one operation.
-# Not neccesary, but convenient.
-model = make_pipeline(PolynomialFeatures(degree=degree), LinearRegression(fit_intercept=False))
-
-# The following (m x n_bootstraps) matrix holds the column vectors y_pred
-# for each bootstrap iteration.
-y_pred = np.empty((y_test.shape[0], n_boostraps))
-for i in range(n_boostraps):
- x_, y_ = resample(x_train, y_train)
-
- # Evaluate the new model on the same test data each time.
- y_pred[:, i] = model.fit(x_, y_).predict(x_test).ravel()
-
-# Note: Expectations and variances taken w.r.t. different training
-# data sets, hence the axis=1. Subsequent means are taken across the test data
-# set in order to obtain a total value, but before this we have error/bias/variance
-# calculated per data point in the test set.
-# Note 2: The use of keepdims=True is important in the calculation of bias as this
-# maintains the column vector form. Dropping this yields very unexpected results.
-error = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) )
-bias = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 )
-variance = np.mean( np.var(y_pred, axis=1, keepdims=True) )
-print('Error:', error)
-print('Bias^2:', bias)
-print('Var:', variance)
-print('{} >= {} + {} = {}'.format(error, bias, variance, bias+variance))
-
-plt.plot(x[::5, :], y[::5, :], label='f(x)')
-plt.scatter(x_test, y_test, label='Data points')
-plt.scatter(x_test, np.mean(y_pred, axis=1), label='Pred')
-plt.legend()
-plt.show()
-
-!ec
-
-
-!split
-===== Understanding what happens =====
-!bc pycod
-import matplotlib.pyplot as plt
-import numpy as np
-from sklearn.linear_model import LinearRegression, Ridge, Lasso
-from sklearn.preprocessing import PolynomialFeatures
-from sklearn.model_selection import train_test_split
-from sklearn.pipeline import make_pipeline
-from sklearn.utils import resample
-
-np.random.seed(2018)
-
-n = 40
-n_boostraps = 100
-maxdegree = 14
-
-
-# Make data set.
-x = np.linspace(-3, 3, n).reshape(-1, 1)
-y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape)
-error = np.zeros(maxdegree)
-bias = np.zeros(maxdegree)
-variance = np.zeros(maxdegree)
-polydegree = np.zeros(maxdegree)
-x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
-
-for degree in range(maxdegree):
- model = make_pipeline(PolynomialFeatures(degree=degree), LinearRegression(fit_intercept=False))
- y_pred = np.empty((y_test.shape[0], n_boostraps))
- for i in range(n_boostraps):
- x_, y_ = resample(x_train, y_train)
- y_pred[:, i] = model.fit(x_, y_).predict(x_test).ravel()
-
- polydegree[degree] = degree
- error[degree] = np.mean( np.mean((y_test - y_pred)**2, axis=1, keepdims=True) )
- bias[degree] = np.mean( (y_test - np.mean(y_pred, axis=1, keepdims=True))**2 )
- variance[degree] = np.mean( np.var(y_pred, axis=1, keepdims=True) )
- print('Polynomial degree:', degree)
- print('Error:', error[degree])
- print('Bias^2:', bias[degree])
- print('Var:', variance[degree])
- print('{} >= {} + {} = {}'.format(error[degree], bias[degree], variance[degree], bias[degree]+variance[degree]))
-
-plt.plot(polydegree, error, label='Error')
-plt.plot(polydegree, bias, label='bias')
-plt.plot(polydegree, variance, label='Variance')
-plt.legend()
-plt.show()
-
-
-
-
-!ec
-
-!split
-===== Summing up =====
-
-
-
-
-The bias-variance tradeoff summarizes the fundamental tension in
-machine learning, particularly supervised learning, between the
-complexity of a model and the amount of training data needed to train
-it. Since data is often limited, in practice it is often useful to
-use a less-complex model with higher bias, that is a model whose asymptotic
-performance is worse than another model because it is easier to
-train and less sensitive to sampling noise arising from having a
-finite-sized training dataset (smaller variance).
-
-
-
-The above equations tell us that in
-order to minimize the expected test error, we need to select a
-statistical learning method that simultaneously achieves low variance
-and low bias. Note that variance is inherently a nonnegative quantity,
-and squared bias is also nonnegative. Hence, we see that the expected
-test MSE can never lie below $Var(\epsilon)$, the irreducible error.
-
-
-What do we mean by the variance and bias of a statistical learning
-method? The variance refers to the amount by which our model would change if we
-estimated it using a different training data set. Since the training
-data are used to fit the statistical learning method, different
-training data sets will result in a different estimate. But ideally the
-estimate for our model should not vary too much between training
-sets. However, if a method has high variance then small changes in
-the training data can result in large changes in the model. In general, more
-flexible statistical methods have higher variance.
-
-
-You may also find this recent "article":"https://www.pnas.org/content/116/32/15849" of interest.
-
-!split
-===== Another Example from Scikit-Learn's Repository =====
-!bc pycod
-"""
-============================
-Underfitting vs. Overfitting
-============================
-
-This example demonstrates the problems of underfitting and overfitting and
-how we can use linear regression with polynomial features to approximate
-nonlinear functions. The plot shows the function that we want to approximate,
-which is a part of the cosine function. In addition, the samples from the
-real function and the approximations of different models are displayed. The
-models have polynomial features of different degrees. We can see that a
-linear function (polynomial with degree 1) is not sufficient to fit the
-training samples. This is called **underfitting**. A polynomial of degree 4
-approximates the true function almost perfectly. However, for higher degrees
-the model will **overfit** the training data, i.e. it learns the noise of the
-training data.
-We evaluate quantitatively **overfitting** / **underfitting** by using
-cross-validation. We calculate the mean squared error (MSE) on the validation
-set, the higher, the less likely the model generalizes correctly from the
-training data.
-"""
-
-print(__doc__)
-
-import numpy as np
-import matplotlib.pyplot as plt
-from sklearn.pipeline import Pipeline
-from sklearn.preprocessing import PolynomialFeatures
-from sklearn.linear_model import LinearRegression
-from sklearn.model_selection import cross_val_score
-
-
-def true_fun(X):
- return np.cos(1.5 * np.pi * X)
-
-np.random.seed(0)
-
-n_samples = 30
-degrees = [1, 4, 15]
-
-X = np.sort(np.random.rand(n_samples))
-y = true_fun(X) + np.random.randn(n_samples) * 0.1
-
-plt.figure(figsize=(14, 5))
-for i in range(len(degrees)):
- ax = plt.subplot(1, len(degrees), i + 1)
- plt.setp(ax, xticks=(), yticks=())
-
- polynomial_features = PolynomialFeatures(degree=degrees[i],
- include_bias=False)
- linear_regression = LinearRegression()
- pipeline = Pipeline([("polynomial_features", polynomial_features),
- ("linear_regression", linear_regression)])
- pipeline.fit(X[:, np.newaxis], y)
-
- # Evaluate the models using crossvalidation
- scores = cross_val_score(pipeline, X[:, np.newaxis], y,
- scoring="neg_mean_squared_error", cv=10)
-
- X_test = np.linspace(0, 1, 100)
- plt.plot(X_test, pipeline.predict(X_test[:, np.newaxis]), label="Model")
- plt.plot(X_test, true_fun(X_test), label="True function")
- plt.scatter(X, y, edgecolor='b', s=20, label="Samples")
- plt.xlabel("x")
- plt.ylabel("y")
- plt.xlim((0, 1))
- plt.ylim((-2, 2))
- plt.legend(loc="best")
- plt.title("Degree {}\nMSE = {:.2e}(+/- {:.2e})".format(
- degrees[i], -scores.mean(), scores.std()))
-plt.show()
-!ec
-
-
-!split
-===== More examples on bootstrap and cross-validation and errors =====
-
-!bc pycod
-# Common imports
-import os
-import numpy as np
-import pandas as pd
-import matplotlib.pyplot as plt
-from sklearn.linear_model import LinearRegression, Ridge, Lasso
-from sklearn.model_selection import train_test_split
-from sklearn.utils import resample
-from sklearn.metrics import mean_squared_error
-# Where to save the figures and data files
-PROJECT_ROOT_DIR = "Results"
-FIGURE_ID = "Results/FigureFiles"
-DATA_ID = "DataFiles/"
-
-if not os.path.exists(PROJECT_ROOT_DIR):
- os.mkdir(PROJECT_ROOT_DIR)
-
-if not os.path.exists(FIGURE_ID):
- os.makedirs(FIGURE_ID)
-
-if not os.path.exists(DATA_ID):
- os.makedirs(DATA_ID)
-
-def image_path(fig_id):
- return os.path.join(FIGURE_ID, fig_id)
-
-def data_path(dat_id):
- return os.path.join(DATA_ID, dat_id)
-
-def save_fig(fig_id):
- plt.savefig(image_path(fig_id) + ".png", format='png')
-
-infile = open(data_path("EoS.csv"),'r')
-
-# Read the EoS data as csv file and organize the data into two arrays with density and energies
-EoS = pd.read_csv(infile, names=('Density', 'Energy'))
-EoS['Energy'] = pd.to_numeric(EoS['Energy'], errors='coerce')
-EoS = EoS.dropna()
-Energies = EoS['Energy']
-Density = EoS['Density']
-# The design matrix now as function of various polytrops
-
-Maxpolydegree = 30
-X = np.zeros((len(Density),Maxpolydegree))
-X[:,0] = 1.0
-testerror = np.zeros(Maxpolydegree)
-trainingerror = np.zeros(Maxpolydegree)
-polynomial = np.zeros(Maxpolydegree)
-
-trials = 100
-for polydegree in range(1, Maxpolydegree):
- polynomial[polydegree] = polydegree
- for degree in range(polydegree):
- X[:,degree] = Density**(degree/3.0)
-
-# loop over trials in order to estimate the expectation value of the MSE
- testerror[polydegree] = 0.0
- trainingerror[polydegree] = 0.0
- for samples in range(trials):
- x_train, x_test, y_train, y_test = train_test_split(X, Energies, test_size=0.2)
- model = LinearRegression(fit_intercept=True).fit(x_train, y_train)
- ypred = model.predict(x_train)
- ytilde = model.predict(x_test)
- testerror[polydegree] += mean_squared_error(y_test, ytilde)
- trainingerror[polydegree] += mean_squared_error(y_train, ypred)
-
- testerror[polydegree] /= trials
- trainingerror[polydegree] /= trials
- print("Degree of polynomial: %3d"% polynomial[polydegree])
- print("Mean squared error on training data: %.8f" % trainingerror[polydegree])
- print("Mean squared error on test data: %.8f" % testerror[polydegree])
-
-plt.plot(polynomial, np.log10(trainingerror), label='Training Error')
-plt.plot(polynomial, np.log10(testerror), label='Test Error')
-plt.xlabel('Polynomial degree')
-plt.ylabel('log10[MSE]')
-plt.legend()
-plt.show()
-
-!ec
-
-
-!split
-===== The same example but now with cross-validation =====
-
-!bc pycod
-# Common imports
-import os
-import numpy as np
-import pandas as pd
-import matplotlib.pyplot as plt
-from sklearn.linear_model import LinearRegression, Ridge, Lasso
-from sklearn.metrics import mean_squared_error
-from sklearn.model_selection import KFold
-from sklearn.model_selection import cross_val_score
-
-
-# Where to save the figures and data files
-PROJECT_ROOT_DIR = "Results"
-FIGURE_ID = "Results/FigureFiles"
-DATA_ID = "DataFiles/"
-
-if not os.path.exists(PROJECT_ROOT_DIR):
- os.mkdir(PROJECT_ROOT_DIR)
-
-if not os.path.exists(FIGURE_ID):
- os.makedirs(FIGURE_ID)
-
-if not os.path.exists(DATA_ID):
- os.makedirs(DATA_ID)
-
-def image_path(fig_id):
- return os.path.join(FIGURE_ID, fig_id)
-
-def data_path(dat_id):
- return os.path.join(DATA_ID, dat_id)
-
-def save_fig(fig_id):
- plt.savefig(image_path(fig_id) + ".png", format='png')
-
-infile = open(data_path("EoS.csv"),'r')
-
-# Read the EoS data as csv file and organize the data into two arrays with density and energies
-EoS = pd.read_csv(infile, names=('Density', 'Energy'))
-EoS['Energy'] = pd.to_numeric(EoS['Energy'], errors='coerce')
-EoS = EoS.dropna()
-Energies = EoS['Energy']
-Density = EoS['Density']
-# The design matrix now as function of various polytrops
-
-Maxpolydegree = 30
-X = np.zeros((len(Density),Maxpolydegree))
-X[:,0] = 1.0
-estimated_mse_sklearn = np.zeros(Maxpolydegree)
-polynomial = np.zeros(Maxpolydegree)
-k =5
-kfold = KFold(n_splits = k)
-
-for polydegree in range(1, Maxpolydegree):
- polynomial[polydegree] = polydegree
- for degree in range(polydegree):
- X[:,degree] = Density**(degree/3.0)
- OLS = LinearRegression()
-# loop over trials in order to estimate the expectation value of the MSE
- estimated_mse_folds = cross_val_score(OLS, X, Energies, scoring='neg_mean_squared_error', cv=kfold)
-#[:, np.newaxis]
- estimated_mse_sklearn[polydegree] = np.mean(-estimated_mse_folds)
-
-plt.plot(polynomial, np.log10(estimated_mse_sklearn), label='Test Error')
-plt.xlabel('Polynomial degree')
-plt.ylabel('log10[MSE]')
-plt.legend()
-plt.show()
-
-!ec
-
-!split
-===== Cross-validation with Ridge =====
-!bc pycod
-import numpy as np
-import matplotlib.pyplot as plt
-from sklearn.model_selection import KFold
-from sklearn.linear_model import Ridge
-from sklearn.model_selection import cross_val_score
-from sklearn.preprocessing import PolynomialFeatures
-
-# A seed just to ensure that the random numbers are the same for every run.
-np.random.seed(3155)
-# Generate the data.
-n = 100
-x = np.linspace(-3, 3, n).reshape(-1, 1)
-y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2)+ np.random.normal(0, 0.1, x.shape)
-# Decide degree on polynomial to fit
-poly = PolynomialFeatures(degree = 10)
-
-# Decide which values of lambda to use
-nlambdas = 500
-lambdas = np.logspace(-3, 5, nlambdas)
-# Initialize a KFold instance
-k = 5
-kfold = KFold(n_splits = k)
-estimated_mse_sklearn = np.zeros(nlambdas)
-i = 0
-for lmb in lambdas:
- ridge = Ridge(alpha = lmb)
- estimated_mse_folds = cross_val_score(ridge, x, y, scoring='neg_mean_squared_error', cv=kfold)
- estimated_mse_sklearn[i] = np.mean(-estimated_mse_folds)
- i += 1
-plt.figure()
-plt.plot(np.log10(lambdas), estimated_mse_sklearn, label = 'cross_val_score')
-plt.xlabel('log10(lambda)')
-plt.ylabel('MSE')
-plt.legend()
-plt.show()
-
-
-!ec
-
-
-