diff --git a/doc/pub/week37/html/._week37-bs000.html b/doc/pub/week37/html/._week37-bs000.html index f984145ed..2ae1b501d 100644 --- a/doc/pub/week37/html/._week37-bs000.html +++ b/doc/pub/week37/html/._week37-bs000.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -302,7 +297,7 @@ MathJax.Hub.Config({
    [2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University

    -

    Sep 17, 2021

    +

    Sep 28, 2021


    @@ -326,7 +321,7 @@ MathJax.Hub.Config({

  • 9
  • 10
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs001.html b/doc/pub/week37/html/._week37-bs001.html index baea75fea..76fd2118a 100644 --- a/doc/pub/week37/html/._week37-bs001.html +++ b/doc/pub/week37/html/._week37-bs001.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -325,7 +320,7 @@ Recommended Reading:
  • 10
  • 11
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs002.html b/doc/pub/week37/html/._week37-bs002.html index e72847e92..a67359222 100644 --- a/doc/pub/week37/html/._week37-bs002.html +++ b/doc/pub/week37/html/._week37-bs002.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -303,7 +298,7 @@ MathJax.Hub.Config({
  • 11
  • 12
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs003.html b/doc/pub/week37/html/._week37-bs003.html index 4b76ff135..dd442db40 100644 --- a/doc/pub/week37/html/._week37-bs003.html +++ b/doc/pub/week37/html/._week37-bs003.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -323,7 +318,7 @@ $$
  • 12
  • 13
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs004.html b/doc/pub/week37/html/._week37-bs004.html index 92e0cb797..98eeeda72 100644 --- a/doc/pub/week37/html/._week37-bs004.html +++ b/doc/pub/week37/html/._week37-bs004.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -337,7 +332,7 @@ It is a conditional probability (see below) and reads as the likelihood of a dom
  • 13
  • 14
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs005.html b/doc/pub/week37/html/._week37-bs005.html index 696f77f10..c83d6ece9 100644 --- a/doc/pub/week37/html/._week37-bs005.html +++ b/doc/pub/week37/html/._week37-bs005.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -331,7 +326,7 @@ is equivalent to the maximization/minimization of the function itself.
  • 14
  • 15
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs006.html b/doc/pub/week37/html/._week37-bs006.html index fcc4b2ef2..f301bcf3f 100644 --- a/doc/pub/week37/html/._week37-bs006.html +++ b/doc/pub/week37/html/._week37-bs006.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -331,7 +326,7 @@ $$
  • 15
  • 16
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs007.html b/doc/pub/week37/html/._week37-bs007.html index 881f68e30..91555da7f 100644 --- a/doc/pub/week37/html/._week37-bs007.html +++ b/doc/pub/week37/html/._week37-bs007.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -322,7 +317,7 @@ which is Bayes' theorem. It allows us to evaluate the uncertainty in in \( X \)
  • 16
  • 17
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs008.html b/doc/pub/week37/html/._week37-bs008.html index 1091586bf..c2ab313ea 100644 --- a/doc/pub/week37/html/._week37-bs008.html +++ b/doc/pub/week37/html/._week37-bs008.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -318,7 +313,7 @@ The function \( p(X) \) on the right hand side is called the prior while the fun
  • 17
  • 18
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs009.html b/doc/pub/week37/html/._week37-bs009.html index 53cbd3faf..9f1d723ec 100644 --- a/doc/pub/week37/html/._week37-bs009.html +++ b/doc/pub/week37/html/._week37-bs009.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -390,7 +385,7 @@ How can we understand this?
  • 18
  • 19
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs010.html b/doc/pub/week37/html/._week37-bs010.html index 14a7e4182..830e0ee10 100644 --- a/doc/pub/week37/html/._week37-bs010.html +++ b/doc/pub/week37/html/._week37-bs010.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -375,7 +370,7 @@ lambdas = np.19
  • 20
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs011.html b/doc/pub/week37/html/._week37-bs011.html index 30046fcfd..fe3fe6475 100644 --- a/doc/pub/week37/html/._week37-bs011.html +++ b/doc/pub/week37/html/._week37-bs011.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -341,7 +336,7 @@ We have a model for \( p(\boldsymbol{D}\vert\boldsymbol{\beta}) \) but need one
  • 20
  • 21
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs012.html b/doc/pub/week37/html/._week37-bs012.html index b601102c1..e18f4bb7c 100644 --- a/doc/pub/week37/html/._week37-bs012.html +++ b/doc/pub/week37/html/._week37-bs012.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -347,7 +342,7 @@ which is our Ridge cost function! Nice, isn't it?
  • 21
  • 22
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs013.html b/doc/pub/week37/html/._week37-bs013.html index 5dbaa7e5b..d9649b431 100644 --- a/doc/pub/week37/html/._week37-bs013.html +++ b/doc/pub/week37/html/._week37-bs013.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -341,7 +336,7 @@ which is our Lasso cost function!
  • 22
  • 23
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs014.html b/doc/pub/week37/html/._week37-bs014.html index 7188c2993..81a7f522b 100644 --- a/doc/pub/week37/html/._week37-bs014.html +++ b/doc/pub/week37/html/._week37-bs014.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -323,7 +318,7 @@ and discuss how to select a given model (one of the difficult parts in machine l
  • 23
  • 24
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs015.html b/doc/pub/week37/html/._week37-bs015.html index 191af6385..c856e1f4c 100644 --- a/doc/pub/week37/html/._week37-bs015.html +++ b/doc/pub/week37/html/._week37-bs015.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -340,7 +335,7 @@ cross-validation and the bootstrap method.
  • 24
  • 25
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs016.html b/doc/pub/week37/html/._week37-bs016.html index f38127961..3215ffe84 100644 --- a/doc/pub/week37/html/._week37-bs016.html +++ b/doc/pub/week37/html/._week37-bs016.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -336,7 +331,7 @@ bootstrap is widely used.
  • 25
  • 26
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs017.html b/doc/pub/week37/html/._week37-bs017.html index 4132e5b49..83b86d50e 100644 --- a/doc/pub/week37/html/._week37-bs017.html +++ b/doc/pub/week37/html/._week37-bs017.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -323,7 +318,7 @@ MathJax.Hub.Config({
  • 26
  • 27
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs018.html b/doc/pub/week37/html/._week37-bs018.html index bdaf94e8e..04ef0b537 100644 --- a/doc/pub/week37/html/._week37-bs018.html +++ b/doc/pub/week37/html/._week37-bs018.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -329,7 +324,7 @@ MathJax.Hub.Config({
  • 27
  • 28
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs019.html b/doc/pub/week37/html/._week37-bs019.html index 8a320e3fb..945f831c7 100644 --- a/doc/pub/week37/html/._week37-bs019.html +++ b/doc/pub/week37/html/._week37-bs019.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -335,7 +330,7 @@ training error reaches a saturation.
  • 28
  • 29
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs020.html b/doc/pub/week37/html/._week37-bs020.html index 3536f8fe1..78a31af56 100644 --- a/doc/pub/week37/html/._week37-bs020.html +++ b/doc/pub/week37/html/._week37-bs020.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -329,7 +324,7 @@ need for bootstrapping.
  • 29
  • 30
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs021.html b/doc/pub/week37/html/._week37-bs021.html index a066d0e55..7b3282268 100644 --- a/doc/pub/week37/html/._week37-bs021.html +++ b/doc/pub/week37/html/._week37-bs021.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -325,7 +320,7 @@ number \( i \) is left out. Using this notation, define
  • 30
  • 31
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs022.html b/doc/pub/week37/html/._week37-bs022.html index 4cbef0650..d48d82e84 100644 --- a/doc/pub/week37/html/._week37-bs022.html +++ b/doc/pub/week37/html/._week37-bs022.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -342,7 +337,7 @@ t = jackknife(x, stat)
  • 31
  • 32
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs023.html b/doc/pub/week37/html/._week37-bs023.html index eef1a79a9..8ac13685a 100644 --- a/doc/pub/week37/html/._week37-bs023.html +++ b/doc/pub/week37/html/._week37-bs023.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -334,7 +329,7 @@ Before we proceed however, we need to remind ourselves about a central theorem i
  • 32
  • 33
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs024.html b/doc/pub/week37/html/._week37-bs024.html index 05b66397b..34768f990 100644 --- a/doc/pub/week37/html/._week37-bs024.html +++ b/doc/pub/week37/html/._week37-bs024.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -328,7 +323,7 @@ the question we pose is which is the PDF of the new variable \( z \).
  • 33
  • 34
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs025.html b/doc/pub/week37/html/._week37-bs025.html index 997d46288..e3d674725 100644 --- a/doc/pub/week37/html/._week37-bs025.html +++ b/doc/pub/week37/html/._week37-bs025.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -326,7 +321,7 @@ product of individual \( p(x_i) \). The independence assumption is important in
  • 34
  • 35
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs026.html b/doc/pub/week37/html/._week37-bs026.html index 179f172d8..1b4b82de4 100644 --- a/doc/pub/week37/html/._week37-bs026.html +++ b/doc/pub/week37/html/._week37-bs026.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -335,7 +330,7 @@ $$
  • 35
  • 36
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs027.html b/doc/pub/week37/html/._week37-bs027.html index be548ef7f..edebb0273 100644 --- a/doc/pub/week37/html/._week37-bs027.html +++ b/doc/pub/week37/html/._week37-bs027.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -337,7 +332,7 @@ and \( \mu \) is also the mean of the PDF \( p(x) \).
  • 36
  • 37
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs028.html b/doc/pub/week37/html/._week37-bs028.html index 1e4230c5d..1fe887f6d 100644 --- a/doc/pub/week37/html/._week37-bs028.html +++ b/doc/pub/week37/html/._week37-bs028.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -350,7 +345,7 @@ finite \( m \), it is not always possible to find a closed form /analytic expres
  • 37
  • 38
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs029.html b/doc/pub/week37/html/._week37-bs029.html index 6329b76b7..c01e592e3 100644 --- a/doc/pub/week37/html/._week37-bs029.html +++ b/doc/pub/week37/html/._week37-bs029.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -328,7 +323,7 @@ construct a confidence interval for the estimates.
  • 38
  • 39
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs030.html b/doc/pub/week37/html/._week37-bs030.html index 41ca0cf00..543d7684f 100644 --- a/doc/pub/week37/html/._week37-bs030.html +++ b/doc/pub/week37/html/._week37-bs030.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -336,7 +331,7 @@ Bootstrap method, why it works and various theorems related to it.
  • 39
  • 40
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs031.html b/doc/pub/week37/html/._week37-bs031.html index 3216467fa..549612ce1 100644 --- a/doc/pub/week37/html/._week37-bs031.html +++ b/doc/pub/week37/html/._week37-bs031.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -322,7 +317,7 @@ estimators.
  • 40
  • 41
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs032.html b/doc/pub/week37/html/._week37-bs032.html index 07bd0eda2..62de18bf4 100644 --- a/doc/pub/week37/html/._week37-bs032.html +++ b/doc/pub/week37/html/._week37-bs032.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -328,7 +323,7 @@ idea is to use the relative frequency of \( \widehat{\beta}^* \)
  • 41
  • 42
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs033.html b/doc/pub/week37/html/._week37-bs033.html index a5326292c..a395a63ef 100644 --- a/doc/pub/week37/html/._week37-bs033.html +++ b/doc/pub/week37/html/._week37-bs033.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -324,7 +319,7 @@ result in some asymptotic sense? The answer is yes.
  • 42
  • 43
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs034.html b/doc/pub/week37/html/._week37-bs034.html index 075043c3d..e3703e88a 100644 --- a/doc/pub/week37/html/._week37-bs034.html +++ b/doc/pub/week37/html/._week37-bs034.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -331,7 +326,7 @@ example, if you are interested in estimating the variance of \( \widehat
  • 43
  • 44
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs035.html b/doc/pub/week37/html/._week37-bs035.html index e57db43f3..0ee213d9b 100644 --- a/doc/pub/week37/html/._week37-bs035.html +++ b/doc/pub/week37/html/._week37-bs035.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -358,7 +353,7 @@ We see that our new variance and from that the standard deviation, agrees with t
  • 44
  • 45
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs036.html b/doc/pub/week37/html/._week37-bs036.html index 8fd1c6a99..392c85c0e 100644 --- a/doc/pub/week37/html/._week37-bs036.html +++ b/doc/pub/week37/html/._week37-bs036.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -323,7 +318,7 @@ plt.show()
  • 45
  • 46
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs037.html b/doc/pub/week37/html/._week37-bs037.html index 0e7980942..666ee94c7 100644 --- a/doc/pub/week37/html/._week37-bs037.html +++ b/doc/pub/week37/html/._week37-bs037.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -372,7 +367,7 @@ that is the rewriting in terms of the so-called bias, the variance of the model
  • 46
  • 47
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs038.html b/doc/pub/week37/html/._week37-bs038.html index a87e4533e..6797fada1 100644 --- a/doc/pub/week37/html/._week37-bs038.html +++ b/doc/pub/week37/html/._week37-bs038.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -314,7 +309,7 @@ MathJax.Hub.Config({
  • 47
  • 48
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs039.html b/doc/pub/week37/html/._week37-bs039.html index 782349de7..c1caf475b 100644 --- a/doc/pub/week37/html/._week37-bs039.html +++ b/doc/pub/week37/html/._week37-bs039.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -367,8 +362,6 @@ plt.show()
  • 47
  • 48
  • 49
  • -
  • ...
  • -
  • 50
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs040.html b/doc/pub/week37/html/._week37-bs040.html index 362b39622..8dfe88d6e 100644 --- a/doc/pub/week37/html/._week37-bs040.html +++ b/doc/pub/week37/html/._week37-bs040.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -358,7 +353,6 @@ plt.show()
  • 47
  • 48
  • 49
  • -
  • 50
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs041.html b/doc/pub/week37/html/._week37-bs041.html index ddad363ef..037ed693a 100644 --- a/doc/pub/week37/html/._week37-bs041.html +++ b/doc/pub/week37/html/._week37-bs041.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -340,7 +335,6 @@ You may also find this recent 47
  • 48
  • 49
  • -
  • 50
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs042.html b/doc/pub/week37/html/._week37-bs042.html index 75236ad61..62cf0a71f 100644 --- a/doc/pub/week37/html/._week37-bs042.html +++ b/doc/pub/week37/html/._week37-bs042.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -381,7 +376,6 @@ plt.show()
  • 47
  • 48
  • 49
  • -
  • 50
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs043.html b/doc/pub/week37/html/._week37-bs043.html index 95f5ec757..c4d4344aa 100644 --- a/doc/pub/week37/html/._week37-bs043.html +++ b/doc/pub/week37/html/._week37-bs043.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -322,7 +317,6 @@ cross-validation (LOOCV).
  • 47
  • 48
  • 49
  • -
  • 50
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs044.html b/doc/pub/week37/html/._week37-bs044.html index 6a6cb420e..bf3530e9e 100644 --- a/doc/pub/week37/html/._week37-bs044.html +++ b/doc/pub/week37/html/._week37-bs044.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -332,7 +327,6 @@ $$
  • 47
  • 48
  • 49
  • -
  • 50
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs045.html b/doc/pub/week37/html/._week37-bs045.html index 4a74c93a4..6956ce029 100644 --- a/doc/pub/week37/html/._week37-bs045.html +++ b/doc/pub/week37/html/._week37-bs045.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -321,7 +316,6 @@ For the various values of \( k \)
  • 47
  • 48
  • 49
  • -
  • 50
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs046.html b/doc/pub/week37/html/._week37-bs046.html index 291bb90f5..8fcf6d83a 100644 --- a/doc/pub/week37/html/._week37-bs046.html +++ b/doc/pub/week37/html/._week37-bs046.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -398,7 +393,6 @@ plt.show()
  • 47
  • 48
  • 49
  • -
  • 50
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs047.html b/doc/pub/week37/html/._week37-bs047.html index 19bfdd13d..ea91f3364 100644 --- a/doc/pub/week37/html/._week37-bs047.html +++ b/doc/pub/week37/html/._week37-bs047.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -348,7 +343,7 @@ trials = 100= 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) + model = LinearRegression(fit_intercept=False).fit(x_train, y_train) ypred = model.predict(x_train) ytilde = model.predict(x_test) testerror[polydegree] += mean_squared_error(y_test, ytilde) @@ -367,6 +362,9 @@ plt.ylabel(' plt.legend() plt.show() +

    +Note that we kept the intercept column in the fitting here. This means that we need to set the intercept in the call to the Scikit-Learn function as False. Alternatively, we could have set up the design matrix \( X \) without the first column of ones. +

    @@ -384,7 +382,6 @@ plt.show()

  • 47
  • 48
  • 49
  • -
  • 50
  • »
  • diff --git a/doc/pub/week37/html/._week37-bs048.html b/doc/pub/week37/html/._week37-bs048.html index 9c049602b..6c3d97210 100644 --- a/doc/pub/week37/html/._week37-bs048.html +++ b/doc/pub/week37/html/._week37-bs048.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -285,6 +280,8 @@ MathJax.Hub.Config({

    The same example but now with cross-validation

    +

    +In this example we keep the intercept column again but add cross-validation in order to estimate the best possible value of the means squared error.

    @@ -344,7 +341,7 @@ kfold = KFold(n_splits = polydegree for degree in range(polydegree): X[:,degree] = Density**(degree/3.0) - OLS = LinearRegression() + OLS = LinearRegression(fit_intercept=False) # 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] @@ -357,6 +354,7 @@ plt.legend() plt.show()

    +

    diff --git a/doc/pub/week37/html/week37-bs.html b/doc/pub/week37/html/week37-bs.html index f984145ed..2ae1b501d 100644 --- a/doc/pub/week37/html/week37-bs.html +++ b/doc/pub/week37/html/week37-bs.html @@ -177,11 +177,7 @@ Automatically generated HTML file from DocOnce source ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -267,7 +263,6 @@ MathJax.Hub.Config({
  • Code Example for Cross-validation and \( k \)-fold Cross-validation
  • More examples on bootstrap and cross-validation and errors
  • The same example but now with cross-validation
  • -
  • Cross-validation with Ridge
  • @@ -302,7 +297,7 @@ MathJax.Hub.Config({
    [2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University

    -

    Sep 17, 2021

    +

    Sep 28, 2021


    @@ -326,7 +321,7 @@ MathJax.Hub.Config({

  • 9
  • 10
  • ...
  • -
  • 50
  • +
  • 49
  • »
  • diff --git a/doc/pub/week37/html/week37-reveal.html b/doc/pub/week37/html/week37-reveal.html index a3c6c7f6f..a88e39b74 100644 --- a/doc/pub/week37/html/week37-reveal.html +++ b/doc/pub/week37/html/week37-reveal.html @@ -148,7 +148,7 @@ MathJax.Hub.Config({
    [2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University

     
    -

    Sep 17, 2021

    +

    Sep 28, 2021


    @@ -1845,7 +1845,7 @@ trials = 100 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) + model = LinearRegression(fit_intercept=False).fit(x_train, y_train) ypred = model.predict(x_train) ytilde = model.predict(x_test) testerror[polydegree] += mean_squared_error(y_test, ytilde) @@ -1864,12 +1864,16 @@ plt.ylabel('log10[MSE]') plt.legend() plt.show() +

    +Note that we kept the intercept column in the fitting here. This means that we need to set the intercept in the call to the Scikit-Learn function as False. Alternatively, we could have set up the design matrix \( X \) without the first column of ones.

    The same example but now with cross-validation

    +

    +In this example we keep the intercept column again but add cross-validation in order to estimate the best possible value of the means squared error.

    @@ -1929,7 +1933,7 @@ kfold = KFold(n_splits = k) polynomial[polydegree] = polydegree for degree in range(polydegree): X[:,degree] = Density**(degree/3.0) - OLS = LinearRegression() + OLS = LinearRegression(fit_intercept=False) # 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] @@ -1944,50 +1948,6 @@ 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/week37/html/week37-solarized.html b/doc/pub/week37/html/week37-solarized.html index f3ee08b0f..bff53993e 100644 --- a/doc/pub/week37/html/week37-solarized.html +++ b/doc/pub/week37/html/week37-solarized.html @@ -197,11 +197,7 @@ div { text-align: justify; text-justify: inter-word; } ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -243,7 +239,7 @@ MathJax.Hub.Config({
    [2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University

    -

    Sep 17, 2021

    +

    Sep 28, 2021












    @@ -1844,7 +1840,7 @@ trials = 100 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) + model = LinearRegression(fit_intercept=False).fit(x_train, y_train) ypred = model.predict(x_train) ytilde = model.predict(x_test) testerror[polydegree] += mean_squared_error(y_test, ytilde) @@ -1863,11 +1859,16 @@ plt.ylabel('log10[MSE]') plt.legend() plt.show() +

    +Note that we kept the intercept column in the fitting here. This means that we need to set the intercept in the call to the Scikit-Learn function as False. Alternatively, we could have set up the design matrix \( X \) without the first column of ones. +

    The same example but now with cross-validation

    +

    +In this example we keep the intercept column again but add cross-validation in order to estimate the best possible value of the means squared error.

    @@ -1927,7 +1928,7 @@ kfold = KFold(n_splits = k) polynomial[polydegree] = polydegree for degree in range(polydegree): X[:,degree] = Density**(degree/3.0) - OLS = LinearRegression() + OLS = LinearRegression(fit_intercept=False) # 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] @@ -1940,49 +1941,6 @@ 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/week37/html/week37.html b/doc/pub/week37/html/week37.html index cf8db4dde..148d17190 100644 --- a/doc/pub/week37/html/week37.html +++ b/doc/pub/week37/html/week37.html @@ -202,11 +202,7 @@ div { text-align: justify; text-justify: inter-word; } ('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')]} + 'the-same-example-but-now-with-cross-validation')]} end of tocinfo --> @@ -248,7 +244,7 @@ MathJax.Hub.Config({

    [2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University

    -

    Sep 17, 2021

    +

    Sep 28, 2021












    @@ -1849,7 +1845,7 @@ trials = 100= 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) + model = LinearRegression(fit_intercept=False).fit(x_train, y_train) ypred = model.predict(x_train) ytilde = model.predict(x_test) testerror[polydegree] += mean_squared_error(y_test, ytilde) @@ -1868,11 +1864,16 @@ plt.ylabel(' plt.legend() plt.show() +

    +Note that we kept the intercept column in the fitting here. This means that we need to set the intercept in the call to the Scikit-Learn function as False. Alternatively, we could have set up the design matrix \( X \) without the first column of ones. +

    The same example but now with cross-validation

    +

    +In this example we keep the intercept column again but add cross-validation in order to estimate the best possible value of the means squared error.

    @@ -1932,7 +1933,7 @@ kfold = KFold(n_splits = polydegree for degree in range(polydegree): X[:,degree] = Density**(degree/3.0) - OLS = LinearRegression() + OLS = LinearRegression(fit_intercept=False) # 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] @@ -1945,49 +1946,6 @@ 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/week37/ipynb/ipynb-week37-src.tar.gz b/doc/pub/week37/ipynb/ipynb-week37-src.tar.gz index ed785793e..d63efe22f 100644 Binary files a/doc/pub/week37/ipynb/ipynb-week37-src.tar.gz and b/doc/pub/week37/ipynb/ipynb-week37-src.tar.gz differ diff --git a/doc/pub/week37/ipynb/week37.ipynb b/doc/pub/week37/ipynb/week37.ipynb index ab0f83f40..15af1b5f5 100644 --- a/doc/pub/week37/ipynb/week37.ipynb +++ b/doc/pub/week37/ipynb/week37.ipynb @@ -10,7 +10,7 @@ " \n", "**Morten Hjorth-Jensen**, Department of Physics, University of Oslo and Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University\n", "\n", - "Date: **Sep 17, 2021**\n", + "Date: **Sep 28, 2021**\n", "\n", "Copyright 1999-2021, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license\n", "\n", @@ -1984,7 +1984,7 @@ " 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", + " model = LinearRegression(fit_intercept=False).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", @@ -2008,8 +2008,12 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "Note that we kept the intercept column in the fitting here. This means that we need to set the **intercept** in the call to the **Scikit-Learn** function as **False**. Alternatively, we could have set up the design matrix $X$ without the first column of ones.\n", + "\n", "\n", - "## The same example but now with cross-validation" + "## The same example but now with cross-validation\n", + "\n", + "In this example we keep the intercept column again but add cross-validation in order to estimate the best possible value of the means squared error." ] }, { @@ -2077,7 +2081,7 @@ " polynomial[polydegree] = polydegree\n", " for degree in range(polydegree):\n", " X[:,degree] = Density**(degree/3.0)\n", - " OLS = LinearRegression()\n", + " OLS = LinearRegression(fit_intercept=False)\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", @@ -2089,59 +2093,6 @@ "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()" - ] } ], "metadata": {}, diff --git a/doc/src/week37/week37.do.txt b/doc/src/week37/week37.do.txt index 4cf333222..c16dd66b7 100644 --- a/doc/src/week37/week37.do.txt +++ b/doc/src/week37/week37.do.txt @@ -1485,7 +1485,7 @@ for polydegree in range(1, Maxpolydegree): 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) + model = LinearRegression(fit_intercept=False).fit(x_train, y_train) ypred = model.predict(x_train) ytilde = model.predict(x_test) testerror[polydegree] += mean_squared_error(y_test, ytilde) @@ -1506,10 +1506,12 @@ plt.show() !ec +Note that we kept the intercept column in the fitting here. This means that we need to set the _intercept_ in the call to the _Scikit-Learn_ function as _False_. Alternatively, we could have set up the design matrix $X$ without the first column of ones. !split ===== The same example but now with cross-validation ===== +In this example we keep the intercept column again but add cross-validation in order to estimate the best possible value of the means squared error. !bc pycod # Common imports import os @@ -1567,7 +1569,7 @@ for polydegree in range(1, Maxpolydegree): polynomial[polydegree] = polydegree for degree in range(polydegree): X[:,degree] = Density**(degree/3.0) - OLS = LinearRegression() + OLS = LinearRegression(fit_intercept=False) # 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] @@ -1581,52 +1583,3 @@ 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 - - - - - - - - diff --git a/doc/src/week39/test1.py b/doc/src/week39/test1.py new file mode 100644 index 000000000..1a9ead338 --- /dev/null +++ b/doc/src/week39/test1.py @@ -0,0 +1,16 @@ +import numpy as np +from sklearn import datasets +from sklearn.linear_model import Ridge +from sklearn.model_selection import GridSearchCV +# load the diabetes datasets +dataset = datasets.load_diabetes() +# prepare a range of alpha values to test +alphas = np.array([1,0.1,0.01,0.001,0.0001,0]) +# create and fit a ridge regression model, testing each alpha +model = Ridge() +grid = GridSearchCV(estimator=model, param_grid=dict(alpha=alphas)) +grid.fit(dataset.data, dataset.target) +print(grid) +# summarize the results of the grid search +print(grid.best_score_) +print(grid.best_estimator_.alpha) diff --git a/doc/src/week39/test2.py b/doc/src/week39/test2.py new file mode 100644 index 000000000..8a58d4ce8 --- /dev/null +++ b/doc/src/week39/test2.py @@ -0,0 +1,17 @@ +import numpy as np +from scipy.stats import uniform as sp_rand +from sklearn import datasets +from sklearn.linear_model import Ridge +from sklearn.model_selection import RandomizedSearchCV +# load the diabetes datasets +dataset = datasets.load_diabetes() +# prepare a uniform distribution to sample for the alpha parameter +param_grid = {'alpha': sp_rand()} +# create and fit a ridge regression model, testing random alpha values +model = Ridge() +rsearch = RandomizedSearchCV(estimator=model, param_distributions=param_grid, n_iter=100) +rsearch.fit(dataset.data, dataset.target) +print(rsearch) +# summarize the results of the random parameter search +print(rsearch.best_score_) +print(rsearch.best_estimator_.alpha) diff --git a/doc/src/week39/test3.py b/doc/src/week39/test3.py new file mode 100644 index 000000000..dc4d67de8 --- /dev/null +++ b/doc/src/week39/test3.py @@ -0,0 +1,30 @@ +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 +from sklearn.model_selection import GridSearchCV + +# 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 = 10 +lambdas = np.logspace(-3, 3, nlambdas) + +# create and fit a ridge regression model, testing each alpha +model = Ridge() +grid = GridSearchCV(estimator=model, param_grid=dict(alpha=lambdas)) +grid.fit(x, y) +print(grid) +# summarize the results of the grid search +print(grid.best_score_) +print(grid.best_estimator_.alpha) + diff --git a/doc/src/week39/test4.py b/doc/src/week39/test4.py new file mode 100644 index 000000000..82e34dc98 --- /dev/null +++ b/doc/src/week39/test4.py @@ -0,0 +1,35 @@ +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/src/week39/test5.py b/doc/src/week39/test5.py new file mode 100644 index 000000000..430ab655c --- /dev/null +++ b/doc/src/week39/test5.py @@ -0,0 +1,61 @@ +import numpy as np +import pandas as pd +import matplotlib.pyplot as plt +from sklearn.model_selection import train_test_split +from sklearn.linear_model import Ridge +from sklearn.preprocessing import StandardScaler +from sklearn.model_selection import cross_val_score +from sklearn.model_selection import GridSearchCV + + + +def MSE(y_data,y_model): + n = np.size(y_model) + return np.sum((y_data-y_model)**2)/n + +# A seed just to ensure that the random numbers are the same for every run. +# Useful for eventual debugging. +np.random.seed(315) + +n = 100 +x = np.random.rand(n) +y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2) + +Maxpolydegree = 5 +X = np.zeros((n,Maxpolydegree-1)) + +for degree in range(1,Maxpolydegree): #No intercept column + X[:,degree-1] = x**(degree) + +# We split the data in test and training data +X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2) + +#For our own implementation, we will need to deal with the intercept by centering the design matrix and the target variable +X_train_mean = np.mean(X_train,axis=0) +#Center by removing mean from each feature +X_train_scaled = X_train - X_train_mean +X_test_scaled = X_test - X_train_mean +#The model intercept (called y_scaler) is given by the mean of the target variable (IF X is centered) +#Remove the intercept from the training data. +y_scaler = np.mean(y_train) +y_train_scaled = y_train - y_scaler + +p = Maxpolydegree-1 +I = np.eye(p,p) +# Decide which values of lambda to use +nlambdas = 10 +MSEOwnRidgePredict = np.zeros(nlambdas) +MSERidgePredict = np.zeros(nlambdas) + +lambdas = np.logspace(-4, 2, nlambdas) + +# create and fit a ridge regression model, testing each alpha +model = Ridge() +grid = GridSearchCV(estimator=model, param_grid=dict(alpha=lambdas)) +grid.fit(X_train_scaled, y_train_scaled) +print(grid) +ypredictRidge = grid.predict(X_test_scaled) +# summarize the results of the grid search +print(grid.best_score_) +print(grid.best_estimator_.alpha) +print(MSE(y_test,ypredictRidge)) diff --git a/doc/src/week39/test6.py b/doc/src/week39/test6.py new file mode 100644 index 000000000..b5515f583 --- /dev/null +++ b/doc/src/week39/test6.py @@ -0,0 +1,72 @@ +import numpy as np +import pandas as pd +import matplotlib.pyplot as plt +from sklearn.model_selection import train_test_split +from sklearn.linear_model import Ridge +from sklearn.preprocessing import StandardScaler +from sklearn.model_selection import cross_val_score +from sklearn.model_selection import GridSearchCV +from scipy.stats import uniform as sp_rand +from sklearn.model_selection import RandomizedSearchCV + + +def R2(y_data, y_model): + return 1 - np.sum((y_data - y_model) ** 2) / np.sum((y_data - np.mean(y_data)) ** 2) + + +def MSE(y_data,y_model): + n = np.size(y_model) + return np.sum((y_data-y_model)**2)/n + +# A seed just to ensure that the random numbers are the same for every run. +# Useful for eventual debugging. +np.random.seed(315) + +n = 100 +x = np.random.rand(n) +y = np.exp(-x**2) + 1.5 * np.exp(-(x-2)**2) + +Maxpolydegree = 5 +X = np.zeros((n,Maxpolydegree-1)) + +for degree in range(1,Maxpolydegree): #No intercept column + X[:,degree-1] = x**(degree) + +# We split the data in test and training data +X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2) + +#For our own implementation, we will need to deal with the intercept by centering the design matrix and the target variable +X_train_mean = np.mean(X_train,axis=0) +#Center by removing mean from each feature +X_train_scaled = X_train - X_train_mean +X_test_scaled = X_test - X_train_mean +#The model intercept (called y_scaler) is given by the mean of the target variable (IF X is centered) +#Remove the intercept from the training data. +y_scaler = np.mean(y_train) +y_train_scaled = y_train - y_scaler +y_test_scaled = y_test - y_scaler + +p = Maxpolydegree-1 +I = np.eye(p,p) +# Decide which values of lambda to use +nlambdas = 10 +MSEOwnRidgePredict = np.zeros(nlambdas) +MSERidgePredict = np.zeros(nlambdas) + + +param_grid = {'alpha': sp_rand()} +# create and fit a ridge regression model, testing each alpha +model = Ridge() +grid = RandomizedSearchCV(estimator=model, param_distributions=param_grid, n_iter=100) +#GridSearchCV(estimator=model, param_grid=dict(alpha=lambdas)) +grid.fit(X_train_scaled, y_train_scaled) +print(grid) +ypredictRidge = grid.predict(X_test_scaled) +# summarize the results of the grid search +print(grid.best_score_) +print(grid.best_estimator_.alpha) +print(MSE(y_test_scaled,ypredictRidge)) +print(R2(y_test_scaled,ypredictRidge)) + + + diff --git a/doc/src/week39/week39.do.txt b/doc/src/week39/week39.do.txt index 8fc273586..25f3525dc 100644 --- a/doc/src/week39/week39.do.txt +++ b/doc/src/week39/week39.do.txt @@ -31,41 +31,6 @@ in evaluating the MSE as function of different $\lambda$ values. Based on these calculations, one tries then to determine the value of the hyperparameter $\lambda$ which results in optimal scores (for example the smallest MSE or an $R2=1$). !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 We see from this plot that the optimal MSE occurs for a value of $\lambda\in [10,100]$. @@ -80,41 +45,7 @@ included with the library _Scikit-Learn_, as demonstrated for the same example here. !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