diff --git a/doc/pub/Regression/html/._Regression-bs000.html b/doc/pub/Regression/html/._Regression-bs000.html
index 833e9dec8..e6ce300e7 100644
--- a/doc/pub/Regression/html/._Regression-bs000.html
+++ b/doc/pub/Regression/html/._Regression-bs000.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -399,7 +438,7 @@ MathJax.Hub.Config({
[2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University
-
Sep 25, 2018
+Oct 11, 2018
@@ -423,7 +462,7 @@ MathJax.Hub.Config({
9
10
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs001.html b/doc/pub/Regression/html/._Regression-bs001.html
index 294497cd4..3ab77c47d 100644
--- a/doc/pub/Regression/html/._Regression-bs001.html
+++ b/doc/pub/Regression/html/._Regression-bs001.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -420,7 +459,7 @@ A regression model aims at finding a likelihood function \( p(y\vert \hat{x}) \)
10
11
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs002.html b/doc/pub/Regression/html/._Regression-bs002.html
index 7551f6711..1a4bca496 100644
--- a/doc/pub/Regression/html/._Regression-bs002.html
+++ b/doc/pub/Regression/html/._Regression-bs002.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -427,7 +466,7 @@ response is equal to \( \beta_j \).
11
12
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs003.html b/doc/pub/Regression/html/._Regression-bs003.html
index 0dfcdd55f..5b47217af 100644
--- a/doc/pub/Regression/html/._Regression-bs003.html
+++ b/doc/pub/Regression/html/._Regression-bs003.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -418,7 +457,7 @@ where \( \epsilon_i \) is the error in our approximation.
12
13
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs004.html b/doc/pub/Regression/html/._Regression-bs004.html
index 209d2107f..457e18668 100644
--- a/doc/pub/Regression/html/._Regression-bs004.html
+++ b/doc/pub/Regression/html/._Regression-bs004.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -418,7 +457,7 @@ $$
13
14
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs005.html b/doc/pub/Regression/html/._Regression-bs005.html
index 216e627f6..49d58a223 100644
--- a/doc/pub/Regression/html/._Regression-bs005.html
+++ b/doc/pub/Regression/html/._Regression-bs005.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -440,7 +479,7 @@ $$
14
15
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs006.html b/doc/pub/Regression/html/._Regression-bs006.html
index b8ef06a07..7fe5349cf 100644
--- a/doc/pub/Regression/html/._Regression-bs006.html
+++ b/doc/pub/Regression/html/._Regression-bs006.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -423,7 +462,7 @@ $$
15
16
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs007.html b/doc/pub/Regression/html/._Regression-bs007.html
index 1810e660e..5da5464cc 100644
--- a/doc/pub/Regression/html/._Regression-bs007.html
+++ b/doc/pub/Regression/html/._Regression-bs007.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -429,7 +468,7 @@ The left-hand side of this equation forms know. Our error vector \( \hat{\epsilo
16
17
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs008.html b/doc/pub/Regression/html/._Regression-bs008.html
index f1be330c0..ec9818f45 100644
--- a/doc/pub/Regression/html/._Regression-bs008.html
+++ b/doc/pub/Regression/html/._Regression-bs008.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -424,7 +463,7 @@ $$
17
18
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs009.html b/doc/pub/Regression/html/._Regression-bs009.html
index 8f0099a19..03bf9471b 100644
--- a/doc/pub/Regression/html/._Regression-bs009.html
+++ b/doc/pub/Regression/html/._Regression-bs009.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -427,7 +466,7 @@ $$
18
19
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs010.html b/doc/pub/Regression/html/._Regression-bs010.html
index cdcdc50a0..80cfe6d3a 100644
--- a/doc/pub/Regression/html/._Regression-bs010.html
+++ b/doc/pub/Regression/html/._Regression-bs010.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -443,7 +482,7 @@ $$
19
20
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs011.html b/doc/pub/Regression/html/._Regression-bs011.html
index c4ae55c01..40049b000 100644
--- a/doc/pub/Regression/html/._Regression-bs011.html
+++ b/doc/pub/Regression/html/._Regression-bs011.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -430,7 +469,7 @@ $$
20
21
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs012.html b/doc/pub/Regression/html/._Regression-bs012.html
index 4b2724b1f..12e3facfd 100644
--- a/doc/pub/Regression/html/._Regression-bs012.html
+++ b/doc/pub/Regression/html/._Regression-bs012.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -432,7 +471,7 @@ meaning that the solution for \( \hat{\beta} \) is the one which minimizes the r
21
22
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs013.html b/doc/pub/Regression/html/._Regression-bs013.html
index 92e245a8c..6ee471d53 100644
--- a/doc/pub/Regression/html/._Regression-bs013.html
+++ b/doc/pub/Regression/html/._Regression-bs013.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -427,7 +466,7 @@ where the matrix \( \hat{\Sigma} \) is a diagonal matrix with \( \sigma_i \) as
22
23
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs014.html b/doc/pub/Regression/html/._Regression-bs014.html
index a888bb56e..1a3347bba 100644
--- a/doc/pub/Regression/html/._Regression-bs014.html
+++ b/doc/pub/Regression/html/._Regression-bs014.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -432,7 +471,7 @@ where we have defined the matrix \( \hat{A} =\hat{X}/\hat{\Sigma} \) with matrix
23
24
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs015.html b/doc/pub/Regression/html/._Regression-bs015.html
index 13b640175..6afcd78f7 100644
--- a/doc/pub/Regression/html/._Regression-bs015.html
+++ b/doc/pub/Regression/html/._Regression-bs015.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -430,7 +469,7 @@ $$
24
25
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs016.html b/doc/pub/Regression/html/._Regression-bs016.html
index fcaf19cef..5b981d515 100644
--- a/doc/pub/Regression/html/._Regression-bs016.html
+++ b/doc/pub/Regression/html/._Regression-bs016.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -435,7 +474,7 @@ $$
25
26
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs017.html b/doc/pub/Regression/html/._Regression-bs017.html
index 217936ac6..2011042b4 100644
--- a/doc/pub/Regression/html/._Regression-bs017.html
+++ b/doc/pub/Regression/html/._Regression-bs017.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -428,7 +467,7 @@ $$
26
27
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs018.html b/doc/pub/Regression/html/._Regression-bs018.html
index 4818576d8..a29f515f5 100644
--- a/doc/pub/Regression/html/._Regression-bs018.html
+++ b/doc/pub/Regression/html/._Regression-bs018.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -450,7 +489,7 @@ This approach (different linear and non-linear regression) suffers often from bo
27
28
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs019.html b/doc/pub/Regression/html/._Regression-bs019.html
index 60d0f0472..e254a6d69 100644
--- a/doc/pub/Regression/html/._Regression-bs019.html
+++ b/doc/pub/Regression/html/._Regression-bs019.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -443,7 +482,7 @@ We see that, as expected, a linear fit gives a seemingly (from the graph) good r
28
29
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs020.html b/doc/pub/Regression/html/._Regression-bs020.html
index 73da57f2f..192379b2a 100644
--- a/doc/pub/Regression/html/._Regression-bs020.html
+++ b/doc/pub/Regression/html/._Regression-bs020.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -434,7 +473,7 @@ plt. show()
29
30
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs021.html b/doc/pub/Regression/html/._Regression-bs021.html
index 01dde831f..0ab9033e7 100644
--- a/doc/pub/Regression/html/._Regression-bs021.html
+++ b/doc/pub/Regression/html/._Regression-bs021.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -471,7 +510,7 @@ plt. show()
30
31
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs022.html b/doc/pub/Regression/html/._Regression-bs022.html
index b7fb9cd33..40cf3890d 100644
--- a/doc/pub/Regression/html/._Regression-bs022.html
+++ b/doc/pub/Regression/html/._Regression-bs022.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -425,7 +464,7 @@ where \( x \) is defined as before.
31
32
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs023.html b/doc/pub/Regression/html/._Regression-bs023.html
index 53bc306cc..ebfc44f7a 100644
--- a/doc/pub/Regression/html/._Regression-bs023.html
+++ b/doc/pub/Regression/html/._Regression-bs023.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -416,7 +455,7 @@ have not discussed a more rigorous approach to the cost function.
32
33
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs024.html b/doc/pub/Regression/html/._Regression-bs024.html
index c3a3a1b8a..0080884ed 100644
--- a/doc/pub/Regression/html/._Regression-bs024.html
+++ b/doc/pub/Regression/html/._Regression-bs024.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -425,7 +464,7 @@ dimensionless.
33
34
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs025.html b/doc/pub/Regression/html/._Regression-bs025.html
index 69eb92b27..012175de2 100644
--- a/doc/pub/Regression/html/._Regression-bs025.html
+++ b/doc/pub/Regression/html/._Regression-bs025.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -424,7 +463,7 @@ the \( \chi^2 \) function becomes smaller.
34
35
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs026.html b/doc/pub/Regression/html/._Regression-bs026.html
index 77d8d82ed..bf4942717 100644
--- a/doc/pub/Regression/html/._Regression-bs026.html
+++ b/doc/pub/Regression/html/._Regression-bs026.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -443,7 +482,7 @@ relative error.
35
36
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs027.html b/doc/pub/Regression/html/._Regression-bs027.html
index 1ad262d3d..45e0111a4 100644
--- a/doc/pub/Regression/html/._Regression-bs027.html
+++ b/doc/pub/Regression/html/._Regression-bs027.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -448,7 +487,7 @@ plt. show()
36
37
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs028.html b/doc/pub/Regression/html/._Regression-bs028.html
index 62b5c5d1b..07e29b5c6 100644
--- a/doc/pub/Regression/html/._Regression-bs028.html
+++ b/doc/pub/Regression/html/._Regression-bs028.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -420,7 +459,7 @@ this function as being similar to the \( \chi^2 \) function defined above.
37
38
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs029.html b/doc/pub/Regression/html/._Regression-bs029.html
index 9277050b0..05602885b 100644
--- a/doc/pub/Regression/html/._Regression-bs029.html
+++ b/doc/pub/Regression/html/._Regression-bs029.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -427,7 +466,7 @@ $$
38
39
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs030.html b/doc/pub/Regression/html/._Regression-bs030.html
index cc82ea4d6..3ad0d84af 100644
--- a/doc/pub/Regression/html/._Regression-bs030.html
+++ b/doc/pub/Regression/html/._Regression-bs030.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -428,7 +467,7 @@ years etc.
39
40
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs031.html b/doc/pub/Regression/html/._Regression-bs031.html
index d8cbdb022..941b82cc4 100644
--- a/doc/pub/Regression/html/._Regression-bs031.html
+++ b/doc/pub/Regression/html/._Regression-bs031.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -451,7 +490,7 @@ Using R , we can perform similar studies.
40
41
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs032.html b/doc/pub/Regression/html/._Regression-bs032.html
index 5be20ef41..21a829bdc 100644
--- a/doc/pub/Regression/html/._Regression-bs032.html
+++ b/doc/pub/Regression/html/._Regression-bs032.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -434,7 +473,7 @@ plt. show()
41
42
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs033.html b/doc/pub/Regression/html/._Regression-bs033.html
index 00e4bff7d..9ff6edea4 100644
--- a/doc/pub/Regression/html/._Regression-bs033.html
+++ b/doc/pub/Regression/html/._Regression-bs033.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -430,7 +469,7 @@ non-random scalar. To specify the parameters of the distribution of
42
43
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs034.html b/doc/pub/Regression/html/._Regression-bs034.html
index 4efbba98b..03ff03934 100644
--- a/doc/pub/Regression/html/._Regression-bs034.html
+++ b/doc/pub/Regression/html/._Regression-bs034.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -437,7 +476,7 @@ Hence, \( Y_i \sim \mathcal{N}( \mathbf{X}_{i, \ast} \, \beta, \sigma^2) \).
43
44
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs035.html b/doc/pub/Regression/html/._Regression-bs035.html
index 07aedc90b..abc095fdd 100644
--- a/doc/pub/Regression/html/._Regression-bs035.html
+++ b/doc/pub/Regression/html/._Regression-bs035.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -425,7 +464,7 @@ $$
44
45
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs036.html b/doc/pub/Regression/html/._Regression-bs036.html
index f0422e232..a17b0f5ad 100644
--- a/doc/pub/Regression/html/._Regression-bs036.html
+++ b/doc/pub/Regression/html/._Regression-bs036.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -454,7 +493,7 @@ This is equivalent to saying that the matrix \( \hat{X} \) has at least an eigen
45
46
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs037.html b/doc/pub/Regression/html/._Regression-bs037.html
index 3e988d009..8f8d6c881 100644
--- a/doc/pub/Regression/html/._Regression-bs037.html
+++ b/doc/pub/Regression/html/._Regression-bs037.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -431,7 +470,7 @@ where \( \hat{I} \) is the identity matrix.
46
47
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs038.html b/doc/pub/Regression/html/._Regression-bs038.html
index 73dc89768..db901b2a8 100644
--- a/doc/pub/Regression/html/._Regression-bs038.html
+++ b/doc/pub/Regression/html/._Regression-bs038.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -430,7 +469,7 @@ Summarize what you have learned about the relationship between model complexity
47
48
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs039.html b/doc/pub/Regression/html/._Regression-bs039.html
index 2028fd298..a9fd9ad01 100644
--- a/doc/pub/Regression/html/._Regression-bs039.html
+++ b/doc/pub/Regression/html/._Regression-bs039.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -418,7 +457,7 @@ Summarize what you think you learned about the relationship of knowing the true
48
49
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs040.html b/doc/pub/Regression/html/._Regression-bs040.html
index a7a448086..d9630cc13 100644
--- a/doc/pub/Regression/html/._Regression-bs040.html
+++ b/doc/pub/Regression/html/._Regression-bs040.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -493,7 +532,7 @@ plt. show()
49
50
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs041.html b/doc/pub/Regression/html/._Regression-bs041.html
index eee89e490..76d514737 100644
--- a/doc/pub/Regression/html/._Regression-bs041.html
+++ b/doc/pub/Regression/html/._Regression-bs041.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -449,7 +488,7 @@ plt. show()
50
51
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs042.html b/doc/pub/Regression/html/._Regression-bs042.html
index 8a82fad75..d5805a287 100644
--- a/doc/pub/Regression/html/._Regression-bs042.html
+++ b/doc/pub/Regression/html/._Regression-bs042.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -414,7 +453,7 @@ decision on its value. How do we do that? Much of the same considerations apply
51
52
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs043.html b/doc/pub/Regression/html/._Regression-bs043.html
index 097d09f61..c19f51113 100644
--- a/doc/pub/Regression/html/._Regression-bs043.html
+++ b/doc/pub/Regression/html/._Regression-bs043.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -484,7 +523,7 @@ plt. show()
52
53
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs044.html b/doc/pub/Regression/html/._Regression-bs044.html
index 18644f1b3..74e5b648e 100644
--- a/doc/pub/Regression/html/._Regression-bs044.html
+++ b/doc/pub/Regression/html/._Regression-bs044.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -517,7 +556,7 @@ plt. show()
53
54
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs045.html b/doc/pub/Regression/html/._Regression-bs045.html
index 629b92b10..99d215822 100644
--- a/doc/pub/Regression/html/._Regression-bs045.html
+++ b/doc/pub/Regression/html/._Regression-bs045.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -424,7 +463,7 @@ once using the original training sample.
54
55
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs046.html b/doc/pub/Regression/html/._Regression-bs046.html
index a10d08bb9..b960c16c3 100644
--- a/doc/pub/Regression/html/._Regression-bs046.html
+++ b/doc/pub/Regression/html/._Regression-bs046.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -429,7 +468,7 @@ bootstrap is widely used.
55
56
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs047.html b/doc/pub/Regression/html/._Regression-bs047.html
index 45a7ae665..d76a1ddaf 100644
--- a/doc/pub/Regression/html/._Regression-bs047.html
+++ b/doc/pub/Regression/html/._Regression-bs047.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -420,7 +459,7 @@ MathJax.Hub.Config({
56
57
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs048.html b/doc/pub/Regression/html/._Regression-bs048.html
index ff55bacef..065fd7937 100644
--- a/doc/pub/Regression/html/._Regression-bs048.html
+++ b/doc/pub/Regression/html/._Regression-bs048.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -426,7 +465,7 @@ MathJax.Hub.Config({
57
58
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs049.html b/doc/pub/Regression/html/._Regression-bs049.html
index 6764d378a..e015ee6e5 100644
--- a/doc/pub/Regression/html/._Regression-bs049.html
+++ b/doc/pub/Regression/html/._Regression-bs049.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -435,7 +474,7 @@ selection of a large set of these numbers reproduces this PDF.
58
59
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs050.html b/doc/pub/Regression/html/._Regression-bs050.html
index b9d0e2710..9a62bada9 100644
--- a/doc/pub/Regression/html/._Regression-bs050.html
+++ b/doc/pub/Regression/html/._Regression-bs050.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -427,7 +466,7 @@ $$
59
60
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs051.html b/doc/pub/Regression/html/._Regression-bs051.html
index b24036b0c..b2090828a 100644
--- a/doc/pub/Regression/html/._Regression-bs051.html
+++ b/doc/pub/Regression/html/._Regression-bs051.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -442,7 +481,7 @@ qualitatively as the spread of \( p \) around its mean.
60
61
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs052.html b/doc/pub/Regression/html/._Regression-bs052.html
index f4b46a682..4082be61c 100644
--- a/doc/pub/Regression/html/._Regression-bs052.html
+++ b/doc/pub/Regression/html/._Regression-bs052.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -435,7 +474,7 @@ $$
61
62
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs053.html b/doc/pub/Regression/html/._Regression-bs053.html
index 09c54b61d..7836c4705 100644
--- a/doc/pub/Regression/html/._Regression-bs053.html
+++ b/doc/pub/Regression/html/._Regression-bs053.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -436,7 +475,7 @@ $$
62
63
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs054.html b/doc/pub/Regression/html/._Regression-bs054.html
index 22e2bb3a4..34234fd7b 100644
--- a/doc/pub/Regression/html/._Regression-bs054.html
+++ b/doc/pub/Regression/html/._Regression-bs054.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -430,7 +469,7 @@ $$
63
64
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs055.html b/doc/pub/Regression/html/._Regression-bs055.html
index ffccf342d..f91de8e81 100644
--- a/doc/pub/Regression/html/._Regression-bs055.html
+++ b/doc/pub/Regression/html/._Regression-bs055.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -436,7 +475,7 @@ value of a set of measurements.
64
65
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs056.html b/doc/pub/Regression/html/._Regression-bs056.html
index 26813c1d2..a7a9d479b 100644
--- a/doc/pub/Regression/html/._Regression-bs056.html
+++ b/doc/pub/Regression/html/._Regression-bs056.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -432,7 +471,7 @@ interested in finding the few lowest moments, like the mean
65
66
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs057.html b/doc/pub/Regression/html/._Regression-bs057.html
index f1dbfebcf..c0e2becb5 100644
--- a/doc/pub/Regression/html/._Regression-bs057.html
+++ b/doc/pub/Regression/html/._Regression-bs057.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -430,7 +469,7 @@ $$
66
67
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs058.html b/doc/pub/Regression/html/._Regression-bs058.html
index eec557144..0fdf133fd 100644
--- a/doc/pub/Regression/html/._Regression-bs058.html
+++ b/doc/pub/Regression/html/._Regression-bs058.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -425,7 +464,7 @@ and covariance \( \mathrm{cov}(X,Y) \).
67
68
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs059.html b/doc/pub/Regression/html/._Regression-bs059.html
index 7e743a687..ea0763aaf 100644
--- a/doc/pub/Regression/html/._Regression-bs059.html
+++ b/doc/pub/Regression/html/._Regression-bs059.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -436,7 +475,7 @@ true PDFs behind, which we usually do not have.
68
69
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs060.html b/doc/pub/Regression/html/._Regression-bs060.html
index 1744242ec..9863000eb 100644
--- a/doc/pub/Regression/html/._Regression-bs060.html
+++ b/doc/pub/Regression/html/._Regression-bs060.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -426,7 +465,7 @@ means.
69
70
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs061.html b/doc/pub/Regression/html/._Regression-bs061.html
index 855ee6b0a..17ca74a2c 100644
--- a/doc/pub/Regression/html/._Regression-bs061.html
+++ b/doc/pub/Regression/html/._Regression-bs061.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -425,7 +464,7 @@ And in particular we are interested in its variance \( \mathrm{var}(\overline X_
70
71
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs062.html b/doc/pub/Regression/html/._Regression-bs062.html
index 709cf9fc8..0ec164d3d 100644
--- a/doc/pub/Regression/html/._Regression-bs062.html
+++ b/doc/pub/Regression/html/._Regression-bs062.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -429,7 +468,7 @@ $$
71
72
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs063.html b/doc/pub/Regression/html/._Regression-bs063.html
index aa964e1d7..b6a58bbf6 100644
--- a/doc/pub/Regression/html/._Regression-bs063.html
+++ b/doc/pub/Regression/html/._Regression-bs063.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -433,7 +472,7 @@ estimate of the PDF of each of the \( X_i \), estimating all properties of
72
73
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs064.html b/doc/pub/Regression/html/._Regression-bs064.html
index 73aa4746e..15d11df4f 100644
--- a/doc/pub/Regression/html/._Regression-bs064.html
+++ b/doc/pub/Regression/html/._Regression-bs064.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -431,7 +470,7 @@ $$
73
74
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs065.html b/doc/pub/Regression/html/._Regression-bs065.html
index cf03c6dfa..61a64d6e7 100644
--- a/doc/pub/Regression/html/._Regression-bs065.html
+++ b/doc/pub/Regression/html/._Regression-bs065.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -443,7 +482,7 @@ measurements in the sample.
74
75
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs066.html b/doc/pub/Regression/html/._Regression-bs066.html
index 682017b2d..b18633ddb 100644
--- a/doc/pub/Regression/html/._Regression-bs066.html
+++ b/doc/pub/Regression/html/._Regression-bs066.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -439,7 +478,7 @@ cannot overlook the always present correlations.
75
76
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs067.html b/doc/pub/Regression/html/._Regression-bs067.html
index ac6022240..ce3cf496e 100644
--- a/doc/pub/Regression/html/._Regression-bs067.html
+++ b/doc/pub/Regression/html/._Regression-bs067.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -433,7 +472,7 @@ measurements. For uncorrelated measurements this second term is zero.
76
77
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs068.html b/doc/pub/Regression/html/._Regression-bs068.html
index 18ae22d07..28acb7f65 100644
--- a/doc/pub/Regression/html/._Regression-bs068.html
+++ b/doc/pub/Regression/html/._Regression-bs068.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -426,7 +465,7 @@ have to be stored throughout the experiment.
77
78
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs069.html b/doc/pub/Regression/html/._Regression-bs069.html
index 57280b0d6..24689f594 100644
--- a/doc/pub/Regression/html/._Regression-bs069.html
+++ b/doc/pub/Regression/html/._Regression-bs069.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -437,7 +476,7 @@ starting always at \( 1 \) for \( d=0 \).
78
79
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs070.html b/doc/pub/Regression/html/._Regression-bs070.html
index efcf83cca..d0a08f223 100644
--- a/doc/pub/Regression/html/._Regression-bs070.html
+++ b/doc/pub/Regression/html/._Regression-bs070.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -437,7 +476,7 @@ $$
79
80
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs071.html b/doc/pub/Regression/html/._Regression-bs071.html
index f132e0346..a7e68c8f4 100644
--- a/doc/pub/Regression/html/._Regression-bs071.html
+++ b/doc/pub/Regression/html/._Regression-bs071.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -429,7 +468,7 @@ measurements is very large.
80
81
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs072.html b/doc/pub/Regression/html/._Regression-bs072.html
index 0ab6f8bcd..6b0c75e54 100644
--- a/doc/pub/Regression/html/._Regression-bs072.html
+++ b/doc/pub/Regression/html/._Regression-bs072.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -436,7 +475,7 @@ The value of \( \lambda \) which minimizes \( \mbox{AIC}(\lambda) \) corresponds
81
82
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs073.html b/doc/pub/Regression/html/._Regression-bs073.html
index 7bc3fd4e5..6bce83806 100644
--- a/doc/pub/Regression/html/._Regression-bs073.html
+++ b/doc/pub/Regression/html/._Regression-bs073.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -434,7 +473,7 @@ some sense) is then selected.
82
83
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs074.html b/doc/pub/Regression/html/._Regression-bs074.html
index 2120de23e..7ddab5a16 100644
--- a/doc/pub/Regression/html/._Regression-bs074.html
+++ b/doc/pub/Regression/html/._Regression-bs074.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -415,7 +454,7 @@ The validation set approach is conceptually simple and is easy to implement. But
83
84
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs075.html b/doc/pub/Regression/html/._Regression-bs075.html
index 0f8eae171..302ee9562 100644
--- a/doc/pub/Regression/html/._Regression-bs075.html
+++ b/doc/pub/Regression/html/._Regression-bs075.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -424,7 +463,7 @@ cross-validation (LOOCV).
84
85
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs076.html b/doc/pub/Regression/html/._Regression-bs076.html
index 5b25680e5..1dcd2c9fd 100644
--- a/doc/pub/Regression/html/._Regression-bs076.html
+++ b/doc/pub/Regression/html/._Regression-bs076.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -439,7 +478,7 @@ $$
85
86
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs077.html b/doc/pub/Regression/html/._Regression-bs077.html
index 68ab6e94d..c902c861e 100644
--- a/doc/pub/Regression/html/._Regression-bs077.html
+++ b/doc/pub/Regression/html/._Regression-bs077.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -428,7 +467,7 @@ the design matrix and the parameters \( \beta \).
86
87
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs078.html b/doc/pub/Regression/html/._Regression-bs078.html
index efd0d82d1..8e5d69406 100644
--- a/doc/pub/Regression/html/._Regression-bs078.html
+++ b/doc/pub/Regression/html/._Regression-bs078.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -426,7 +465,7 @@ need for bootstrapping.
87
88
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs079.html b/doc/pub/Regression/html/._Regression-bs079.html
index e200bd8c3..3cd8369e9 100644
--- a/doc/pub/Regression/html/._Regression-bs079.html
+++ b/doc/pub/Regression/html/._Regression-bs079.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -422,7 +461,7 @@ number \( i \) is left out. Using this notation, define
88
89
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs080.html b/doc/pub/Regression/html/._Regression-bs080.html
index 3d89f5ba0..51764999a 100644
--- a/doc/pub/Regression/html/._Regression-bs080.html
+++ b/doc/pub/Regression/html/._Regression-bs080.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -417,7 +456,7 @@ $$
89
90
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs081.html b/doc/pub/Regression/html/._Regression-bs081.html
index 854b0125b..fe8949010 100644
--- a/doc/pub/Regression/html/._Regression-bs081.html
+++ b/doc/pub/Regression/html/._Regression-bs081.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -439,7 +478,7 @@ t = jackknife(x, stat)
90
91
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs082.html b/doc/pub/Regression/html/._Regression-bs082.html
index 63d63c594..ea5b87c5e 100644
--- a/doc/pub/Regression/html/._Regression-bs082.html
+++ b/doc/pub/Regression/html/._Regression-bs082.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -425,7 +464,7 @@ advantages:
91
92
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs083.html b/doc/pub/Regression/html/._Regression-bs083.html
index d7c3551c4..834ebb88b 100644
--- a/doc/pub/Regression/html/._Regression-bs083.html
+++ b/doc/pub/Regression/html/._Regression-bs083.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -419,7 +458,7 @@ estimators.
92
93
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs084.html b/doc/pub/Regression/html/._Regression-bs084.html
index b3b2e3814..e804d4f02 100644
--- a/doc/pub/Regression/html/._Regression-bs084.html
+++ b/doc/pub/Regression/html/._Regression-bs084.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -425,7 +464,7 @@ idea is to use the relative frequency of \( \widehat{\theta}^* \)
93
94
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs085.html b/doc/pub/Regression/html/._Regression-bs085.html
index 1513219f9..f5c492eff 100644
--- a/doc/pub/Regression/html/._Regression-bs085.html
+++ b/doc/pub/Regression/html/._Regression-bs085.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -424,7 +463,7 @@ frequency of the observation \( X_i \), just draw the values
94
95
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs086.html b/doc/pub/Regression/html/._Regression-bs086.html
index 184a4db28..4b88fd8ba 100644
--- a/doc/pub/Regression/html/._Regression-bs086.html
+++ b/doc/pub/Regression/html/._Regression-bs086.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -420,7 +459,7 @@ When you are done, you can draw a histogram of the relative frequency of \( \wid
95
96
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs087.html b/doc/pub/Regression/html/._Regression-bs087.html
index 5badfa310..b238190ec 100644
--- a/doc/pub/Regression/html/._Regression-bs087.html
+++ b/doc/pub/Regression/html/._Regression-bs087.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -454,7 +493,7 @@ plt. show()
96
97
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs088.html b/doc/pub/Regression/html/._Regression-bs088.html
index f9f418dcc..d27461467 100644
--- a/doc/pub/Regression/html/._Regression-bs088.html
+++ b/doc/pub/Regression/html/._Regression-bs088.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -429,7 +468,7 @@ moreover, it becomes more accurate the larger \( n \) is.
97
98
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs089.html b/doc/pub/Regression/html/._Regression-bs089.html
index 7e99c3cad..0195fd72b 100644
--- a/doc/pub/Regression/html/._Regression-bs089.html
+++ b/doc/pub/Regression/html/._Regression-bs089.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -440,7 +479,7 @@ elements of \( \vec{X}_i \) and let \( n_i \) be the number of elements of
98
99
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs090.html b/doc/pub/Regression/html/._Regression-bs090.html
index 9e0891aaf..a3746cf29 100644
--- a/doc/pub/Regression/html/._Regression-bs090.html
+++ b/doc/pub/Regression/html/._Regression-bs090.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -427,7 +466,7 @@ The quantity \( \hat{X} \) is asymptotic uncorrelated by assumption, \( \hat{X}_
99
100
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs091.html b/doc/pub/Regression/html/._Regression-bs091.html
index 72e1def76..13f1056fd 100644
--- a/doc/pub/Regression/html/._Regression-bs091.html
+++ b/doc/pub/Regression/html/._Regression-bs091.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -425,7 +464,7 @@ We can show that \( V(\overline{X}_i) = V(\overline{X}_j) \) for all \( 0 \leq i
100
101
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs092.html b/doc/pub/Regression/html/._Regression-bs092.html
index 9a65ab40c..8258b3005 100644
--- a/doc/pub/Regression/html/._Regression-bs092.html
+++ b/doc/pub/Regression/html/._Regression-bs092.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -434,7 +473,7 @@ It means we can apply blocking transformations until
101
102
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs093.html b/doc/pub/Regression/html/._Regression-bs093.html
index e1d99a12f..67c893844 100644
--- a/doc/pub/Regression/html/._Regression-bs093.html
+++ b/doc/pub/Regression/html/._Regression-bs093.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -631,6 +670,8 @@ dataAnalysis. printOutput()
101
102
103
+ ...
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs094.html b/doc/pub/Regression/html/._Regression-bs094.html
index 06e21545b..62bfeba8d 100644
--- a/doc/pub/Regression/html/._Regression-bs094.html
+++ b/doc/pub/Regression/html/._Regression-bs094.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -424,6 +463,9 @@ The
101
102
103
+ 104
+ ...
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs095.html b/doc/pub/Regression/html/._Regression-bs095.html
index 21344805e..4b2e34abf 100644
--- a/doc/pub/Regression/html/._Regression-bs095.html
+++ b/doc/pub/Regression/html/._Regression-bs095.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -413,6 +452,10 @@ where \( \epsilon \) is normally distributed with mean zero and standard deviati
101
102
103
+ 104
+ 105
+ ...
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs096.html b/doc/pub/Regression/html/._Regression-bs096.html
index 7688b8a91..da4fca920 100644
--- a/doc/pub/Regression/html/._Regression-bs096.html
+++ b/doc/pub/Regression/html/._Regression-bs096.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -415,6 +454,11 @@ $$
101
102
103
+ 104
+ 105
+ 106
+ ...
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs097.html b/doc/pub/Regression/html/._Regression-bs097.html
index 0ca3f9a9d..70b4a1f5c 100644
--- a/doc/pub/Regression/html/._Regression-bs097.html
+++ b/doc/pub/Regression/html/._Regression-bs097.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -415,6 +454,12 @@ functional if we drew an infinite number of datasets \( \{\mathcal{L}_1,
101
102
103
+ 104
+ 105
+ 106
+ 107
+ ...
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs098.html b/doc/pub/Regression/html/._Regression-bs098.html
index 9c7699772..e93202174 100644
--- a/doc/pub/Regression/html/._Regression-bs098.html
+++ b/doc/pub/Regression/html/._Regression-bs098.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -423,6 +462,13 @@ terms.
101
102
103
+ 104
+ 105
+ 106
+ 107
+ 108
+ ...
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs099.html b/doc/pub/Regression/html/._Regression-bs099.html
index e5b68b91a..107bd7107 100644
--- a/doc/pub/Regression/html/._Regression-bs099.html
+++ b/doc/pub/Regression/html/._Regression-bs099.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -415,6 +454,14 @@ $$
101
102
103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ ...
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs100.html b/doc/pub/Regression/html/._Regression-bs100.html
index d454ff85b..fce74f58b 100644
--- a/doc/pub/Regression/html/._Regression-bs100.html
+++ b/doc/pub/Regression/html/._Regression-bs100.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -408,6 +447,15 @@ and measures the deviation of the expectation value of our estimator (i.e. the a
101
102
103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ ...
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs101.html b/doc/pub/Regression/html/._Regression-bs101.html
index ea0da0cbf..051d57739 100644
--- a/doc/pub/Regression/html/._Regression-bs101.html
+++ b/doc/pub/Regression/html/._Regression-bs101.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -419,6 +458,16 @@ finite-sized training dataset (smaller variance).
101
102
103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ ...
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs102.html b/doc/pub/Regression/html/._Regression-bs102.html
index d129f2258..adccff3cc 100644
--- a/doc/pub/Regression/html/._Regression-bs102.html
+++ b/doc/pub/Regression/html/._Regression-bs102.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -401,6 +440,7 @@ 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.
+
diff --git a/doc/pub/Regression/html/._Regression-bs103.html b/doc/pub/Regression/html/._Regression-bs103.html
index 0aa98b52c..32bf8052f 100644
--- a/doc/pub/Regression/html/._Regression-bs103.html
+++ b/doc/pub/Regression/html/._Regression-bs103.html
@@ -194,46 +194,65 @@ Automatically generated HTML file from DocOnce source
'___sec77'),
('Resampling methods: Jackknife', 2, None, '___sec78'),
('Resampling methods: Jackknife estimator', 2, None, '___sec79'),
- ('Resampling methods: Bootstrap', 2, None, '___sec80'),
- ('Resampling methods: Bootstrap background', 2, None, '___sec81'),
+ ('Jackknife code example', 2, None, '___sec80'),
+ ('Resampling methods: Bootstrap', 2, None, '___sec81'),
+ ('Resampling methods: Bootstrap background', 2, None, '___sec82'),
('Resampling methods: More Bootstrap background',
2,
None,
- '___sec82'),
- ('Resampling methods: Bootstrap approach', 2, None, '___sec83'),
- ('Resampling methods: Bootstrap steps', 2, None, '___sec84'),
- ('Resampling methods: Blocking', 2, None, '___sec85'),
- ('Blocking Transformations', 2, None, '___sec86'),
- ('Blocking Transformations', 2, None, '___sec87'),
- ('Blocking Transformations, getting there', 2, None, '___sec88'),
+ '___sec83'),
+ ('Resampling methods: Bootstrap approach', 2, None, '___sec84'),
+ ('Resampling methods: Bootstrap steps', 2, None, '___sec85'),
+ ('Code example for the Bootstrap method', 2, None, '___sec86'),
+ ('Resampling methods: Blocking', 2, None, '___sec87'),
+ ('Blocking Transformations', 2, None, '___sec88'),
+ ('Blocking Transformations', 2, None, '___sec89'),
+ ('Blocking Transformations, getting there', 2, None, '___sec90'),
('Blocking Transformations, final expressions',
2,
None,
- '___sec89'),
+ '___sec91'),
('"Code examples for Blocking, Jackknife and '
'bootstrap":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/ResamplingAnalysisScripts"',
2,
None,
- '___sec90'),
- ('The bias-variance tradeoff', 2, None, '___sec91'),
- ('Training and testing data', 2, None, '___sec92'),
- ('Procedure to find a predictor', 2, None, '___sec93'),
- ('What we want', 2, None, '___sec94'),
- ('The expected generalization error', 2, None, '___sec95'),
- ('Elaborating a little bit more', 2, None, '___sec96'),
- ('The bias', 2, None, '___sec97'),
- ('The variance', 2, None, '___sec98'),
- ('Summing up', 2, None, '___sec99'),
- ('Logistic Regression', 2, None, '___sec100'),
- ('Basics', 2, None, '___sec101'),
- ('Linear classifier', 2, None, '___sec102'),
- ('Some selected properties', 2, None, '___sec103'),
- ('The cross-entropy as a cost function for logistic regression',
+ '___sec92'),
+ ('The bias-variance tradeoff', 2, None, '___sec93'),
+ ('Training and testing data', 2, None, '___sec94'),
+ ('Procedure to find a predictor', 2, None, '___sec95'),
+ ('What we want', 2, None, '___sec96'),
+ ('The expected generalization error', 2, None, '___sec97'),
+ ('Elaborating a little bit more', 2, None, '___sec98'),
+ ('The bias', 2, None, '___sec99'),
+ ('The variance', 2, None, '___sec100'),
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
2,
None,
'___sec104'),
- ('Maximum likelihood', 2, None, '___sec105'),
- ('Minimizing the cross entropy', 2, None, '___sec106')]}
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -351,33 +370,40 @@ MathJax.Hub.Config({
Resampling methods: Jackknife and Bootstrap
Resampling methods: Jackknife
Resampling methods: Jackknife estimator
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Resampling methods: Blocking
- Blocking Transformations
- Blocking Transformations
- Blocking Transformations, getting there
- Blocking Transformations, final expressions
- "Code examples for Blocking, Jackknife and bootstrap":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/ResamplingAnalysisScripts"
- The bias-variance tradeoff
- Training and testing data
- Procedure to find a predictor
- What we want
- The expected generalization error
- Elaborating a little bit more
- The bias
- The variance
- Summing up
- Logistic Regression
- Basics
- Linear classifier
- Some selected properties
- The cross-entropy as a cost function for logistic regression
- Maximum likelihood
- Minimizing the cross entropy
+ 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
+ Resampling methods: Blocking
+ Blocking Transformations
+ Blocking Transformations
+ Blocking Transformations, getting there
+ Blocking Transformations, final expressions
+ "Code examples for Blocking, Jackknife and bootstrap":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/ResamplingAnalysisScripts"
+ The bias-variance tradeoff
+ Training and testing data
+ Procedure to find a predictor
+ What we want
+ The expected generalization error
+ Elaborating a little bit more
+ The bias
+ The variance
+ Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -393,20 +419,37 @@ MathJax.Hub.Config({
-Linear classifier
+The one-dimensional Ising model, project 2
-Let us start by considering a slightly simpler classifier: a linear classifier that categorizes examples using a weighted linear-combination of the features and an additive offset
+The one-dimensional Ising model with nearest neighbor interaction, no external field and a constant coupling constant \( J \) is given by
+
$$
-\begin{equation}
-s_i = \boldsymbol{x}_i^T\boldsymbol{w} + b_0 \equiv \mathbf{x}_i^T\mathbf{w},
+\begin{align}
+ H = -J \sum_{k}^L s_k s_{k + 1},
\tag{30}
-\end{equation}
+\end{align}
$$
-where we use the short-hand notation
-\( \mathbf{x}_i = (1,\boldsymbol{x}_i) \) and \( \mathbf{w}_i = (b_0,\boldsymbol{w}_i) \).
+where \( s_i \in \{-1, 1\} \) and \( s_{N + 1} = s_1 \). The number of spins in the system is determined by \( L \). For the low temperature limit there is no phase transition.
+
+We will look at a system of \( L = 40 \) spins with a coupling constant of \( J = 1 \). To get enough training data we will generate 10000 states with their respective energies.
+
+
+
+
+
L = 40
+n = int (1e4 )
+
+spins = np. random. choice([-1 , 1 ], size= (n, L))
+J = 1.0
+
+energies = np. zeros(n)
+
+for i in range (n):
+ energies[i] = - J * np. dot(spins[i], np. roll(spins[i], 1 ))
+
@@ -428,6 +471,12 @@ where we use the short-hand notation
107
108
109
+ 110
+ 111
+ 112
+ 113
+ ...
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs104.html b/doc/pub/Regression/html/._Regression-bs104.html
index f7dcffe23..7f19c515a 100644
--- a/doc/pub/Regression/html/._Regression-bs104.html
+++ b/doc/pub/Regression/html/._Regression-bs104.html
@@ -194,46 +194,65 @@ Automatically generated HTML file from DocOnce source
'___sec77'),
('Resampling methods: Jackknife', 2, None, '___sec78'),
('Resampling methods: Jackknife estimator', 2, None, '___sec79'),
- ('Resampling methods: Bootstrap', 2, None, '___sec80'),
- ('Resampling methods: Bootstrap background', 2, None, '___sec81'),
+ ('Jackknife code example', 2, None, '___sec80'),
+ ('Resampling methods: Bootstrap', 2, None, '___sec81'),
+ ('Resampling methods: Bootstrap background', 2, None, '___sec82'),
('Resampling methods: More Bootstrap background',
2,
None,
- '___sec82'),
- ('Resampling methods: Bootstrap approach', 2, None, '___sec83'),
- ('Resampling methods: Bootstrap steps', 2, None, '___sec84'),
- ('Resampling methods: Blocking', 2, None, '___sec85'),
- ('Blocking Transformations', 2, None, '___sec86'),
- ('Blocking Transformations', 2, None, '___sec87'),
- ('Blocking Transformations, getting there', 2, None, '___sec88'),
+ '___sec83'),
+ ('Resampling methods: Bootstrap approach', 2, None, '___sec84'),
+ ('Resampling methods: Bootstrap steps', 2, None, '___sec85'),
+ ('Code example for the Bootstrap method', 2, None, '___sec86'),
+ ('Resampling methods: Blocking', 2, None, '___sec87'),
+ ('Blocking Transformations', 2, None, '___sec88'),
+ ('Blocking Transformations', 2, None, '___sec89'),
+ ('Blocking Transformations, getting there', 2, None, '___sec90'),
('Blocking Transformations, final expressions',
2,
None,
- '___sec89'),
+ '___sec91'),
('"Code examples for Blocking, Jackknife and '
'bootstrap":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/ResamplingAnalysisScripts"',
2,
None,
- '___sec90'),
- ('The bias-variance tradeoff', 2, None, '___sec91'),
- ('Training and testing data', 2, None, '___sec92'),
- ('Procedure to find a predictor', 2, None, '___sec93'),
- ('What we want', 2, None, '___sec94'),
- ('The expected generalization error', 2, None, '___sec95'),
- ('Elaborating a little bit more', 2, None, '___sec96'),
- ('The bias', 2, None, '___sec97'),
- ('The variance', 2, None, '___sec98'),
- ('Summing up', 2, None, '___sec99'),
- ('Logistic Regression', 2, None, '___sec100'),
- ('Basics', 2, None, '___sec101'),
- ('Linear classifier', 2, None, '___sec102'),
- ('Some selected properties', 2, None, '___sec103'),
- ('The cross-entropy as a cost function for logistic regression',
+ '___sec92'),
+ ('The bias-variance tradeoff', 2, None, '___sec93'),
+ ('Training and testing data', 2, None, '___sec94'),
+ ('Procedure to find a predictor', 2, None, '___sec95'),
+ ('What we want', 2, None, '___sec96'),
+ ('The expected generalization error', 2, None, '___sec97'),
+ ('Elaborating a little bit more', 2, None, '___sec98'),
+ ('The bias', 2, None, '___sec99'),
+ ('The variance', 2, None, '___sec100'),
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
2,
None,
'___sec104'),
- ('Maximum likelihood', 2, None, '___sec105'),
- ('Minimizing the cross entropy', 2, None, '___sec106')]}
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -351,33 +370,40 @@ MathJax.Hub.Config({
Resampling methods: Jackknife and Bootstrap
Resampling methods: Jackknife
Resampling methods: Jackknife estimator
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Resampling methods: Blocking
- Blocking Transformations
- Blocking Transformations
- Blocking Transformations, getting there
- Blocking Transformations, final expressions
- "Code examples for Blocking, Jackknife and bootstrap":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/ResamplingAnalysisScripts"
- The bias-variance tradeoff
- Training and testing data
- Procedure to find a predictor
- What we want
- The expected generalization error
- Elaborating a little bit more
- The bias
- The variance
- Summing up
- Logistic Regression
- Basics
- Linear classifier
- Some selected properties
- The cross-entropy as a cost function for logistic regression
- Maximum likelihood
- Minimizing the cross entropy
+ 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
+ Resampling methods: Blocking
+ Blocking Transformations
+ Blocking Transformations
+ Blocking Transformations, getting there
+ Blocking Transformations, final expressions
+ "Code examples for Blocking, Jackknife and bootstrap":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/ResamplingAnalysisScripts"
+ The bias-variance tradeoff
+ Training and testing data
+ Procedure to find a predictor
+ What we want
+ The expected generalization error
+ Elaborating a little bit more
+ The bias
+ The variance
+ Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -393,30 +419,28 @@ MathJax.Hub.Config({
-Some selected properties
+Example: The one-dimensional Ising model
-This function takes values on the entire real axis. In the case of
-logistic regression, however, the labels \( y_i \) are discrete
-variables. One simple way to get a discrete output is to have sign
-functions that map the output of a linear regressor to \( \{0,1\} \),
-\( f(s_i)=sign(s_i)=1 \) if \( s_i\ge 0 \) and 0 if otherwise. Indeed,
-this is commonly known as the "perceptron" in the machine learning
-literature. This model is extremely simple, and it is favorable in
-many cases (e.g. noisy data) to have a ``soft" classifier that outputs
-the probability of a given category. For example, given
-\( \mathbf{x}_i \), the classifier outputs the probability of being in
-category \( m \). One such function is the logistic (or sigmoid) function:
-
-$$
-\begin{equation}
-f(s) = \frac{1}{1+\mathrm e^{-s}}.
-\tag{31}
-\end{equation}
-$$
-
-Note that \( 1-f(s)= f(-s) \), which will be useful shortly.
+Here we use linear (ordinary least squares), ridge and LASSO
+regression to predict the energy in the nearest neighbor
+one-dimensional Ising model on a ring, i.e., the endpoints wrap
+around. We will use the linear regression models to fit a value for
+the coupling constant to achieve this.
+
+
+
import numpy as np
+import matplotlib.pyplot as plt
+from mpl_toolkits.axes_grid1 import make_axes_locatable
+import seaborn as sns
+import scipy.linalg as scl
+from sklearn.model_selection import train_test_split
+import sklearn.linear_model as skl
+import tqdm
+sns. set(color_codes= True )
+cmap_args= dict (vmin=-1. , vmax=1. , cmap= 'seismic' )
+
@@ -437,6 +461,13 @@ Note that \( 1-f(s)= f(-s) \), which will be useful shortly.
107
108
109
+ 110
+ 111
+ 112
+ 113
+ 114
+ ...
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs105.html b/doc/pub/Regression/html/._Regression-bs105.html
index 1d815b130..35f9a1406 100644
--- a/doc/pub/Regression/html/._Regression-bs105.html
+++ b/doc/pub/Regression/html/._Regression-bs105.html
@@ -194,46 +194,65 @@ Automatically generated HTML file from DocOnce source
'___sec77'),
('Resampling methods: Jackknife', 2, None, '___sec78'),
('Resampling methods: Jackknife estimator', 2, None, '___sec79'),
- ('Resampling methods: Bootstrap', 2, None, '___sec80'),
- ('Resampling methods: Bootstrap background', 2, None, '___sec81'),
+ ('Jackknife code example', 2, None, '___sec80'),
+ ('Resampling methods: Bootstrap', 2, None, '___sec81'),
+ ('Resampling methods: Bootstrap background', 2, None, '___sec82'),
('Resampling methods: More Bootstrap background',
2,
None,
- '___sec82'),
- ('Resampling methods: Bootstrap approach', 2, None, '___sec83'),
- ('Resampling methods: Bootstrap steps', 2, None, '___sec84'),
- ('Resampling methods: Blocking', 2, None, '___sec85'),
- ('Blocking Transformations', 2, None, '___sec86'),
- ('Blocking Transformations', 2, None, '___sec87'),
- ('Blocking Transformations, getting there', 2, None, '___sec88'),
+ '___sec83'),
+ ('Resampling methods: Bootstrap approach', 2, None, '___sec84'),
+ ('Resampling methods: Bootstrap steps', 2, None, '___sec85'),
+ ('Code example for the Bootstrap method', 2, None, '___sec86'),
+ ('Resampling methods: Blocking', 2, None, '___sec87'),
+ ('Blocking Transformations', 2, None, '___sec88'),
+ ('Blocking Transformations', 2, None, '___sec89'),
+ ('Blocking Transformations, getting there', 2, None, '___sec90'),
('Blocking Transformations, final expressions',
2,
None,
- '___sec89'),
+ '___sec91'),
('"Code examples for Blocking, Jackknife and '
'bootstrap":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/ResamplingAnalysisScripts"',
2,
None,
- '___sec90'),
- ('The bias-variance tradeoff', 2, None, '___sec91'),
- ('Training and testing data', 2, None, '___sec92'),
- ('Procedure to find a predictor', 2, None, '___sec93'),
- ('What we want', 2, None, '___sec94'),
- ('The expected generalization error', 2, None, '___sec95'),
- ('Elaborating a little bit more', 2, None, '___sec96'),
- ('The bias', 2, None, '___sec97'),
- ('The variance', 2, None, '___sec98'),
- ('Summing up', 2, None, '___sec99'),
- ('Logistic Regression', 2, None, '___sec100'),
- ('Basics', 2, None, '___sec101'),
- ('Linear classifier', 2, None, '___sec102'),
- ('Some selected properties', 2, None, '___sec103'),
- ('The cross-entropy as a cost function for logistic regression',
+ '___sec92'),
+ ('The bias-variance tradeoff', 2, None, '___sec93'),
+ ('Training and testing data', 2, None, '___sec94'),
+ ('Procedure to find a predictor', 2, None, '___sec95'),
+ ('What we want', 2, None, '___sec96'),
+ ('The expected generalization error', 2, None, '___sec97'),
+ ('Elaborating a little bit more', 2, None, '___sec98'),
+ ('The bias', 2, None, '___sec99'),
+ ('The variance', 2, None, '___sec100'),
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
2,
None,
'___sec104'),
- ('Maximum likelihood', 2, None, '___sec105'),
- ('Minimizing the cross entropy', 2, None, '___sec106')]}
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -351,33 +370,40 @@ MathJax.Hub.Config({
Resampling methods: Jackknife and Bootstrap
Resampling methods: Jackknife
Resampling methods: Jackknife estimator
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Resampling methods: Blocking
- Blocking Transformations
- Blocking Transformations
- Blocking Transformations, getting there
- Blocking Transformations, final expressions
- "Code examples for Blocking, Jackknife and bootstrap":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/ResamplingAnalysisScripts"
- The bias-variance tradeoff
- Training and testing data
- Procedure to find a predictor
- What we want
- The expected generalization error
- Elaborating a little bit more
- The bias
- The variance
- Summing up
- Logistic Regression
- Basics
- Linear classifier
- Some selected properties
- The cross-entropy as a cost function for logistic regression
- Maximum likelihood
- Minimizing the cross entropy
+ 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
+ Resampling methods: Blocking
+ Blocking Transformations
+ Blocking Transformations
+ Blocking Transformations, getting there
+ Blocking Transformations, final expressions
+ "Code examples for Blocking, Jackknife and bootstrap":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/ResamplingAnalysisScripts"
+ The bias-variance tradeoff
+ Training and testing data
+ Procedure to find a predictor
+ What we want
+ The expected generalization error
+ Elaborating a little bit more
+ The bias
+ The variance
+ Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -393,26 +419,59 @@ MathJax.Hub.Config({
-The cross-entropy as a cost function for logistic regression
+Reformulating the problem to suit regression
-The perceptron is an example of a ``hard classification": each datapoint is deterministically assigned to a category (i.e \( y_i=0 \) or \( y_i=1 \)). In many cases, it is favorable to have a "soft" classifier that outputs the probability of a given category rather than a single value. For example, given \( \mathbf{x}_i \), the classifier outputs the probability of being in category \( m \).
-Logistic regression is the most canonical example of a soft classifier. In logistic regression, the probability that a data point \( \boldsymbol{x}_i \) belongs to a category \( y_i=\{0,1\} \) is is given by
-$$
-\begin{eqnarray}
-P(y_i=1|\boldsymbol{x}_i,\boldsymbol{\theta)} &=& \frac{1}{1+\mathrm{e}^{-\mathbf{x}^T_i\mathbf{w}}},\nonumber\\
-P(y_i=0|\boldsymbol{x}_i,\boldsymbol{\theta)} &=& 1 - P(y_i=1|\boldsymbol{x}_i,\boldsymbol{\theta)},
-\end{eqnarray}
-$$
+A more general form for the one-dimensional Ising model is
-where \( \boldsymbol{\theta}=\mathbf{w} \) are the weights we wish to learn from the data.
+$$
+\begin{align}
+ H = - \sum_j^L \sum_k^L s_j s_k J_{jk}.
+\tag{31}
+\end{align}
+$$
-Notice that in terms of the logistic function, we can write
+Here we allow for interactions beyond the nearest neighbors and a more
+adaptive coupling matrix. This latter expression can be formulated as
+a matrix-product on the form
$$
-P(y_i=1) =f(\mathbf{x}_i^T\mathbf{w})=1-P(y_i=0).
+\begin{align}
+ H = X J,
+\tag{32}
+\end{align}
$$
+
+where \( X_{jk} = s_j s_k \) and \( J \) is the matrix consisting of the
+elements \( -J_{jk} \). This form of writing the energy fits perfectly
+with the form utilized in linear regression, viz.
+$$
+\begin{align}
+ y = X\omega + \epsilon,
+\tag{33}
+\end{align}
+$$
+
+
+
+
+
X = np. zeros((n, L ** 2 ))
+for i in range (n):
+ X[i] = np. outer(spins[i], spins[i]). ravel()
+y = energies
+X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.96 )
+
+X_train_own = np. concatenate(
+ (np. ones(len (X_train))[:, np. newaxis], X_train),
+ axis=1
+)
+
+X_test_own = np. concatenate(
+ (np. ones(len (X_test))[:, np. newaxis], X_test),
+ axis=1
+)
+
@@ -432,6 +491,12 @@ $$
107
108
109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs106.html b/doc/pub/Regression/html/._Regression-bs106.html
index 7f367c12c..2b8dd41ea 100644
--- a/doc/pub/Regression/html/._Regression-bs106.html
+++ b/doc/pub/Regression/html/._Regression-bs106.html
@@ -194,46 +194,65 @@ Automatically generated HTML file from DocOnce source
'___sec77'),
('Resampling methods: Jackknife', 2, None, '___sec78'),
('Resampling methods: Jackknife estimator', 2, None, '___sec79'),
- ('Resampling methods: Bootstrap', 2, None, '___sec80'),
- ('Resampling methods: Bootstrap background', 2, None, '___sec81'),
+ ('Jackknife code example', 2, None, '___sec80'),
+ ('Resampling methods: Bootstrap', 2, None, '___sec81'),
+ ('Resampling methods: Bootstrap background', 2, None, '___sec82'),
('Resampling methods: More Bootstrap background',
2,
None,
- '___sec82'),
- ('Resampling methods: Bootstrap approach', 2, None, '___sec83'),
- ('Resampling methods: Bootstrap steps', 2, None, '___sec84'),
- ('Resampling methods: Blocking', 2, None, '___sec85'),
- ('Blocking Transformations', 2, None, '___sec86'),
- ('Blocking Transformations', 2, None, '___sec87'),
- ('Blocking Transformations, getting there', 2, None, '___sec88'),
+ '___sec83'),
+ ('Resampling methods: Bootstrap approach', 2, None, '___sec84'),
+ ('Resampling methods: Bootstrap steps', 2, None, '___sec85'),
+ ('Code example for the Bootstrap method', 2, None, '___sec86'),
+ ('Resampling methods: Blocking', 2, None, '___sec87'),
+ ('Blocking Transformations', 2, None, '___sec88'),
+ ('Blocking Transformations', 2, None, '___sec89'),
+ ('Blocking Transformations, getting there', 2, None, '___sec90'),
('Blocking Transformations, final expressions',
2,
None,
- '___sec89'),
+ '___sec91'),
('"Code examples for Blocking, Jackknife and '
'bootstrap":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/ResamplingAnalysisScripts"',
2,
None,
- '___sec90'),
- ('The bias-variance tradeoff', 2, None, '___sec91'),
- ('Training and testing data', 2, None, '___sec92'),
- ('Procedure to find a predictor', 2, None, '___sec93'),
- ('What we want', 2, None, '___sec94'),
- ('The expected generalization error', 2, None, '___sec95'),
- ('Elaborating a little bit more', 2, None, '___sec96'),
- ('The bias', 2, None, '___sec97'),
- ('The variance', 2, None, '___sec98'),
- ('Summing up', 2, None, '___sec99'),
- ('Logistic Regression', 2, None, '___sec100'),
- ('Basics', 2, None, '___sec101'),
- ('Linear classifier', 2, None, '___sec102'),
- ('Some selected properties', 2, None, '___sec103'),
- ('The cross-entropy as a cost function for logistic regression',
+ '___sec92'),
+ ('The bias-variance tradeoff', 2, None, '___sec93'),
+ ('Training and testing data', 2, None, '___sec94'),
+ ('Procedure to find a predictor', 2, None, '___sec95'),
+ ('What we want', 2, None, '___sec96'),
+ ('The expected generalization error', 2, None, '___sec97'),
+ ('Elaborating a little bit more', 2, None, '___sec98'),
+ ('The bias', 2, None, '___sec99'),
+ ('The variance', 2, None, '___sec100'),
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
2,
None,
'___sec104'),
- ('Maximum likelihood', 2, None, '___sec105'),
- ('Minimizing the cross entropy', 2, None, '___sec106')]}
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -351,33 +370,40 @@ MathJax.Hub.Config({
Resampling methods: Jackknife and Bootstrap
Resampling methods: Jackknife
Resampling methods: Jackknife estimator
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Resampling methods: Blocking
- Blocking Transformations
- Blocking Transformations
- Blocking Transformations, getting there
- Blocking Transformations, final expressions
- "Code examples for Blocking, Jackknife and bootstrap":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/ResamplingAnalysisScripts"
- The bias-variance tradeoff
- Training and testing data
- Procedure to find a predictor
- What we want
- The expected generalization error
- Elaborating a little bit more
- The bias
- The variance
- Summing up
- Logistic Regression
- Basics
- Linear classifier
- Some selected properties
- The cross-entropy as a cost function for logistic regression
- Maximum likelihood
- Minimizing the cross entropy
+ 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
+ Resampling methods: Blocking
+ Blocking Transformations
+ Blocking Transformations
+ Blocking Transformations, getting there
+ Blocking Transformations, final expressions
+ "Code examples for Blocking, Jackknife and bootstrap":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/ResamplingAnalysisScripts"
+ The bias-variance tradeoff
+ Training and testing data
+ Procedure to find a predictor
+ What we want
+ The expected generalization error
+ Elaborating a little bit more
+ The bias
+ The variance
+ Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -391,32 +417,38 @@ MathJax.Hub.Config({
-
+
-Maximum likelihood
+Linear regression
-We now define the cost function for logistic regression using Maximum
-Likelihood Estimation (MLE). Recall, that in MLE we choose parameters
-to maximize the probability of seeing the observed data. Consider a
-dataset \( \mathcal{D}=\{(y_i,\boldsymbol{x}_i)\} \) with binary labels
-\( y_i\in\{0,1\} \) where the data points are drawn independently. The
-likelihood of the seeing the data under our model is just:
+The problem at hand is to try to fit the equation
$$
\begin{align}
-P(\mathcal{D}|\mathbf{w})& = \prod_{i=1}^n \left[f(\mathbf{x}_i^T\mathbf{w})\right]^{y_i}\left[1-f(\mathbf{x}_i^T\mathbf{w})\right]^{1-y_i}\nonumber \\
-\tag{32}
+ y = f(x) + \epsilon,
+\tag{34}
\end{align}
$$
-from which we can readily compute the log-likelihood:
+
+where \( f(x) \) is some unknown function of the data \( x \) and \( \epsilon \)
+is normally distributed with mean zero noise with standard deviation
+\( \sigma_{\epsilon} \). Our job is to try to find a predictor which
+estimates the function \( f(x) \). In linear regression we assume that we
+can formulate the problem as
+
$$
-\begin{equation}
-l(\mathbf{w}) = \sum_{i=1}^n y_i\log f(\mathbf{x}_i^T\mathbf{w}) + (1-y_i)\log\left[1-f(\mathbf{x}_i^T\mathbf{w})\right].
-\tag{33}
-\end{equation}
+\begin{align}
+ y = X\omega + \epsilon,
+\tag{35}
+\end{align}
$$
+
+where \( X \) and \( \omega \) are now matrices. Our job at hand is now to
+find a cost function \( C \), which we wish to minimize in order to find
+the best estimate of \( \omega \).
+
@@ -435,6 +467,12 @@ $$
107
108
109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs107.html b/doc/pub/Regression/html/._Regression-bs107.html
index 0ff989da8..9eeb9f894 100644
--- a/doc/pub/Regression/html/._Regression-bs107.html
+++ b/doc/pub/Regression/html/._Regression-bs107.html
@@ -194,46 +194,65 @@ Automatically generated HTML file from DocOnce source
'___sec77'),
('Resampling methods: Jackknife', 2, None, '___sec78'),
('Resampling methods: Jackknife estimator', 2, None, '___sec79'),
- ('Resampling methods: Bootstrap', 2, None, '___sec80'),
- ('Resampling methods: Bootstrap background', 2, None, '___sec81'),
+ ('Jackknife code example', 2, None, '___sec80'),
+ ('Resampling methods: Bootstrap', 2, None, '___sec81'),
+ ('Resampling methods: Bootstrap background', 2, None, '___sec82'),
('Resampling methods: More Bootstrap background',
2,
None,
- '___sec82'),
- ('Resampling methods: Bootstrap approach', 2, None, '___sec83'),
- ('Resampling methods: Bootstrap steps', 2, None, '___sec84'),
- ('Resampling methods: Blocking', 2, None, '___sec85'),
- ('Blocking Transformations', 2, None, '___sec86'),
- ('Blocking Transformations', 2, None, '___sec87'),
- ('Blocking Transformations, getting there', 2, None, '___sec88'),
+ '___sec83'),
+ ('Resampling methods: Bootstrap approach', 2, None, '___sec84'),
+ ('Resampling methods: Bootstrap steps', 2, None, '___sec85'),
+ ('Code example for the Bootstrap method', 2, None, '___sec86'),
+ ('Resampling methods: Blocking', 2, None, '___sec87'),
+ ('Blocking Transformations', 2, None, '___sec88'),
+ ('Blocking Transformations', 2, None, '___sec89'),
+ ('Blocking Transformations, getting there', 2, None, '___sec90'),
('Blocking Transformations, final expressions',
2,
None,
- '___sec89'),
+ '___sec91'),
('"Code examples for Blocking, Jackknife and '
'bootstrap":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/ResamplingAnalysisScripts"',
2,
None,
- '___sec90'),
- ('The bias-variance tradeoff', 2, None, '___sec91'),
- ('Training and testing data', 2, None, '___sec92'),
- ('Procedure to find a predictor', 2, None, '___sec93'),
- ('What we want', 2, None, '___sec94'),
- ('The expected generalization error', 2, None, '___sec95'),
- ('Elaborating a little bit more', 2, None, '___sec96'),
- ('The bias', 2, None, '___sec97'),
- ('The variance', 2, None, '___sec98'),
- ('Summing up', 2, None, '___sec99'),
- ('Logistic Regression', 2, None, '___sec100'),
- ('Basics', 2, None, '___sec101'),
- ('Linear classifier', 2, None, '___sec102'),
- ('Some selected properties', 2, None, '___sec103'),
- ('The cross-entropy as a cost function for logistic regression',
+ '___sec92'),
+ ('The bias-variance tradeoff', 2, None, '___sec93'),
+ ('Training and testing data', 2, None, '___sec94'),
+ ('Procedure to find a predictor', 2, None, '___sec95'),
+ ('What we want', 2, None, '___sec96'),
+ ('The expected generalization error', 2, None, '___sec97'),
+ ('Elaborating a little bit more', 2, None, '___sec98'),
+ ('The bias', 2, None, '___sec99'),
+ ('The variance', 2, None, '___sec100'),
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
2,
None,
'___sec104'),
- ('Maximum likelihood', 2, None, '___sec105'),
- ('Minimizing the cross entropy', 2, None, '___sec106')]}
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -351,33 +370,40 @@ MathJax.Hub.Config({
Resampling methods: Jackknife and Bootstrap
Resampling methods: Jackknife
Resampling methods: Jackknife estimator
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Resampling methods: Blocking
- Blocking Transformations
- Blocking Transformations
- Blocking Transformations, getting there
- Blocking Transformations, final expressions
- "Code examples for Blocking, Jackknife and bootstrap":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/ResamplingAnalysisScripts"
- The bias-variance tradeoff
- Training and testing data
- Procedure to find a predictor
- What we want
- The expected generalization error
- Elaborating a little bit more
- The bias
- The variance
- Summing up
- Logistic Regression
- Basics
- Linear classifier
- Some selected properties
- The cross-entropy as a cost function for logistic regression
- Maximum likelihood
- Minimizing the cross entropy
+ 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
+ Resampling methods: Blocking
+ Blocking Transformations
+ Blocking Transformations
+ Blocking Transformations, getting there
+ Blocking Transformations, final expressions
+ "Code examples for Blocking, Jackknife and bootstrap":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/ResamplingAnalysisScripts"
+ The bias-variance tradeoff
+ Training and testing data
+ Procedure to find a predictor
+ What we want
+ The expected generalization error
+ Elaborating a little bit more
+ The bias
+ The variance
+ Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -392,22 +418,50 @@ MathJax.Hub.Config({
-The maximum likelihood estimator is defined as the set of parameters that maximize the log-likelihood where we maximize with respect to \( \theta \)
+
+Ordinary least squares
+
+
+In the ordinary least squares method we choose the cost function
$$
-\hat{\mathbf{w}} = \sum_{i=1}^n y_i\log f(\mathbf{x}_i^T\mathbf{w}) + (1-y_i)\log\left[1-f(\mathbf{x}_i^T\mathbf{w})\right].
+\begin{align}
+ C(X, \omega) = ||X\omega - y||^2
+ = (X\omega - y)^T(X\omega - y)
+\tag{36}
+\end{align}
$$
-Since the cost (error) function is just the negative log-likelihood, for logistic regression we have that
+We then find the extremal point of \( C \) by taking the derivative with respect to \( \omega \) and setting it to zero, i.e.,
+
$$
-\begin{eqnarray}
-\mathcal{C}(\mathbf{w}) &=& - l(\mathbf{w}) \\
-&=& \sum_{i=1}^n -y_i\log f(\mathbf{x}_i^T\mathbf{w}) - (1-y_i)\log\left[1-f(\mathbf{x}_i^T\mathbf{w})\right].\nonumber
-\end{eqnarray}
+\begin{align}
+ \dfrac{\mathrm{d}C}{\mathrm{d}\omega}
+ = 0.
+\tag{37}
+\end{align}
$$
-This equation is known in statistics as the \emph{cross entropy}. Finally, we note that just as in linear regression,
-in practice we usually supplement the cross-entropy with additional regularization terms, usually \( L_1 \) and \( L_2 \) regularization as we did for Ridge and Lasso regression.
+This yields the expression for \( \omega \) to be
+$$
+\begin{align}
+ \omega = \frac{X^T y}{X^T X},
+\tag{38}
+\end{align}
+$$
+
+which immediately imposes some requirements on \( X \) as there must exist
+an inverse of \( X^T X \). If the expression we are modelling contains an
+intercept, i.e., a constant expression we must make sure that the
+first column of \( X \) consists of \( 1 \).
+
+
+
+
+
def get_ols_weights_naive (x: np. ndarray, y: np. ndarray) -> np. ndarray:
+ return scl. inv(x. T @ x) @ (x. T @ y)
+omega = get_ols_weights_naive(X_train_own, y_train)
+
@@ -425,6 +479,12 @@ in practice we usually supplement the cross-entropy with additional regularizati
107
108
109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
»
diff --git a/doc/pub/Regression/html/._Regression-bs108.html b/doc/pub/Regression/html/._Regression-bs108.html
index 24f214d02..2e1910830 100644
--- a/doc/pub/Regression/html/._Regression-bs108.html
+++ b/doc/pub/Regression/html/._Regression-bs108.html
@@ -194,46 +194,65 @@ Automatically generated HTML file from DocOnce source
'___sec77'),
('Resampling methods: Jackknife', 2, None, '___sec78'),
('Resampling methods: Jackknife estimator', 2, None, '___sec79'),
- ('Resampling methods: Bootstrap', 2, None, '___sec80'),
- ('Resampling methods: Bootstrap background', 2, None, '___sec81'),
+ ('Jackknife code example', 2, None, '___sec80'),
+ ('Resampling methods: Bootstrap', 2, None, '___sec81'),
+ ('Resampling methods: Bootstrap background', 2, None, '___sec82'),
('Resampling methods: More Bootstrap background',
2,
None,
- '___sec82'),
- ('Resampling methods: Bootstrap approach', 2, None, '___sec83'),
- ('Resampling methods: Bootstrap steps', 2, None, '___sec84'),
- ('Resampling methods: Blocking', 2, None, '___sec85'),
- ('Blocking Transformations', 2, None, '___sec86'),
- ('Blocking Transformations', 2, None, '___sec87'),
- ('Blocking Transformations, getting there', 2, None, '___sec88'),
+ '___sec83'),
+ ('Resampling methods: Bootstrap approach', 2, None, '___sec84'),
+ ('Resampling methods: Bootstrap steps', 2, None, '___sec85'),
+ ('Code example for the Bootstrap method', 2, None, '___sec86'),
+ ('Resampling methods: Blocking', 2, None, '___sec87'),
+ ('Blocking Transformations', 2, None, '___sec88'),
+ ('Blocking Transformations', 2, None, '___sec89'),
+ ('Blocking Transformations, getting there', 2, None, '___sec90'),
('Blocking Transformations, final expressions',
2,
None,
- '___sec89'),
+ '___sec91'),
('"Code examples for Blocking, Jackknife and '
'bootstrap":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/ResamplingAnalysisScripts"',
2,
None,
- '___sec90'),
- ('The bias-variance tradeoff', 2, None, '___sec91'),
- ('Training and testing data', 2, None, '___sec92'),
- ('Procedure to find a predictor', 2, None, '___sec93'),
- ('What we want', 2, None, '___sec94'),
- ('The expected generalization error', 2, None, '___sec95'),
- ('Elaborating a little bit more', 2, None, '___sec96'),
- ('The bias', 2, None, '___sec97'),
- ('The variance', 2, None, '___sec98'),
- ('Summing up', 2, None, '___sec99'),
- ('Logistic Regression', 2, None, '___sec100'),
- ('Basics', 2, None, '___sec101'),
- ('Linear classifier', 2, None, '___sec102'),
- ('Some selected properties', 2, None, '___sec103'),
- ('The cross-entropy as a cost function for logistic regression',
+ '___sec92'),
+ ('The bias-variance tradeoff', 2, None, '___sec93'),
+ ('Training and testing data', 2, None, '___sec94'),
+ ('Procedure to find a predictor', 2, None, '___sec95'),
+ ('What we want', 2, None, '___sec96'),
+ ('The expected generalization error', 2, None, '___sec97'),
+ ('Elaborating a little bit more', 2, None, '___sec98'),
+ ('The bias', 2, None, '___sec99'),
+ ('The variance', 2, None, '___sec100'),
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
2,
None,
'___sec104'),
- ('Maximum likelihood', 2, None, '___sec105'),
- ('Minimizing the cross entropy', 2, None, '___sec106')]}
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -351,33 +370,40 @@ MathJax.Hub.Config({
Resampling methods: Jackknife and Bootstrap
Resampling methods: Jackknife
Resampling methods: Jackknife estimator
- Resampling methods: Bootstrap
- Resampling methods: Bootstrap background
- Resampling methods: More Bootstrap background
- Resampling methods: Bootstrap approach
- Resampling methods: Bootstrap steps
- Resampling methods: Blocking
- Blocking Transformations
- Blocking Transformations
- Blocking Transformations, getting there
- Blocking Transformations, final expressions
- "Code examples for Blocking, Jackknife and bootstrap":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/ResamplingAnalysisScripts"
- The bias-variance tradeoff
- Training and testing data
- Procedure to find a predictor
- What we want
- The expected generalization error
- Elaborating a little bit more
- The bias
- The variance
- Summing up
- Logistic Regression
- Basics
- Linear classifier
- Some selected properties
- The cross-entropy as a cost function for logistic regression
- Maximum likelihood
- Minimizing the cross entropy
+ 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
+ Resampling methods: Blocking
+ Blocking Transformations
+ Blocking Transformations
+ Blocking Transformations, getting there
+ Blocking Transformations, final expressions
+ "Code examples for Blocking, Jackknife and bootstrap":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/ResamplingAnalysisScripts"
+ The bias-variance tradeoff
+ Training and testing data
+ Procedure to find a predictor
+ What we want
+ The expected generalization error
+ Elaborating a little bit more
+ The bias
+ The variance
+ Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -393,27 +419,62 @@ MathJax.Hub.Config({
-Minimizing the cross entropy
-
-
-The cross entropy is a convex function of the weights \( \mathbf{w} \) and,
-therefore, any local minimizer is a global minimizer. Minimizing this
-cost function leads to the following equation
+
Singular Value decomposition
+Doing the inversion directly turns out to be a bad idea as the matrix
+\( X^TX \) is singular. An alternative approach is to use the singular
+value decomposition . Using the definition of the Moore-Penrose
+pseudoinverse we can write the equation for \( \omega \) as
$$
-\begin{equation}
-\boldsymbol{0}=\boldsymbol{\nabla} \mathcal{C}(\mathbf{w}) = \sum_{i=1}^n\left[f(\mathbf{x}_i^T\mathbf{w})-y_i\right]\mathbf{x}_i,
-\tag{34}
-\end{equation}
+\begin{align}
+ \omega = X^{+}y,
+\tag{39}
+\end{align}
+$$
+
+where the pseudoinverse of \( X \) is given by
+$$
+\begin{align}
+ X^{+} = \frac{X^T}{X^T X}.
+\tag{40}
+\end{align}
$$
-where we made use of the logistic function identity \( \partial_z f(z) =
-f(z)[1-f(z)] \). This equation defines a transcendental equation for
-\( \mathbf{w} \), the solution of which, unlike linear regression, cannot
-be written in a closed form.
-Here we need gradient descent methods!
+Using singular value decomposition we have that \( X = U\Sigma V^T \),
+where \( X^{+} = V\Sigma^{+} U^T \). This reduces the equation for
+\( \omega \) to
+$$
+\begin{align}
+ \omega = V\Sigma^{+} U^T y.
+\tag{41}
+\end{align}
+$$
+
+Note that solving this equation by actually doing the pseudoinverse
+(which is what we will do) is not a good idea as this operation scales
+as \( \mathcal{O}(n^3) \), where \( n \) is the number of elements in a
+general matrix. Instead, doing \( QR \)-factorization and solving the
+linear system as an equation would reduce this down to
+\( \mathcal{O}(n^2) \) operations.
+
+
+
+
+
def get_ols_weights (x: np. ndarray, y: np. ndarray) -> np. ndarray:
+ u, s, v = scl. svd(x)
+ return v. T @ scl. pinv(scl. diagsvd(s, u. shape[0 ], v. shape[0 ])) @ u. T @ y
+
+
+Before passing in the data to the function we append a column with ones to the training data.
+
+
+
+
+
omega = get_ols_weights(X_train_own,y_train)
+
+
diff --git a/doc/pub/Regression/html/._Regression-bs109.html b/doc/pub/Regression/html/._Regression-bs109.html
new file mode 100644
index 000000000..804d9cf08
--- /dev/null
+++ b/doc/pub/Regression/html/._Regression-bs109.html
@@ -0,0 +1,515 @@
+
+
+
+
+
+
+
+Data Analysis and Machine Learning: Linear Regression and more Advanced Regression Analysis
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Fitting with scikit-learn
+
+
+Next we fit a LinearRegression-model from Scikit-learn for comparison.
+
+
+
+
+
clf = skl. LinearRegression(). fit(X_train, y_train)
+
+
+Extracting the \( J \)-matrix from both our own method and the Scikit-learn model where we make sure to remove the intercept.
+
+
+
+
+
J_own = omega[1 :]. reshape(L, L)
+J_sk = clf. coef_. reshape(L, L)
+
+
+A way of looking at the coefficients in \( J \) is to plot the matrices as images.
+
+
+
+
+
fig = plt. figure(figsize= (20 , 14 ))
+im = plt. imshow(J_own, ** cmap_args)
+plt. title("Home-made OLS" , fontsize=18 )
+plt. xticks(fontsize=18 )
+plt. yticks(fontsize=18 )
+cb = fig. colorbar(im)
+cb. ax. set_yticklabels(cb. ax. get_yticklabels(), fontsize=18 )
+
+fig = plt. figure(figsize= (20 , 14 ))
+im = plt. imshow(J_sk, ** cmap_args)
+plt. title("LinearRegression from Scikit-learn" , fontsize=18 )
+plt. xticks(fontsize=18 )
+plt. yticks(fontsize=18 )
+cb = fig. colorbar(im)
+cb. ax. set_yticklabels(cb. ax. get_yticklabels(), fontsize=18 )
+plt. show()
+
+
+We can see that our model for the least squares method performes close
+to the benchmark from Scikit-learn. It is interesting to note that OLS
+considers both \( J_{j, j + 1} = -0.5 \) and \( J_{j, j - 1} = -0.5 \) as
+valid matrix elements for \( J \).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/doc/pub/Regression/html/._Regression-bs110.html b/doc/pub/Regression/html/._Regression-bs110.html
new file mode 100644
index 000000000..1994449a9
--- /dev/null
+++ b/doc/pub/Regression/html/._Regression-bs110.html
@@ -0,0 +1,528 @@
+
+
+
+
+
+
+
+Data Analysis and Machine Learning: Linear Regression and more Advanced Regression Analysis
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Ridge regression
+
+
+Having explored the ordinary least squares we move on to ridge
+regression. In ridge regression we include a regularizer . This
+involves a new cost function which leads to a new estimate for the
+weights \( \omega \). This results in a penalized regression problem. The
+cost function is given by
+
+$$
+\begin{align}
+ C(X, \omega; \lambda) = ||X\omega - y||^2 + \lambda ||\omega||^2
+ = (X\omega - y)^T(X\omega - y) + \lambda \omega^T\omega.
+\tag{42}
+\end{align}
+$$
+
+Finding the extremum of this function yields the weights
+
+$$
+\begin{align}
+ \omega(\lambda) = \frac{X^Ty}{X^TX + \lambda} \to \frac{\omega_{\text{LS}}}{1 + \lambda},
+\tag{43}
+\end{align}
+$$
+
+
+where \( \omega_{\text{LS}} \) is the weights from ordinary least
+squares. The last assumption assumes that \( X \) is orthogonal, which it
+is not. We will therefore resort to solving the equation as it stands
+on the left hand side.
+
+
+
+
+
def get_ridge_weights (x: np. ndarray, y: np. ndarray, _lambda: float ) -> np. ndarray:
+ return x. T @ y @ scl. inv(
+ x. T @ x + np. eye(x. shape[1 ], x. shape[1 ]) * _lambda
+ )
+lambda = 0.1
+omega_ridge = get_ridge_weights(X_train_own, y_train, np. array([_lambda]))
+clf_ridge = skl. Ridge(alpha= _lambda). fit(X_train, y_train)
+J_ridge_own = omega_ridge[1 :]. reshape(L, L)
+J_ridge_sk = clf_ridge. coef_. reshape(L, L)
+fig = plt. figure(figsize= (20 , 14 ))
+im = plt. imshow(J_ridge_own, ** cmap_args)
+plt. title("Home-made ridge regression" , fontsize=18 )
+plt. xticks(fontsize=18 )
+plt. yticks(fontsize=18 )
+cb = fig. colorbar(im)
+cb. ax. set_yticklabels(cb. ax. get_yticklabels(), fontsize=18 )
+
+fig = plt. figure(figsize= (20 , 14 ))
+im = plt. imshow(J_ridge_sk, ** cmap_args)
+plt. title("Ridge from Scikit-learn" , fontsize=18 )
+plt. xticks(fontsize=18 )
+plt. yticks(fontsize=18 )
+cb = fig. colorbar(im)
+cb. ax. set_yticklabels(cb. ax. get_yticklabels(), fontsize=18 )
+
+plt. show()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/doc/pub/Regression/html/._Regression-bs111.html b/doc/pub/Regression/html/._Regression-bs111.html
new file mode 100644
index 000000000..0e1b20c58
--- /dev/null
+++ b/doc/pub/Regression/html/._Regression-bs111.html
@@ -0,0 +1,500 @@
+
+
+
+
+
+
+
+Data Analysis and Machine Learning: Linear Regression and more Advanced Regression Analysis
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
LASSO regression
+
+
+In the Least Absolute Shrinkage and Selection Operator (LASSO)-method we get a third cost function.
+$$
+\begin{align}
+ C(X, \omega; \lambda) =
+ ||X\omega - y||^2 + \lambda ||\omega||
+ = (X\omega - y)^T(X\omega - y) + \lambda \sqrt{\omega^T\omega}.
+\tag{44}
+\end{align}
+$$
+
+Finding the extremal point of this cost function is not so straight-forward as in least squares and ridge. We will therefore rely solely on the function ``Lasso`` from Scikit-learn.
+
+
+
+
+
clf_lasso = skl. Lasso(alpha= _lambda). fit(X_train, y_train)
+J_lasso_sk = clf_lasso. coef_. reshape(L, L)
+fig = plt. figure(figsize= (20 , 14 ))
+im = plt. imshow(J_lasso_sk, ** cmap_args)
+plt. title("Lasso from Scikit-learn" , fontsize=18 )
+plt. xticks(fontsize=18 )
+plt. yticks(fontsize=18 )
+cb = fig. colorbar(im)
+cb. ax. set_yticklabels(cb. ax. get_yticklabels(), fontsize=18 )
+
+plt. show()
+
+
+It is quite striking how LASSO breaks the symmetry of the coupling
+constant as opposed to ridge and OLS. We get a sparse solution with
+\( J_{j, j + 1} = -1 \).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/doc/pub/Regression/html/._Regression-bs112.html b/doc/pub/Regression/html/._Regression-bs112.html
new file mode 100644
index 000000000..4c095c632
--- /dev/null
+++ b/doc/pub/Regression/html/._Regression-bs112.html
@@ -0,0 +1,495 @@
+
+
+
+
+
+
+
+Data Analysis and Machine Learning: Linear Regression and more Advanced Regression Analysis
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Performance of the different models
+
+
+In order to judge which model performs best at varying values of \( \lambda \) (for ridge and LASSO) we compute \( R^2 \) which is given by
+
+$$
+\begin{align}
+ R^2 = 1 - \frac{(y - \hat{y})^2}{(y - \bar{y})^2},
+\tag{45}
+\end{align}
+$$
+
+where \( y \) is a vector with the true values of the energy, \( \hat{y} \) is the predicted values of \( y \) from the models and \( \bar{y} \) is the mean of \( \hat{y} \).
+
+
+
+
+
def r_squared (y, y_hat):
+ return 1 - np. sum((y - y_hat) ** 2 ) / np. sum((y - np. mean(y_hat)) ** 2 )
+
+
+This is the same metric used by Scikit-learn for their regression models when scoring.
+
+
+
+
y_hat = clf. predict(X_test)
+r_test = r_squared(y_test, y_hat)
+sk_r_test = clf. score(X_test, y_test)
+
+assert abs (r_test - sk_r_test) < 1e-2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/doc/pub/Regression/html/._Regression-bs113.html b/doc/pub/Regression/html/._Regression-bs113.html
new file mode 100644
index 000000000..f33282cad
--- /dev/null
+++ b/doc/pub/Regression/html/._Regression-bs113.html
@@ -0,0 +1,542 @@
+
+
+
+
+
+
+
+Data Analysis and Machine Learning: Linear Regression and more Advanced Regression Analysis
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Performance as function of the regularization parameter
+
+
+We see how the different models perform for a different set of values for \( \lambda \).
+
+
+
+
+
lambdas = np. logspace(-4 , 5 , 10 )
+
+train_errors = {
+ "ols_own" : np. zeros(lambdas. size),
+ "ols_sk" : np. zeros(lambdas. size),
+ "ridge_own" : np. zeros(lambdas. size),
+ "ridge_sk" : np. zeros(lambdas. size),
+ "lasso_sk" : np. zeros(lambdas. size)
+}
+
+test_errors = {
+ "ols_own" : np. zeros(lambdas. size),
+ "ols_sk" : np. zeros(lambdas. size),
+ "ridge_own" : np. zeros(lambdas. size),
+ "ridge_sk" : np. zeros(lambdas. size),
+ "lasso_sk" : np. zeros(lambdas. size)
+}
+
+plot_counter = 1
+
+fig = plt. figure(figsize= (32 , 54 ))
+
+for i, _lambda in enumerate (tqdm. tqdm(lambdas)):
+ omega = get_ols_weights(X_train_own, y_train)
+ y_hat_train = X_train_own @ omega
+ y_hat_test = X_test_own @ omega
+
+ train_errors["ols_own" ][i] = r_squared(y_train, y_hat_train)
+ test_errors["ols_own" ][i] = r_squared(y_test, y_hat_test)
+
+ plt. subplot(10 , 5 , plot_counter)
+ plt. imshow(omega[1 :]. reshape(L, L), ** cmap_args)
+ plt. title("Home made OLS" )
+ plot_counter += 1
+
+ omega = get_ridge_weights(X_train_own, y_train, _lambda)
+ y_hat_train = X_train_own @ omega
+ y_hat_test = X_test_own @ omega
+
+ train_errors["ridge_own" ][i] = r_squared(y_train, y_hat_train)
+ test_errors["ridge_own" ][i] = r_squared(y_test, y_hat_test)
+
+ plt. subplot(10 , 5 , plot_counter)
+ plt. imshow(omega[1 :]. reshape(L, L), ** cmap_args)
+ plt. title(r"Home made ridge, $\lambda = %.4f $" % _lambda)
+ plot_counter += 1
+
+ for key, method in zip (
+ ["ols_sk" , "ridge_sk" , "lasso_sk" ],
+ [skl. LinearRegression(), skl. Ridge(alpha= _lambda), skl. Lasso(alpha= _lambda)]
+ ):
+ method = method. fit(X_train, y_train)
+
+ train_errors[key][i] = method. score(X_train, y_train)
+ test_errors[key][i] = method. score(X_test, y_test)
+
+ omega = method. coef_. reshape(L, L)
+
+ plt. subplot(10 , 5 , plot_counter)
+ plt. imshow(omega, ** cmap_args)
+ plt. title(r" %s , $\lambda = %.4f $" % (key, _lambda))
+ plot_counter += 1
+
+plt. show()
+
+
+We can see that LASSO quite fast reaches a good solution for low
+values of \( \lambda \), but will "wither" when we increase \( \lambda \) too
+much. Ridge is more stable over a larger range of values for
+\( \lambda \), but eventually also fades away.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/doc/pub/Regression/html/._Regression-bs114.html b/doc/pub/Regression/html/._Regression-bs114.html
new file mode 100644
index 000000000..9294abbed
--- /dev/null
+++ b/doc/pub/Regression/html/._Regression-bs114.html
@@ -0,0 +1,514 @@
+
+
+
+
+
+
+
+Data Analysis and Machine Learning: Linear Regression and more Advanced Regression Analysis
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Finding the optimal value of \( \lambda \)
+
+
+To determine which value of \( \lambda \) is best we plot the accuracy of
+the models when predicting the training and the testing set. We expect
+the accuracy of the training set to be quite good, but if the accuracy
+of the testing set is much lower this tells us that we might be
+subject to an overfit model. The ideal scenario is an accuracy on the
+testing set that is close to the accuracy of the training set.
+
+
+
+
+
fig = plt. figure(figsize= (20 , 14 ))
+
+colors = {
+ "ols_own" : "b" ,
+ "ridge_own" : "g" ,
+ "ols_sk" : "r" ,
+ "ridge_sk" : "y" ,
+ "lasso_sk" : "c"
+}
+
+for key in train_errors:
+ plt. semilogx(
+ lambdas,
+ train_errors[key],
+ colors[key],
+ label= "Train {0}" . format(key),
+ linewidth=4.0
+ )
+
+for key in test_errors:
+ plt. semilogx(
+ lambdas,
+ test_errors[key],
+ colors[key] + "--" ,
+ label= "Test {0}" . format(key),
+ linewidth=4.0
+ )
+#plt.semilogx(lambdas, train_errors["ols_own"], label="Train (OLS own)")
+#plt.semilogx(lambdas, test_errors["ols_own"], label="Test (OLS own)")
+
+plt. legend(loc= "best" , fontsize=18 )
+plt. xlabel(r"$\lambda$" , fontsize=18 )
+plt. ylabel(r"$R^2$" , fontsize=18 )
+plt. tick_params(labelsize=18 )
+plt. show()
+
+
+From the above figure we can see that LASSO with \( \lambda = 10^{-2} \)
+achieve a very good accuracy on the test set. This by far surpases the
+other models for all values of \( \lambda \).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/doc/pub/Regression/html/Regression-bs.html b/doc/pub/Regression/html/Regression-bs.html
index 833e9dec8..e6ce300e7 100644
--- a/doc/pub/Regression/html/Regression-bs.html
+++ b/doc/pub/Regression/html/Regression-bs.html
@@ -225,7 +225,34 @@ Automatically generated HTML file from DocOnce source
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -365,6 +392,18 @@ MathJax.Hub.Config({
The bias
The variance
Summing up
+ The one-dimensional Ising model, project 2
+ Example: The one-dimensional Ising model
+ Reformulating the problem to suit regression
+ Linear regression
+ Ordinary least squares
+ Singular Value decomposition
+ Fitting with scikit-learn
+ Ridge regression
+ LASSO regression
+ Performance of the different models
+ Performance as function of the regularization parameter
+ Finding the optimal value of \( \lambda \)
@@ -399,7 +438,7 @@ MathJax.Hub.Config({
[2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University
-
Sep 25, 2018
+Oct 11, 2018
@@ -423,7 +462,7 @@ MathJax.Hub.Config({
9
10
...
- 103
+ 115
»
diff --git a/doc/pub/Regression/html/Regression-reveal.html b/doc/pub/Regression/html/Regression-reveal.html
index c5cf28468..1959fd9b9 100644
--- a/doc/pub/Regression/html/Regression-reveal.html
+++ b/doc/pub/Regression/html/Regression-reveal.html
@@ -148,7 +148,7 @@ MathJax.Hub.Config({
[2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University
-
Sep 25, 2018
+Oct 11, 2018
@@ -3541,6 +3541,624 @@ flexible statistical methods have higher variance.
+
+The one-dimensional Ising model, project 2
+
+
+The one-dimensional Ising model with nearest neighbor interaction, no external field and a constant coupling constant \( J \) is given by
+
+
+$$
+\begin{align}
+ H = -J \sum_{k}^L s_k s_{k + 1},
+\tag{30}
+\end{align}
+$$
+
+
+where \( s_i \in \{-1, 1\} \) and \( s_{N + 1} = s_1 \). The number of spins in the system is determined by \( L \). For the low temperature limit there is no phase transition.
+
+
+We will look at a system of \( L = 40 \) spins with a coupling constant of \( J = 1 \). To get enough training data we will generate 10000 states with their respective energies.
+
+
+
+
+
L = 40
+n = int (1e4 )
+
+spins = np.random.choice([-1 , 1 ], size=(n, L))
+J = 1.0
+
+energies = np.zeros(n)
+
+for i in range (n):
+ energies[i] = - J * np.dot(spins[i], np.roll(spins[i], 1 ))
+
+
+
+
+
+Example: The one-dimensional Ising model
+
+
+Here we use linear (ordinary least squares), ridge and LASSO
+regression to predict the energy in the nearest neighbor
+one-dimensional Ising model on a ring, i.e., the endpoints wrap
+around. We will use the linear regression models to fit a value for
+the coupling constant to achieve this.
+
+
+
+
import numpy as np
+import matplotlib.pyplot as plt
+from mpl_toolkits.axes_grid1 import make_axes_locatable
+import seaborn as sns
+import scipy.linalg as scl
+from sklearn.model_selection import train_test_split
+import sklearn.linear_model as skl
+import tqdm
+sns.set(color_codes=True )
+cmap_args=dict (vmin=-1. , vmax=1. , cmap='seismic' )
+
+
+
+
+
+Reformulating the problem to suit regression
+
+
+A more general form for the one-dimensional Ising model is
+
+
+$$
+\begin{align}
+ H = - \sum_j^L \sum_k^L s_j s_k J_{jk}.
+\tag{31}
+\end{align}
+$$
+
+
+
+Here we allow for interactions beyond the nearest neighbors and a more
+adaptive coupling matrix. This latter expression can be formulated as
+a matrix-product on the form
+
+$$
+\begin{align}
+ H = X J,
+\tag{32}
+\end{align}
+$$
+
+
+
+where \( X_{jk} = s_j s_k \) and \( J \) is the matrix consisting of the
+elements \( -J_{jk} \). This form of writing the energy fits perfectly
+with the form utilized in linear regression, viz.
+
+$$
+\begin{align}
+ y = X\omega + \epsilon,
+\tag{33}
+\end{align}
+$$
+
+
+
+
+
+
X = np.zeros((n, L ** 2 ))
+for i in range (n):
+ X[i] = np.outer(spins[i], spins[i]).ravel()
+y = energies
+X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.96 )
+
+X_train_own = np.concatenate(
+ (np.ones(len (X_train))[:, np.newaxis], X_train),
+ axis=1
+)
+
+X_test_own = np.concatenate(
+ (np.ones(len (X_test))[:, np.newaxis], X_test),
+ axis=1
+)
+
+
+
+
+
+Linear regression
+
+
+The problem at hand is to try to fit the equation
+
+$$
+\begin{align}
+ y = f(x) + \epsilon,
+\tag{34}
+\end{align}
+$$
+
+
+
+where \( f(x) \) is some unknown function of the data \( x \) and \( \epsilon \)
+is normally distributed with mean zero noise with standard deviation
+\( \sigma_{\epsilon} \). Our job is to try to find a predictor which
+estimates the function \( f(x) \). In linear regression we assume that we
+can formulate the problem as
+
+
+$$
+\begin{align}
+ y = X\omega + \epsilon,
+\tag{35}
+\end{align}
+$$
+
+
+
+where \( X \) and \( \omega \) are now matrices. Our job at hand is now to
+find a cost function \( C \), which we wish to minimize in order to find
+the best estimate of \( \omega \).
+
+
+
+
+Ordinary least squares
+
+
+In the ordinary least squares method we choose the cost function
+
+$$
+\begin{align}
+ C(X, \omega) = ||X\omega - y||^2
+ = (X\omega - y)^T(X\omega - y)
+\tag{36}
+\end{align}
+$$
+
+
+We then find the extremal point of \( C \) by taking the derivative with respect to \( \omega \) and setting it to zero, i.e.,
+
+
+$$
+\begin{align}
+ \dfrac{\mathrm{d}C}{\mathrm{d}\omega}
+ = 0.
+\tag{37}
+\end{align}
+$$
+
+
+This yields the expression for \( \omega \) to be
+
+$$
+\begin{align}
+ \omega = \frac{X^T y}{X^T X},
+\tag{38}
+\end{align}
+$$
+
+
+
+which immediately imposes some requirements on \( X \) as there must exist
+an inverse of \( X^T X \). If the expression we are modelling contains an
+intercept, i.e., a constant expression we must make sure that the
+first column of \( X \) consists of \( 1 \).
+
+
+
+
+
def get_ols_weights_naive (x: np.ndarray, y: np.ndarray) -> np.ndarray:
+ return scl.inv(x.T @ x) @ (x.T @ y)
+omega = get_ols_weights_naive(X_train_own, y_train)
+
+
+
+
+
+Singular Value decomposition
+Doing the inversion directly turns out to be a bad idea as the matrix
+\( X^TX \) is singular. An alternative approach is to use the singular
+value decomposition . Using the definition of the Moore-Penrose
+pseudoinverse we can write the equation for \( \omega \) as
+
+
+$$
+\begin{align}
+ \omega = X^{+}y,
+\tag{39}
+\end{align}
+$$
+
+
+where the pseudoinverse of \( X \) is given by
+
+$$
+\begin{align}
+ X^{+} = \frac{X^T}{X^T X}.
+\tag{40}
+\end{align}
+$$
+
+
+
+Using singular value decomposition we have that \( X = U\Sigma V^T \),
+where \( X^{+} = V\Sigma^{+} U^T \). This reduces the equation for
+\( \omega \) to
+
+$$
+\begin{align}
+ \omega = V\Sigma^{+} U^T y.
+\tag{41}
+\end{align}
+$$
+
+
+
+Note that solving this equation by actually doing the pseudoinverse
+(which is what we will do) is not a good idea as this operation scales
+as \( \mathcal{O}(n^3) \), where \( n \) is the number of elements in a
+general matrix. Instead, doing \( QR \)-factorization and solving the
+linear system as an equation would reduce this down to
+\( \mathcal{O}(n^2) \) operations.
+
+
+
+
+
def get_ols_weights (x: np.ndarray, y: np.ndarray) -> np.ndarray:
+ u, s, v = scl.svd(x)
+ return v.T @ scl.pinv(scl.diagsvd(s, u.shape[0 ], v.shape[0 ])) @ u.T @ y
+
+
+Before passing in the data to the function we append a column with ones to the training data.
+
+
+
+
+
omega = get_ols_weights(X_train_own,y_train)
+
+
+
+
+
+Fitting with scikit-learn
+
+
+Next we fit a LinearRegression-model from Scikit-learn for comparison.
+
+
+
+
+
clf = skl.LinearRegression().fit(X_train, y_train)
+
+
+Extracting the \( J \)-matrix from both our own method and the Scikit-learn model where we make sure to remove the intercept.
+
+
+
+
+
J_own = omega[1 :].reshape(L, L)
+J_sk = clf.coef_.reshape(L, L)
+
+
+A way of looking at the coefficients in \( J \) is to plot the matrices as images.
+
+
+
+
+
fig = plt.figure(figsize=(20 , 14 ))
+im = plt.imshow(J_own, **cmap_args)
+plt.title("Home-made OLS" , fontsize=18 )
+plt.xticks(fontsize=18 )
+plt.yticks(fontsize=18 )
+cb = fig.colorbar(im)
+cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18 )
+
+fig = plt.figure(figsize=(20 , 14 ))
+im = plt.imshow(J_sk, **cmap_args)
+plt.title("LinearRegression from Scikit-learn" , fontsize=18 )
+plt.xticks(fontsize=18 )
+plt.yticks(fontsize=18 )
+cb = fig.colorbar(im)
+cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18 )
+plt.show()
+
+
+We can see that our model for the least squares method performes close
+to the benchmark from Scikit-learn. It is interesting to note that OLS
+considers both \( J_{j, j + 1} = -0.5 \) and \( J_{j, j - 1} = -0.5 \) as
+valid matrix elements for \( J \).
+
+
+
+
+Ridge regression
+
+
+Having explored the ordinary least squares we move on to ridge
+regression. In ridge regression we include a regularizer . This
+involves a new cost function which leads to a new estimate for the
+weights \( \omega \). This results in a penalized regression problem. The
+cost function is given by
+
+
+$$
+\begin{align}
+ C(X, \omega; \lambda) = ||X\omega - y||^2 + \lambda ||\omega||^2
+ = (X\omega - y)^T(X\omega - y) + \lambda \omega^T\omega.
+\tag{42}
+\end{align}
+$$
+
+
+Finding the extremum of this function yields the weights
+
+
+$$
+\begin{align}
+ \omega(\lambda) = \frac{X^Ty}{X^TX + \lambda} \to \frac{\omega_{\text{LS}}}{1 + \lambda},
+\tag{43}
+\end{align}
+$$
+
+
+
+where \( \omega_{\text{LS}} \) is the weights from ordinary least
+squares. The last assumption assumes that \( X \) is orthogonal, which it
+is not. We will therefore resort to solving the equation as it stands
+on the left hand side.
+
+
+
+
+
def get_ridge_weights (x: np.ndarray, y: np.ndarray, _lambda: float ) -> np.ndarray:
+ return x.T @ y @ scl.inv(
+ x.T @ x + np.eye(x.shape[1 ], x.shape[1 ]) * _lambda
+ )
+lambda = 0.1
+omega_ridge = get_ridge_weights(X_train_own, y_train, np.array([_lambda]))
+clf_ridge = skl.Ridge(alpha=_lambda).fit(X_train, y_train)
+J_ridge_own = omega_ridge[1 :].reshape(L, L)
+J_ridge_sk = clf_ridge.coef_.reshape(L, L)
+fig = plt.figure(figsize=(20 , 14 ))
+im = plt.imshow(J_ridge_own, **cmap_args)
+plt.title("Home-made ridge regression" , fontsize=18 )
+plt.xticks(fontsize=18 )
+plt.yticks(fontsize=18 )
+cb = fig.colorbar(im)
+cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18 )
+
+fig = plt.figure(figsize=(20 , 14 ))
+im = plt.imshow(J_ridge_sk, **cmap_args)
+plt.title("Ridge from Scikit-learn" , fontsize=18 )
+plt.xticks(fontsize=18 )
+plt.yticks(fontsize=18 )
+cb = fig.colorbar(im)
+cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18 )
+
+plt.show()
+
+
+
+
+
+LASSO regression
+
+
+In the Least Absolute Shrinkage and Selection Operator (LASSO)-method we get a third cost function.
+
+$$
+\begin{align}
+ C(X, \omega; \lambda) =
+ ||X\omega - y||^2 + \lambda ||\omega||
+ = (X\omega - y)^T(X\omega - y) + \lambda \sqrt{\omega^T\omega}.
+\tag{44}
+\end{align}
+$$
+
+
+Finding the extremal point of this cost function is not so straight-forward as in least squares and ridge. We will therefore rely solely on the function ``Lasso`` from Scikit-learn.
+
+
+
+
+
clf_lasso = skl.Lasso(alpha=_lambda).fit(X_train, y_train)
+J_lasso_sk = clf_lasso.coef_.reshape(L, L)
+fig = plt.figure(figsize=(20 , 14 ))
+im = plt.imshow(J_lasso_sk, **cmap_args)
+plt.title("Lasso from Scikit-learn" , fontsize=18 )
+plt.xticks(fontsize=18 )
+plt.yticks(fontsize=18 )
+cb = fig.colorbar(im)
+cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18 )
+
+plt.show()
+
+
+It is quite striking how LASSO breaks the symmetry of the coupling
+constant as opposed to ridge and OLS. We get a sparse solution with
+\( J_{j, j + 1} = -1 \).
+
+
+
+
+Performance of the different models
+
+
+In order to judge which model performs best at varying values of \( \lambda \) (for ridge and LASSO) we compute \( R^2 \) which is given by
+
+
+$$
+\begin{align}
+ R^2 = 1 - \frac{(y - \hat{y})^2}{(y - \bar{y})^2},
+\tag{45}
+\end{align}
+$$
+
+
+where \( y \) is a vector with the true values of the energy, \( \hat{y} \) is the predicted values of \( y \) from the models and \( \bar{y} \) is the mean of \( \hat{y} \).
+
+
+
+
+
def r_squared (y, y_hat):
+ return 1 - np.sum((y - y_hat) ** 2 ) / np.sum((y - np.mean(y_hat)) ** 2 )
+
+
+This is the same metric used by Scikit-learn for their regression models when scoring.
+
+
+
+
y_hat = clf.predict(X_test)
+r_test = r_squared(y_test, y_hat)
+sk_r_test = clf.score(X_test, y_test)
+
+assert abs (r_test - sk_r_test) < 1e-2
+
+
+
+
+
+Performance as function of the regularization parameter
+
+
+We see how the different models perform for a different set of values for \( \lambda \).
+
+
+
+
+
lambdas = np.logspace(-4 , 5 , 10 )
+
+train_errors = {
+ "ols_own" : np.zeros(lambdas.size),
+ "ols_sk" : np.zeros(lambdas.size),
+ "ridge_own" : np.zeros(lambdas.size),
+ "ridge_sk" : np.zeros(lambdas.size),
+ "lasso_sk" : np.zeros(lambdas.size)
+}
+
+test_errors = {
+ "ols_own" : np.zeros(lambdas.size),
+ "ols_sk" : np.zeros(lambdas.size),
+ "ridge_own" : np.zeros(lambdas.size),
+ "ridge_sk" : np.zeros(lambdas.size),
+ "lasso_sk" : np.zeros(lambdas.size)
+}
+
+plot_counter = 1
+
+fig = plt.figure(figsize=(32 , 54 ))
+
+for i, _lambda in enumerate (tqdm.tqdm(lambdas)):
+ omega = get_ols_weights(X_train_own, y_train)
+ y_hat_train = X_train_own @ omega
+ y_hat_test = X_test_own @ omega
+
+ train_errors["ols_own" ][i] = r_squared(y_train, y_hat_train)
+ test_errors["ols_own" ][i] = r_squared(y_test, y_hat_test)
+
+ plt.subplot(10 , 5 , plot_counter)
+ plt.imshow(omega[1 :].reshape(L, L), **cmap_args)
+ plt.title("Home made OLS" )
+ plot_counter += 1
+
+ omega = get_ridge_weights(X_train_own, y_train, _lambda)
+ y_hat_train = X_train_own @ omega
+ y_hat_test = X_test_own @ omega
+
+ train_errors["ridge_own" ][i] = r_squared(y_train, y_hat_train)
+ test_errors["ridge_own" ][i] = r_squared(y_test, y_hat_test)
+
+ plt.subplot(10 , 5 , plot_counter)
+ plt.imshow(omega[1 :].reshape(L, L), **cmap_args)
+ plt.title(r"Home made ridge, $\lambda = %.4f$" % _lambda)
+ plot_counter += 1
+
+ for key, method in zip (
+ ["ols_sk" , "ridge_sk" , "lasso_sk" ],
+ [skl.LinearRegression(), skl.Ridge(alpha=_lambda), skl.Lasso(alpha=_lambda)]
+ ):
+ method = method.fit(X_train, y_train)
+
+ train_errors[key][i] = method.score(X_train, y_train)
+ test_errors[key][i] = method.score(X_test, y_test)
+
+ omega = method.coef_.reshape(L, L)
+
+ plt.subplot(10 , 5 , plot_counter)
+ plt.imshow(omega, **cmap_args)
+ plt.title(r"%s, $\lambda = %.4f$" % (key, _lambda))
+ plot_counter += 1
+
+plt.show()
+
+
+We can see that LASSO quite fast reaches a good solution for low
+values of \( \lambda \), but will "wither" when we increase \( \lambda \) too
+much. Ridge is more stable over a larger range of values for
+\( \lambda \), but eventually also fades away.
+
+
+
+
+Finding the optimal value of \( \lambda \)
+
+
+To determine which value of \( \lambda \) is best we plot the accuracy of
+the models when predicting the training and the testing set. We expect
+the accuracy of the training set to be quite good, but if the accuracy
+of the testing set is much lower this tells us that we might be
+subject to an overfit model. The ideal scenario is an accuracy on the
+testing set that is close to the accuracy of the training set.
+
+
+
+
+
fig = plt.figure(figsize=(20 , 14 ))
+
+colors = {
+ "ols_own" : "b" ,
+ "ridge_own" : "g" ,
+ "ols_sk" : "r" ,
+ "ridge_sk" : "y" ,
+ "lasso_sk" : "c"
+}
+
+for key in train_errors:
+ plt.semilogx(
+ lambdas,
+ train_errors[key],
+ colors[key],
+ label="Train {0}" .format(key),
+ linewidth=4.0
+ )
+
+for key in test_errors:
+ plt.semilogx(
+ lambdas,
+ test_errors[key],
+ colors[key] + "--" ,
+ label="Test {0}" .format(key),
+ linewidth=4.0
+ )
+#plt.semilogx(lambdas, train_errors["ols_own"], label="Train (OLS own)")
+#plt.semilogx(lambdas, test_errors["ols_own"], label="Test (OLS own)")
+
+plt.legend(loc="best" , fontsize=18 )
+plt.xlabel(r"$\lambda$" , fontsize=18 )
+plt.ylabel(r"$R^2$" , fontsize=18 )
+plt.tick_params(labelsize=18 )
+plt.show()
+
+
+From the above figure we can see that LASSO with \( \lambda = 10^{-2} \)
+achieve a very good accuracy on the test set. This by far surpases the
+other models for all values of \( \lambda \).
+
+
+
diff --git a/doc/pub/Regression/html/Regression-solarized.html b/doc/pub/Regression/html/Regression-solarized.html
index df9b24537..95341ec36 100644
--- a/doc/pub/Regression/html/Regression-solarized.html
+++ b/doc/pub/Regression/html/Regression-solarized.html
@@ -245,7 +245,34 @@ div { text-align: justify; text-justify: inter-word; }
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -287,7 +314,7 @@ MathJax.Hub.Config({
[2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University
-
Sep 25, 2018
+Oct 11, 2018
@@ -3472,6 +3499,585 @@ 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.
+
+
+
+
The one-dimensional Ising model, project 2
+
+
+The one-dimensional Ising model with nearest neighbor interaction, no external field and a constant coupling constant \( J \) is given by
+
+$$
+\begin{align}
+ H = -J \sum_{k}^L s_k s_{k + 1},
+\label{_auto19}
+\end{align}
+$$
+
+where \( s_i \in \{-1, 1\} \) and \( s_{N + 1} = s_1 \). The number of spins in the system is determined by \( L \). For the low temperature limit there is no phase transition.
+
+
+We will look at a system of \( L = 40 \) spins with a coupling constant of \( J = 1 \). To get enough training data we will generate 10000 states with their respective energies.
+
+
+
+
+
L = 40
+n = int (1e4 )
+
+spins = np.random.choice([-1 , 1 ], size=(n, L))
+J = 1.0
+
+energies = np.zeros(n)
+
+for i in range (n):
+ energies[i] = - J * np.dot(spins[i], np.roll(spins[i], 1 ))
+
+
+
+
+
Example: The one-dimensional Ising model
+
+
+Here we use linear (ordinary least squares), ridge and LASSO
+regression to predict the energy in the nearest neighbor
+one-dimensional Ising model on a ring, i.e., the endpoints wrap
+around. We will use the linear regression models to fit a value for
+the coupling constant to achieve this.
+
+
+
+
import numpy as np
+import matplotlib.pyplot as plt
+from mpl_toolkits.axes_grid1 import make_axes_locatable
+import seaborn as sns
+import scipy.linalg as scl
+from sklearn.model_selection import train_test_split
+import sklearn.linear_model as skl
+import tqdm
+sns.set(color_codes=True )
+cmap_args=dict (vmin=-1. , vmax=1. , cmap='seismic' )
+
+
+
+
+
Reformulating the problem to suit regression
+
+
+A more general form for the one-dimensional Ising model is
+
+$$
+\begin{align}
+ H = - \sum_j^L \sum_k^L s_j s_k J_{jk}.
+\label{_auto20}
+\end{align}
+$$
+
+
+Here we allow for interactions beyond the nearest neighbors and a more
+adaptive coupling matrix. This latter expression can be formulated as
+a matrix-product on the form
+$$
+\begin{align}
+ H = X J,
+\label{_auto21}
+\end{align}
+$$
+
+
+where \( X_{jk} = s_j s_k \) and \( J \) is the matrix consisting of the
+elements \( -J_{jk} \). This form of writing the energy fits perfectly
+with the form utilized in linear regression, viz.
+$$
+\begin{align}
+ y = X\omega + \epsilon,
+\label{_auto22}
+\end{align}
+$$
+
+
+
+
+
X = np.zeros((n, L ** 2 ))
+for i in range (n):
+ X[i] = np.outer(spins[i], spins[i]).ravel()
+y = energies
+X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.96 )
+
+X_train_own = np.concatenate(
+ (np.ones(len (X_train))[:, np.newaxis], X_train),
+ axis=1
+)
+
+X_test_own = np.concatenate(
+ (np.ones(len (X_test))[:, np.newaxis], X_test),
+ axis=1
+)
+
+
+
+
+
Linear regression
+
+
+The problem at hand is to try to fit the equation
+$$
+\begin{align}
+ y = f(x) + \epsilon,
+\label{_auto23}
+\end{align}
+$$
+
+
+where \( f(x) \) is some unknown function of the data \( x \) and \( \epsilon \)
+is normally distributed with mean zero noise with standard deviation
+\( \sigma_{\epsilon} \). Our job is to try to find a predictor which
+estimates the function \( f(x) \). In linear regression we assume that we
+can formulate the problem as
+
+$$
+\begin{align}
+ y = X\omega + \epsilon,
+\label{_auto24}
+\end{align}
+$$
+
+
+where \( X \) and \( \omega \) are now matrices. Our job at hand is now to
+find a cost function \( C \), which we wish to minimize in order to find
+the best estimate of \( \omega \).
+
+
+
+
+
Ordinary least squares
+
+
+In the ordinary least squares method we choose the cost function
+$$
+\begin{align}
+ C(X, \omega) = ||X\omega - y||^2
+ = (X\omega - y)^T(X\omega - y)
+\label{_auto25}
+\end{align}
+$$
+
+We then find the extremal point of \( C \) by taking the derivative with respect to \( \omega \) and setting it to zero, i.e.,
+
+$$
+\begin{align}
+ \dfrac{\mathrm{d}C}{\mathrm{d}\omega}
+ = 0.
+\label{_auto26}
+\end{align}
+$$
+
+This yields the expression for \( \omega \) to be
+$$
+\begin{align}
+ \omega = \frac{X^T y}{X^T X},
+\label{_auto27}
+\end{align}
+$$
+
+
+which immediately imposes some requirements on \( X \) as there must exist
+an inverse of \( X^T X \). If the expression we are modelling contains an
+intercept, i.e., a constant expression we must make sure that the
+first column of \( X \) consists of \( 1 \).
+
+
+
+
+
def get_ols_weights_naive (x: np.ndarray, y: np.ndarray) -> np.ndarray:
+ return scl.inv(x.T @ x) @ (x.T @ y)
+omega = get_ols_weights_naive(X_train_own, y_train)
+
+
+
+
+
Singular Value decomposition
+Doing the inversion directly turns out to be a bad idea as the matrix
+\( X^TX \) is singular. An alternative approach is to use the singular
+value decomposition . Using the definition of the Moore-Penrose
+pseudoinverse we can write the equation for \( \omega \) as
+
+$$
+\begin{align}
+ \omega = X^{+}y,
+\label{_auto28}
+\end{align}
+$$
+
+where the pseudoinverse of \( X \) is given by
+$$
+\begin{align}
+ X^{+} = \frac{X^T}{X^T X}.
+\label{_auto29}
+\end{align}
+$$
+
+
+Using singular value decomposition we have that \( X = U\Sigma V^T \),
+where \( X^{+} = V\Sigma^{+} U^T \). This reduces the equation for
+\( \omega \) to
+$$
+\begin{align}
+ \omega = V\Sigma^{+} U^T y.
+\label{_auto30}
+\end{align}
+$$
+
+
+Note that solving this equation by actually doing the pseudoinverse
+(which is what we will do) is not a good idea as this operation scales
+as \( \mathcal{O}(n^3) \), where \( n \) is the number of elements in a
+general matrix. Instead, doing \( QR \)-factorization and solving the
+linear system as an equation would reduce this down to
+\( \mathcal{O}(n^2) \) operations.
+
+
+
+
+
def get_ols_weights (x: np.ndarray, y: np.ndarray) -> np.ndarray:
+ u, s, v = scl.svd(x)
+ return v.T @ scl.pinv(scl.diagsvd(s, u.shape[0 ], v.shape[0 ])) @ u.T @ y
+
+
+Before passing in the data to the function we append a column with ones to the training data.
+
+
+
+
+
omega = get_ols_weights(X_train_own,y_train)
+
+
+
+
+
Fitting with scikit-learn
+
+
+Next we fit a LinearRegression-model from Scikit-learn for comparison.
+
+
+
+
+
clf = skl.LinearRegression().fit(X_train, y_train)
+
+
+Extracting the \( J \)-matrix from both our own method and the Scikit-learn model where we make sure to remove the intercept.
+
+
+
+
+
J_own = omega[1 :].reshape(L, L)
+J_sk = clf.coef_.reshape(L, L)
+
+
+A way of looking at the coefficients in \( J \) is to plot the matrices as images.
+
+
+
+
+
fig = plt.figure(figsize=(20 , 14 ))
+im = plt.imshow(J_own, **cmap_args)
+plt.title("Home-made OLS" , fontsize=18 )
+plt.xticks(fontsize=18 )
+plt.yticks(fontsize=18 )
+cb = fig.colorbar(im)
+cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18 )
+
+fig = plt.figure(figsize=(20 , 14 ))
+im = plt.imshow(J_sk, **cmap_args)
+plt.title("LinearRegression from Scikit-learn" , fontsize=18 )
+plt.xticks(fontsize=18 )
+plt.yticks(fontsize=18 )
+cb = fig.colorbar(im)
+cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18 )
+plt.show()
+
+
+We can see that our model for the least squares method performes close
+to the benchmark from Scikit-learn. It is interesting to note that OLS
+considers both \( J_{j, j + 1} = -0.5 \) and \( J_{j, j - 1} = -0.5 \) as
+valid matrix elements for \( J \).
+
+
+
+
+
Ridge regression
+
+
+Having explored the ordinary least squares we move on to ridge
+regression. In ridge regression we include a regularizer . This
+involves a new cost function which leads to a new estimate for the
+weights \( \omega \). This results in a penalized regression problem. The
+cost function is given by
+
+$$
+\begin{align}
+ C(X, \omega; \lambda) = ||X\omega - y||^2 + \lambda ||\omega||^2
+ = (X\omega - y)^T(X\omega - y) + \lambda \omega^T\omega.
+\label{_auto31}
+\end{align}
+$$
+
+Finding the extremum of this function yields the weights
+
+$$
+\begin{align}
+ \omega(\lambda) = \frac{X^Ty}{X^TX + \lambda} \to \frac{\omega_{\text{LS}}}{1 + \lambda},
+\label{_auto32}
+\end{align}
+$$
+
+
+where \( \omega_{\text{LS}} \) is the weights from ordinary least
+squares. The last assumption assumes that \( X \) is orthogonal, which it
+is not. We will therefore resort to solving the equation as it stands
+on the left hand side.
+
+
+
+
+
def get_ridge_weights (x: np.ndarray, y: np.ndarray, _lambda: float ) -> np.ndarray:
+ return x.T @ y @ scl.inv(
+ x.T @ x + np.eye(x.shape[1 ], x.shape[1 ]) * _lambda
+ )
+lambda = 0.1
+omega_ridge = get_ridge_weights(X_train_own, y_train, np.array([_lambda]))
+clf_ridge = skl.Ridge(alpha=_lambda).fit(X_train, y_train)
+J_ridge_own = omega_ridge[1 :].reshape(L, L)
+J_ridge_sk = clf_ridge.coef_.reshape(L, L)
+fig = plt.figure(figsize=(20 , 14 ))
+im = plt.imshow(J_ridge_own, **cmap_args)
+plt.title("Home-made ridge regression" , fontsize=18 )
+plt.xticks(fontsize=18 )
+plt.yticks(fontsize=18 )
+cb = fig.colorbar(im)
+cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18 )
+
+fig = plt.figure(figsize=(20 , 14 ))
+im = plt.imshow(J_ridge_sk, **cmap_args)
+plt.title("Ridge from Scikit-learn" , fontsize=18 )
+plt.xticks(fontsize=18 )
+plt.yticks(fontsize=18 )
+cb = fig.colorbar(im)
+cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18 )
+
+plt.show()
+
+
+
+
+
LASSO regression
+
+
+In the Least Absolute Shrinkage and Selection Operator (LASSO)-method we get a third cost function.
+$$
+\begin{align}
+ C(X, \omega; \lambda) =
+ ||X\omega - y||^2 + \lambda ||\omega||
+ = (X\omega - y)^T(X\omega - y) + \lambda \sqrt{\omega^T\omega}.
+\label{_auto33}
+\end{align}
+$$
+
+Finding the extremal point of this cost function is not so straight-forward as in least squares and ridge. We will therefore rely solely on the function ``Lasso`` from Scikit-learn.
+
+
+
+
+
clf_lasso = skl.Lasso(alpha=_lambda).fit(X_train, y_train)
+J_lasso_sk = clf_lasso.coef_.reshape(L, L)
+fig = plt.figure(figsize=(20 , 14 ))
+im = plt.imshow(J_lasso_sk, **cmap_args)
+plt.title("Lasso from Scikit-learn" , fontsize=18 )
+plt.xticks(fontsize=18 )
+plt.yticks(fontsize=18 )
+cb = fig.colorbar(im)
+cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18 )
+
+plt.show()
+
+
+It is quite striking how LASSO breaks the symmetry of the coupling
+constant as opposed to ridge and OLS. We get a sparse solution with
+\( J_{j, j + 1} = -1 \).
+
+
+
+
+
Performance of the different models
+
+
+In order to judge which model performs best at varying values of \( \lambda \) (for ridge and LASSO) we compute \( R^2 \) which is given by
+
+$$
+\begin{align}
+ R^2 = 1 - \frac{(y - \hat{y})^2}{(y - \bar{y})^2},
+\label{_auto34}
+\end{align}
+$$
+
+where \( y \) is a vector with the true values of the energy, \( \hat{y} \) is the predicted values of \( y \) from the models and \( \bar{y} \) is the mean of \( \hat{y} \).
+
+
+
+
+
def r_squared (y, y_hat):
+ return 1 - np.sum((y - y_hat) ** 2 ) / np.sum((y - np.mean(y_hat)) ** 2 )
+
+
+This is the same metric used by Scikit-learn for their regression models when scoring.
+
+
+
+
y_hat = clf.predict(X_test)
+r_test = r_squared(y_test, y_hat)
+sk_r_test = clf.score(X_test, y_test)
+
+assert abs (r_test - sk_r_test) < 1e-2
+
+
+
+
+
Performance as function of the regularization parameter
+
+
+We see how the different models perform for a different set of values for \( \lambda \).
+
+
+
+
+
lambdas = np.logspace(-4 , 5 , 10 )
+
+train_errors = {
+ "ols_own" : np.zeros(lambdas.size),
+ "ols_sk" : np.zeros(lambdas.size),
+ "ridge_own" : np.zeros(lambdas.size),
+ "ridge_sk" : np.zeros(lambdas.size),
+ "lasso_sk" : np.zeros(lambdas.size)
+}
+
+test_errors = {
+ "ols_own" : np.zeros(lambdas.size),
+ "ols_sk" : np.zeros(lambdas.size),
+ "ridge_own" : np.zeros(lambdas.size),
+ "ridge_sk" : np.zeros(lambdas.size),
+ "lasso_sk" : np.zeros(lambdas.size)
+}
+
+plot_counter = 1
+
+fig = plt.figure(figsize=(32 , 54 ))
+
+for i, _lambda in enumerate (tqdm.tqdm(lambdas)):
+ omega = get_ols_weights(X_train_own, y_train)
+ y_hat_train = X_train_own @ omega
+ y_hat_test = X_test_own @ omega
+
+ train_errors["ols_own" ][i] = r_squared(y_train, y_hat_train)
+ test_errors["ols_own" ][i] = r_squared(y_test, y_hat_test)
+
+ plt.subplot(10 , 5 , plot_counter)
+ plt.imshow(omega[1 :].reshape(L, L), **cmap_args)
+ plt.title("Home made OLS" )
+ plot_counter += 1
+
+ omega = get_ridge_weights(X_train_own, y_train, _lambda)
+ y_hat_train = X_train_own @ omega
+ y_hat_test = X_test_own @ omega
+
+ train_errors["ridge_own" ][i] = r_squared(y_train, y_hat_train)
+ test_errors["ridge_own" ][i] = r_squared(y_test, y_hat_test)
+
+ plt.subplot(10 , 5 , plot_counter)
+ plt.imshow(omega[1 :].reshape(L, L), **cmap_args)
+ plt.title(r"Home made ridge, $\lambda = %.4f$" % _lambda)
+ plot_counter += 1
+
+ for key, method in zip (
+ ["ols_sk" , "ridge_sk" , "lasso_sk" ],
+ [skl.LinearRegression(), skl.Ridge(alpha=_lambda), skl.Lasso(alpha=_lambda)]
+ ):
+ method = method.fit(X_train, y_train)
+
+ train_errors[key][i] = method.score(X_train, y_train)
+ test_errors[key][i] = method.score(X_test, y_test)
+
+ omega = method.coef_.reshape(L, L)
+
+ plt.subplot(10 , 5 , plot_counter)
+ plt.imshow(omega, **cmap_args)
+ plt.title(r"%s, $\lambda = %.4f$" % (key, _lambda))
+ plot_counter += 1
+
+plt.show()
+
+
+We can see that LASSO quite fast reaches a good solution for low
+values of \( \lambda \), but will "wither" when we increase \( \lambda \) too
+much. Ridge is more stable over a larger range of values for
+\( \lambda \), but eventually also fades away.
+
+
+
+
+
Finding the optimal value of \( \lambda \)
+
+
+To determine which value of \( \lambda \) is best we plot the accuracy of
+the models when predicting the training and the testing set. We expect
+the accuracy of the training set to be quite good, but if the accuracy
+of the testing set is much lower this tells us that we might be
+subject to an overfit model. The ideal scenario is an accuracy on the
+testing set that is close to the accuracy of the training set.
+
+
+
+
+
fig = plt.figure(figsize=(20 , 14 ))
+
+colors = {
+ "ols_own" : "b" ,
+ "ridge_own" : "g" ,
+ "ols_sk" : "r" ,
+ "ridge_sk" : "y" ,
+ "lasso_sk" : "c"
+}
+
+for key in train_errors:
+ plt.semilogx(
+ lambdas,
+ train_errors[key],
+ colors[key],
+ label="Train {0}" .format(key),
+ linewidth=4.0
+ )
+
+for key in test_errors:
+ plt.semilogx(
+ lambdas,
+ test_errors[key],
+ colors[key] + "--" ,
+ label="Test {0}" .format(key),
+ linewidth=4.0
+ )
+#plt.semilogx(lambdas, train_errors["ols_own"], label="Train (OLS own)")
+#plt.semilogx(lambdas, test_errors["ols_own"], label="Test (OLS own)")
+
+plt.legend(loc="best" , fontsize=18 )
+plt.xlabel(r"$\lambda$" , fontsize=18 )
+plt.ylabel(r"$R^2$" , fontsize=18 )
+plt.tick_params(labelsize=18 )
+plt.show()
+
+
+From the above figure we can see that LASSO with \( \lambda = 10^{-2} \)
+achieve a very good accuracy on the test set. This by far surpases the
+other models for all values of \( \lambda \).
+
diff --git a/doc/pub/Regression/html/Regression.html b/doc/pub/Regression/html/Regression.html
index 3681d2511..af11e2365 100644
--- a/doc/pub/Regression/html/Regression.html
+++ b/doc/pub/Regression/html/Regression.html
@@ -250,7 +250,34 @@ div { text-align: justify; text-justify: inter-word; }
('Elaborating a little bit more', 2, None, '___sec98'),
('The bias', 2, None, '___sec99'),
('The variance', 2, None, '___sec100'),
- ('Summing up', 2, None, '___sec101')]}
+ ('Summing up', 2, None, '___sec101'),
+ ('The one-dimensional Ising model, project 2',
+ 2,
+ None,
+ '___sec102'),
+ ('Example: The one-dimensional Ising model',
+ 2,
+ None,
+ '___sec103'),
+ ('Reformulating the problem to suit regression',
+ 2,
+ None,
+ '___sec104'),
+ ('Linear regression', 2, None, '___sec105'),
+ ('Ordinary least squares', 2, None, '___sec106'),
+ ('Singular Value decomposition', 2, None, '___sec107'),
+ ('Fitting with scikit-learn', 2, None, '___sec108'),
+ ('Ridge regression', 2, None, '___sec109'),
+ ('LASSO regression', 2, None, '___sec110'),
+ ('Performance of the different models', 2, None, '___sec111'),
+ ('Performance as function of the regularization parameter',
+ 2,
+ None,
+ '___sec112'),
+ ('Finding the optimal value of $\\lambda$',
+ 2,
+ None,
+ '___sec113')]}
end of tocinfo -->
@@ -292,7 +319,7 @@ MathJax.Hub.Config({
[2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University
-
Sep 25, 2018
+Oct 11, 2018
@@ -3477,6 +3504,585 @@ 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.
+
+
+
+
The one-dimensional Ising model, project 2
+
+
+The one-dimensional Ising model with nearest neighbor interaction, no external field and a constant coupling constant \( J \) is given by
+
+$$
+\begin{align}
+ H = -J \sum_{k}^L s_k s_{k + 1},
+\label{_auto19}
+\end{align}
+$$
+
+where \( s_i \in \{-1, 1\} \) and \( s_{N + 1} = s_1 \). The number of spins in the system is determined by \( L \). For the low temperature limit there is no phase transition.
+
+
+We will look at a system of \( L = 40 \) spins with a coupling constant of \( J = 1 \). To get enough training data we will generate 10000 states with their respective energies.
+
+
+
+
+
L = 40
+n = int (1e4 )
+
+spins = np. random. choice([-1 , 1 ], size= (n, L))
+J = 1.0
+
+energies = np. zeros(n)
+
+for i in range (n):
+ energies[i] = - J * np. dot(spins[i], np. roll(spins[i], 1 ))
+
+
+
+
+
Example: The one-dimensional Ising model
+
+
+Here we use linear (ordinary least squares), ridge and LASSO
+regression to predict the energy in the nearest neighbor
+one-dimensional Ising model on a ring, i.e., the endpoints wrap
+around. We will use the linear regression models to fit a value for
+the coupling constant to achieve this.
+
+
+
+
import numpy as np
+import matplotlib.pyplot as plt
+from mpl_toolkits.axes_grid1 import make_axes_locatable
+import seaborn as sns
+import scipy.linalg as scl
+from sklearn.model_selection import train_test_split
+import sklearn.linear_model as skl
+import tqdm
+sns. set(color_codes= True )
+cmap_args= dict (vmin=-1. , vmax=1. , cmap= 'seismic' )
+
+
+
+
+
Reformulating the problem to suit regression
+
+
+A more general form for the one-dimensional Ising model is
+
+$$
+\begin{align}
+ H = - \sum_j^L \sum_k^L s_j s_k J_{jk}.
+\label{_auto20}
+\end{align}
+$$
+
+
+Here we allow for interactions beyond the nearest neighbors and a more
+adaptive coupling matrix. This latter expression can be formulated as
+a matrix-product on the form
+$$
+\begin{align}
+ H = X J,
+\label{_auto21}
+\end{align}
+$$
+
+
+where \( X_{jk} = s_j s_k \) and \( J \) is the matrix consisting of the
+elements \( -J_{jk} \). This form of writing the energy fits perfectly
+with the form utilized in linear regression, viz.
+$$
+\begin{align}
+ y = X\omega + \epsilon,
+\label{_auto22}
+\end{align}
+$$
+
+
+
+
+
X = np. zeros((n, L ** 2 ))
+for i in range (n):
+ X[i] = np. outer(spins[i], spins[i]). ravel()
+y = energies
+X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.96 )
+
+X_train_own = np. concatenate(
+ (np. ones(len (X_train))[:, np. newaxis], X_train),
+ axis=1
+)
+
+X_test_own = np. concatenate(
+ (np. ones(len (X_test))[:, np. newaxis], X_test),
+ axis=1
+)
+
+
+
+
+
Linear regression
+
+
+The problem at hand is to try to fit the equation
+$$
+\begin{align}
+ y = f(x) + \epsilon,
+\label{_auto23}
+\end{align}
+$$
+
+
+where \( f(x) \) is some unknown function of the data \( x \) and \( \epsilon \)
+is normally distributed with mean zero noise with standard deviation
+\( \sigma_{\epsilon} \). Our job is to try to find a predictor which
+estimates the function \( f(x) \). In linear regression we assume that we
+can formulate the problem as
+
+$$
+\begin{align}
+ y = X\omega + \epsilon,
+\label{_auto24}
+\end{align}
+$$
+
+
+where \( X \) and \( \omega \) are now matrices. Our job at hand is now to
+find a cost function \( C \), which we wish to minimize in order to find
+the best estimate of \( \omega \).
+
+
+
+
+
Ordinary least squares
+
+
+In the ordinary least squares method we choose the cost function
+$$
+\begin{align}
+ C(X, \omega) = ||X\omega - y||^2
+ = (X\omega - y)^T(X\omega - y)
+\label{_auto25}
+\end{align}
+$$
+
+We then find the extremal point of \( C \) by taking the derivative with respect to \( \omega \) and setting it to zero, i.e.,
+
+$$
+\begin{align}
+ \dfrac{\mathrm{d}C}{\mathrm{d}\omega}
+ = 0.
+\label{_auto26}
+\end{align}
+$$
+
+This yields the expression for \( \omega \) to be
+$$
+\begin{align}
+ \omega = \frac{X^T y}{X^T X},
+\label{_auto27}
+\end{align}
+$$
+
+
+which immediately imposes some requirements on \( X \) as there must exist
+an inverse of \( X^T X \). If the expression we are modelling contains an
+intercept, i.e., a constant expression we must make sure that the
+first column of \( X \) consists of \( 1 \).
+
+
+
+
+
def get_ols_weights_naive (x: np. ndarray, y: np. ndarray) -> np. ndarray:
+ return scl. inv(x. T @ x) @ (x. T @ y)
+omega = get_ols_weights_naive(X_train_own, y_train)
+
+
+
+
+
Singular Value decomposition
+Doing the inversion directly turns out to be a bad idea as the matrix
+\( X^TX \) is singular. An alternative approach is to use the singular
+value decomposition . Using the definition of the Moore-Penrose
+pseudoinverse we can write the equation for \( \omega \) as
+
+$$
+\begin{align}
+ \omega = X^{+}y,
+\label{_auto28}
+\end{align}
+$$
+
+where the pseudoinverse of \( X \) is given by
+$$
+\begin{align}
+ X^{+} = \frac{X^T}{X^T X}.
+\label{_auto29}
+\end{align}
+$$
+
+
+Using singular value decomposition we have that \( X = U\Sigma V^T \),
+where \( X^{+} = V\Sigma^{+} U^T \). This reduces the equation for
+\( \omega \) to
+$$
+\begin{align}
+ \omega = V\Sigma^{+} U^T y.
+\label{_auto30}
+\end{align}
+$$
+
+
+Note that solving this equation by actually doing the pseudoinverse
+(which is what we will do) is not a good idea as this operation scales
+as \( \mathcal{O}(n^3) \), where \( n \) is the number of elements in a
+general matrix. Instead, doing \( QR \)-factorization and solving the
+linear system as an equation would reduce this down to
+\( \mathcal{O}(n^2) \) operations.
+
+
+
+
+
def get_ols_weights (x: np. ndarray, y: np. ndarray) -> np. ndarray:
+ u, s, v = scl. svd(x)
+ return v. T @ scl. pinv(scl. diagsvd(s, u. shape[0 ], v. shape[0 ])) @ u. T @ y
+
+
+Before passing in the data to the function we append a column with ones to the training data.
+
+
+
+
+
omega = get_ols_weights(X_train_own,y_train)
+
+
+
+
+
Fitting with scikit-learn
+
+
+Next we fit a LinearRegression-model from Scikit-learn for comparison.
+
+
+
+
+
clf = skl. LinearRegression(). fit(X_train, y_train)
+
+
+Extracting the \( J \)-matrix from both our own method and the Scikit-learn model where we make sure to remove the intercept.
+
+
+
+
+
J_own = omega[1 :]. reshape(L, L)
+J_sk = clf. coef_. reshape(L, L)
+
+
+A way of looking at the coefficients in \( J \) is to plot the matrices as images.
+
+
+
+
+
fig = plt. figure(figsize= (20 , 14 ))
+im = plt. imshow(J_own, ** cmap_args)
+plt. title("Home-made OLS" , fontsize=18 )
+plt. xticks(fontsize=18 )
+plt. yticks(fontsize=18 )
+cb = fig. colorbar(im)
+cb. ax. set_yticklabels(cb. ax. get_yticklabels(), fontsize=18 )
+
+fig = plt. figure(figsize= (20 , 14 ))
+im = plt. imshow(J_sk, ** cmap_args)
+plt. title("LinearRegression from Scikit-learn" , fontsize=18 )
+plt. xticks(fontsize=18 )
+plt. yticks(fontsize=18 )
+cb = fig. colorbar(im)
+cb. ax. set_yticklabels(cb. ax. get_yticklabels(), fontsize=18 )
+plt. show()
+
+
+We can see that our model for the least squares method performes close
+to the benchmark from Scikit-learn. It is interesting to note that OLS
+considers both \( J_{j, j + 1} = -0.5 \) and \( J_{j, j - 1} = -0.5 \) as
+valid matrix elements for \( J \).
+
+
+
+
+
Ridge regression
+
+
+Having explored the ordinary least squares we move on to ridge
+regression. In ridge regression we include a regularizer . This
+involves a new cost function which leads to a new estimate for the
+weights \( \omega \). This results in a penalized regression problem. The
+cost function is given by
+
+$$
+\begin{align}
+ C(X, \omega; \lambda) = ||X\omega - y||^2 + \lambda ||\omega||^2
+ = (X\omega - y)^T(X\omega - y) + \lambda \omega^T\omega.
+\label{_auto31}
+\end{align}
+$$
+
+Finding the extremum of this function yields the weights
+
+$$
+\begin{align}
+ \omega(\lambda) = \frac{X^Ty}{X^TX + \lambda} \to \frac{\omega_{\text{LS}}}{1 + \lambda},
+\label{_auto32}
+\end{align}
+$$
+
+
+where \( \omega_{\text{LS}} \) is the weights from ordinary least
+squares. The last assumption assumes that \( X \) is orthogonal, which it
+is not. We will therefore resort to solving the equation as it stands
+on the left hand side.
+
+
+
+
+
def get_ridge_weights (x: np. ndarray, y: np. ndarray, _lambda: float ) -> np. ndarray:
+ return x. T @ y @ scl. inv(
+ x. T @ x + np. eye(x. shape[1 ], x. shape[1 ]) * _lambda
+ )
+lambda = 0.1
+omega_ridge = get_ridge_weights(X_train_own, y_train, np. array([_lambda]))
+clf_ridge = skl. Ridge(alpha= _lambda). fit(X_train, y_train)
+J_ridge_own = omega_ridge[1 :]. reshape(L, L)
+J_ridge_sk = clf_ridge. coef_. reshape(L, L)
+fig = plt. figure(figsize= (20 , 14 ))
+im = plt. imshow(J_ridge_own, ** cmap_args)
+plt. title("Home-made ridge regression" , fontsize=18 )
+plt. xticks(fontsize=18 )
+plt. yticks(fontsize=18 )
+cb = fig. colorbar(im)
+cb. ax. set_yticklabels(cb. ax. get_yticklabels(), fontsize=18 )
+
+fig = plt. figure(figsize= (20 , 14 ))
+im = plt. imshow(J_ridge_sk, ** cmap_args)
+plt. title("Ridge from Scikit-learn" , fontsize=18 )
+plt. xticks(fontsize=18 )
+plt. yticks(fontsize=18 )
+cb = fig. colorbar(im)
+cb. ax. set_yticklabels(cb. ax. get_yticklabels(), fontsize=18 )
+
+plt. show()
+
+
+
+
+
LASSO regression
+
+
+In the Least Absolute Shrinkage and Selection Operator (LASSO)-method we get a third cost function.
+$$
+\begin{align}
+ C(X, \omega; \lambda) =
+ ||X\omega - y||^2 + \lambda ||\omega||
+ = (X\omega - y)^T(X\omega - y) + \lambda \sqrt{\omega^T\omega}.
+\label{_auto33}
+\end{align}
+$$
+
+Finding the extremal point of this cost function is not so straight-forward as in least squares and ridge. We will therefore rely solely on the function ``Lasso`` from Scikit-learn.
+
+
+
+
+
clf_lasso = skl. Lasso(alpha= _lambda). fit(X_train, y_train)
+J_lasso_sk = clf_lasso. coef_. reshape(L, L)
+fig = plt. figure(figsize= (20 , 14 ))
+im = plt. imshow(J_lasso_sk, ** cmap_args)
+plt. title("Lasso from Scikit-learn" , fontsize=18 )
+plt. xticks(fontsize=18 )
+plt. yticks(fontsize=18 )
+cb = fig. colorbar(im)
+cb. ax. set_yticklabels(cb. ax. get_yticklabels(), fontsize=18 )
+
+plt. show()
+
+
+It is quite striking how LASSO breaks the symmetry of the coupling
+constant as opposed to ridge and OLS. We get a sparse solution with
+\( J_{j, j + 1} = -1 \).
+
+
+
+
+
Performance of the different models
+
+
+In order to judge which model performs best at varying values of \( \lambda \) (for ridge and LASSO) we compute \( R^2 \) which is given by
+
+$$
+\begin{align}
+ R^2 = 1 - \frac{(y - \hat{y})^2}{(y - \bar{y})^2},
+\label{_auto34}
+\end{align}
+$$
+
+where \( y \) is a vector with the true values of the energy, \( \hat{y} \) is the predicted values of \( y \) from the models and \( \bar{y} \) is the mean of \( \hat{y} \).
+
+
+
+
+
def r_squared (y, y_hat):
+ return 1 - np. sum((y - y_hat) ** 2 ) / np. sum((y - np. mean(y_hat)) ** 2 )
+
+
+This is the same metric used by Scikit-learn for their regression models when scoring.
+
+
+
+
y_hat = clf. predict(X_test)
+r_test = r_squared(y_test, y_hat)
+sk_r_test = clf. score(X_test, y_test)
+
+assert abs (r_test - sk_r_test) < 1e-2
+
+
+
+
+
Performance as function of the regularization parameter
+
+
+We see how the different models perform for a different set of values for \( \lambda \).
+
+
+
+
+
lambdas = np. logspace(-4 , 5 , 10 )
+
+train_errors = {
+ "ols_own" : np. zeros(lambdas. size),
+ "ols_sk" : np. zeros(lambdas. size),
+ "ridge_own" : np. zeros(lambdas. size),
+ "ridge_sk" : np. zeros(lambdas. size),
+ "lasso_sk" : np. zeros(lambdas. size)
+}
+
+test_errors = {
+ "ols_own" : np. zeros(lambdas. size),
+ "ols_sk" : np. zeros(lambdas. size),
+ "ridge_own" : np. zeros(lambdas. size),
+ "ridge_sk" : np. zeros(lambdas. size),
+ "lasso_sk" : np. zeros(lambdas. size)
+}
+
+plot_counter = 1
+
+fig = plt. figure(figsize= (32 , 54 ))
+
+for i, _lambda in enumerate (tqdm. tqdm(lambdas)):
+ omega = get_ols_weights(X_train_own, y_train)
+ y_hat_train = X_train_own @ omega
+ y_hat_test = X_test_own @ omega
+
+ train_errors["ols_own" ][i] = r_squared(y_train, y_hat_train)
+ test_errors["ols_own" ][i] = r_squared(y_test, y_hat_test)
+
+ plt. subplot(10 , 5 , plot_counter)
+ plt. imshow(omega[1 :]. reshape(L, L), ** cmap_args)
+ plt. title("Home made OLS" )
+ plot_counter += 1
+
+ omega = get_ridge_weights(X_train_own, y_train, _lambda)
+ y_hat_train = X_train_own @ omega
+ y_hat_test = X_test_own @ omega
+
+ train_errors["ridge_own" ][i] = r_squared(y_train, y_hat_train)
+ test_errors["ridge_own" ][i] = r_squared(y_test, y_hat_test)
+
+ plt. subplot(10 , 5 , plot_counter)
+ plt. imshow(omega[1 :]. reshape(L, L), ** cmap_args)
+ plt. title(r"Home made ridge, $\lambda = %.4f $" % _lambda)
+ plot_counter += 1
+
+ for key, method in zip (
+ ["ols_sk" , "ridge_sk" , "lasso_sk" ],
+ [skl. LinearRegression(), skl. Ridge(alpha= _lambda), skl. Lasso(alpha= _lambda)]
+ ):
+ method = method. fit(X_train, y_train)
+
+ train_errors[key][i] = method. score(X_train, y_train)
+ test_errors[key][i] = method. score(X_test, y_test)
+
+ omega = method. coef_. reshape(L, L)
+
+ plt. subplot(10 , 5 , plot_counter)
+ plt. imshow(omega, ** cmap_args)
+ plt. title(r" %s , $\lambda = %.4f $" % (key, _lambda))
+ plot_counter += 1
+
+plt. show()
+
+
+We can see that LASSO quite fast reaches a good solution for low
+values of \( \lambda \), but will "wither" when we increase \( \lambda \) too
+much. Ridge is more stable over a larger range of values for
+\( \lambda \), but eventually also fades away.
+
+
+
+
+
Finding the optimal value of \( \lambda \)
+
+
+To determine which value of \( \lambda \) is best we plot the accuracy of
+the models when predicting the training and the testing set. We expect
+the accuracy of the training set to be quite good, but if the accuracy
+of the testing set is much lower this tells us that we might be
+subject to an overfit model. The ideal scenario is an accuracy on the
+testing set that is close to the accuracy of the training set.
+
+
+
+
+
fig = plt. figure(figsize= (20 , 14 ))
+
+colors = {
+ "ols_own" : "b" ,
+ "ridge_own" : "g" ,
+ "ols_sk" : "r" ,
+ "ridge_sk" : "y" ,
+ "lasso_sk" : "c"
+}
+
+for key in train_errors:
+ plt. semilogx(
+ lambdas,
+ train_errors[key],
+ colors[key],
+ label= "Train {0}" . format(key),
+ linewidth=4.0
+ )
+
+for key in test_errors:
+ plt. semilogx(
+ lambdas,
+ test_errors[key],
+ colors[key] + "--" ,
+ label= "Test {0}" . format(key),
+ linewidth=4.0
+ )
+#plt.semilogx(lambdas, train_errors["ols_own"], label="Train (OLS own)")
+#plt.semilogx(lambdas, test_errors["ols_own"], label="Test (OLS own)")
+
+plt. legend(loc= "best" , fontsize=18 )
+plt. xlabel(r"$\lambda$" , fontsize=18 )
+plt. ylabel(r"$R^2$" , fontsize=18 )
+plt. tick_params(labelsize=18 )
+plt. show()
+
+
+From the above figure we can see that LASSO with \( \lambda = 10^{-2} \)
+achieve a very good accuracy on the test set. This by far surpases the
+other models for all values of \( \lambda \).
+
diff --git a/doc/pub/Regression/ipynb/Regression.ipynb b/doc/pub/Regression/ipynb/Regression.ipynb
index c3f5a08af..907fa601a 100644
--- a/doc/pub/Regression/ipynb/Regression.ipynb
+++ b/doc/pub/Regression/ipynb/Regression.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 25, 2018**\n",
+ "Date: **Oct 11, 2018**\n",
"\n",
"Copyright 1999-2018, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license\n",
"\n",
@@ -4505,7 +4505,903 @@
"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."
+ "flexible statistical methods have higher variance.\n",
+ "\n",
+ "\n",
+ "## The one-dimensional Ising model, project 2\n",
+ "\n",
+ "The one-dimensional Ising model with nearest neighbor interaction, no external field and a constant coupling constant $J$ is given by"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "
\n",
+ "\n",
+ "$$\n",
+ "\\begin{equation}\n",
+ " H = -J \\sum_{k}^L s_k s_{k + 1},\n",
+ "\\label{_auto19} \\tag{30}\n",
+ "\\end{equation}\n",
+ "$$"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "where $s_i \\in \\{-1, 1\\}$ and $s_{N + 1} = s_1$. The number of spins in the system is determined by $L$. For the low temperature limit there is no phase transition.\n",
+ "\n",
+ "We will look at a system of $L = 40$ spins with a coupling constant of $J = 1$. To get enough training data we will generate 10000 states with their respective energies."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "L = 40\n",
+ "n = int(1e4)\n",
+ "\n",
+ "spins = np.random.choice([-1, 1], size=(n, L))\n",
+ "J = 1.0\n",
+ "\n",
+ "energies = np.zeros(n)\n",
+ "\n",
+ "for i in range(n):\n",
+ " energies[i] = - J * np.dot(spins[i], np.roll(spins[i], 1))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example: The one-dimensional Ising model\n",
+ "\n",
+ "\n",
+ "Here we use linear (ordinary least squares), ridge and LASSO\n",
+ "regression to predict the energy in the nearest neighbor\n",
+ "one-dimensional Ising model on a ring, i.e., the endpoints wrap\n",
+ "around. We will use the linear regression models to fit a value for\n",
+ "the coupling constant to achieve this."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "import numpy as np\n",
+ "import matplotlib.pyplot as plt\n",
+ "from mpl_toolkits.axes_grid1 import make_axes_locatable\n",
+ "import seaborn as sns\n",
+ "import scipy.linalg as scl\n",
+ "from sklearn.model_selection import train_test_split\n",
+ "import sklearn.linear_model as skl\n",
+ "import tqdm\n",
+ "sns.set(color_codes=True)\n",
+ "cmap_args=dict(vmin=-1., vmax=1., cmap='seismic')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Reformulating the problem to suit regression\n",
+ "\n",
+ "A more general form for the one-dimensional Ising model is"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "
\n",
+ "\n",
+ "$$\n",
+ "\\begin{equation}\n",
+ " H = - \\sum_j^L \\sum_k^L s_j s_k J_{jk}.\n",
+ "\\label{_auto20} \\tag{31}\n",
+ "\\end{equation}\n",
+ "$$"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Here we allow for interactions beyond the nearest neighbors and a more\n",
+ "adaptive coupling matrix. This latter expression can be formulated as\n",
+ "a matrix-product on the form"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "
\n",
+ "\n",
+ "$$\n",
+ "\\begin{equation}\n",
+ " H = X J,\n",
+ "\\label{_auto21} \\tag{32}\n",
+ "\\end{equation}\n",
+ "$$"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "where $X_{jk} = s_j s_k$ and $J$ is the matrix consisting of the\n",
+ "elements $-J_{jk}$. This form of writing the energy fits perfectly\n",
+ "with the form utilized in linear regression, viz."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "
\n",
+ "\n",
+ "$$\n",
+ "\\begin{equation}\n",
+ " y = X\\omega + \\epsilon,\n",
+ "\\label{_auto22} \\tag{33}\n",
+ "\\end{equation}\n",
+ "$$"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "X = np.zeros((n, L ** 2))\n",
+ "for i in range(n):\n",
+ " X[i] = np.outer(spins[i], spins[i]).ravel()\n",
+ "y = energies\n",
+ "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.96)\n",
+ "\n",
+ "X_train_own = np.concatenate(\n",
+ " (np.ones(len(X_train))[:, np.newaxis], X_train),\n",
+ " axis=1\n",
+ ")\n",
+ "\n",
+ "X_test_own = np.concatenate(\n",
+ " (np.ones(len(X_test))[:, np.newaxis], X_test),\n",
+ " axis=1\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Linear regression\n",
+ "\n",
+ "The problem at hand is to try to fit the equation"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "
\n",
+ "\n",
+ "$$\n",
+ "\\begin{equation}\n",
+ " y = f(x) + \\epsilon,\n",
+ "\\label{_auto23} \\tag{34}\n",
+ "\\end{equation}\n",
+ "$$"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "where $f(x)$ is some unknown function of the data $x$ and $\\epsilon$\n",
+ "is normally distributed with mean zero noise with standard deviation\n",
+ "$\\sigma_{\\epsilon}$. Our job is to try to find a predictor which\n",
+ "estimates the function $f(x)$. In linear regression we assume that we\n",
+ "can formulate the problem as"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "
\n",
+ "\n",
+ "$$\n",
+ "\\begin{equation}\n",
+ " y = X\\omega + \\epsilon,\n",
+ "\\label{_auto24} \\tag{35}\n",
+ "\\end{equation}\n",
+ "$$"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "where $X$ and $\\omega$ are now matrices. Our job at hand is now to\n",
+ "find a **cost function** $C$, which we wish to minimize in order to find\n",
+ "the best estimate of $\\omega$.\n",
+ "\n",
+ "## Ordinary least squares\n",
+ "\n",
+ "In the ordinary least squares method we choose the cost function"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "
\n",
+ "\n",
+ "$$\n",
+ "\\begin{equation}\n",
+ " C(X, \\omega) = ||X\\omega - y||^2\n",
+ " = (X\\omega - y)^T(X\\omega - y)\n",
+ "\\label{_auto25} \\tag{36}\n",
+ "\\end{equation}\n",
+ "$$"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "We then find the extremal point of $C$ by taking the derivative with respect to $\\omega$ and setting it to zero, i.e.,"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "
\n",
+ "\n",
+ "$$\n",
+ "\\begin{equation}\n",
+ " \\dfrac{\\mathrm{d}C}{\\mathrm{d}\\omega}\n",
+ " = 0.\n",
+ "\\label{_auto26} \\tag{37}\n",
+ "\\end{equation}\n",
+ "$$"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "This yields the expression for $\\omega$ to be"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "
\n",
+ "\n",
+ "$$\n",
+ "\\begin{equation}\n",
+ " \\omega = \\frac{X^T y}{X^T X},\n",
+ "\\label{_auto27} \\tag{38}\n",
+ "\\end{equation}\n",
+ "$$"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "which immediately imposes some requirements on $X$ as there must exist\n",
+ "an inverse of $X^T X$. If the expression we are modelling contains an\n",
+ "intercept, i.e., a constant expression we must make sure that the\n",
+ "first column of $X$ consists of $1$."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "def get_ols_weights_naive(x: np.ndarray, y: np.ndarray) -> np.ndarray:\n",
+ " return scl.inv(x.T @ x) @ (x.T @ y)\n",
+ "omega = get_ols_weights_naive(X_train_own, y_train)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Singular Value decomposition\n",
+ "Doing the inversion directly turns out to be a bad idea as the matrix\n",
+ "$X^TX$ is singular. An alternative approach is to use the **singular\n",
+ "value decomposition**. Using the definition of the Moore-Penrose\n",
+ "pseudoinverse we can write the equation for $\\omega$ as"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "
\n",
+ "\n",
+ "$$\n",
+ "\\begin{equation}\n",
+ " \\omega = X^{+}y,\n",
+ "\\label{_auto28} \\tag{39}\n",
+ "\\end{equation}\n",
+ "$$"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "where the pseudoinverse of $X$ is given by"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "
\n",
+ "\n",
+ "$$\n",
+ "\\begin{equation}\n",
+ " X^{+} = \\frac{X^T}{X^T X}.\n",
+ "\\label{_auto29} \\tag{40}\n",
+ "\\end{equation}\n",
+ "$$"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Using singular value decomposition we have that $X = U\\Sigma V^T$,\n",
+ "where $X^{+} = V\\Sigma^{+} U^T$. This reduces the equation for\n",
+ "$\\omega$ to"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "
\n",
+ "\n",
+ "$$\n",
+ "\\begin{equation}\n",
+ " \\omega = V\\Sigma^{+} U^T y.\n",
+ "\\label{_auto30} \\tag{41}\n",
+ "\\end{equation}\n",
+ "$$"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Note that solving this equation by actually doing the pseudoinverse\n",
+ "(which is what we will do) is not a good idea as this operation scales\n",
+ "as $\\mathcal{O}(n^3)$, where $n$ is the number of elements in a\n",
+ "general matrix. Instead, doing $QR$-factorization and solving the\n",
+ "linear system as an equation would reduce this down to\n",
+ "$\\mathcal{O}(n^2)$ operations."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "def get_ols_weights(x: np.ndarray, y: np.ndarray) -> np.ndarray:\n",
+ " u, s, v = scl.svd(x)\n",
+ " return v.T @ scl.pinv(scl.diagsvd(s, u.shape[0], v.shape[0])) @ u.T @ y"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Before passing in the data to the function we append a column with ones to the training data."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "omega = get_ols_weights(X_train_own,y_train)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Fitting with scikit-learn\n",
+ "\n",
+ "Next we fit a `LinearRegression`-model from Scikit-learn for comparison."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "clf = skl.LinearRegression().fit(X_train, y_train)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Extracting the $J$-matrix from both our own method and the Scikit-learn model where we make sure to remove the intercept."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "J_own = omega[1:].reshape(L, L)\n",
+ "J_sk = clf.coef_.reshape(L, L)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "A way of looking at the coefficients in $J$ is to plot the matrices as images."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "fig = plt.figure(figsize=(20, 14))\n",
+ "im = plt.imshow(J_own, **cmap_args)\n",
+ "plt.title(\"Home-made OLS\", fontsize=18)\n",
+ "plt.xticks(fontsize=18)\n",
+ "plt.yticks(fontsize=18)\n",
+ "cb = fig.colorbar(im)\n",
+ "cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18)\n",
+ "\n",
+ "fig = plt.figure(figsize=(20, 14))\n",
+ "im = plt.imshow(J_sk, **cmap_args)\n",
+ "plt.title(\"LinearRegression from Scikit-learn\", fontsize=18)\n",
+ "plt.xticks(fontsize=18)\n",
+ "plt.yticks(fontsize=18)\n",
+ "cb = fig.colorbar(im)\n",
+ "cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18)\n",
+ "plt.show()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "We can see that our model for the least squares method performes close\n",
+ "to the benchmark from Scikit-learn. It is interesting to note that OLS\n",
+ "considers both $J_{j, j + 1} = -0.5$ and $J_{j, j - 1} = -0.5$ as\n",
+ "valid matrix elements for $J$.\n",
+ "\n",
+ "## Ridge regression\n",
+ "\n",
+ "Having explored the ordinary least squares we move on to ridge\n",
+ "regression. In ridge regression we include a **regularizer**. This\n",
+ "involves a new cost function which leads to a new estimate for the\n",
+ "weights $\\omega$. This results in a penalized regression problem. The\n",
+ "cost function is given by"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "
\n",
+ "\n",
+ "$$\n",
+ "\\begin{equation}\n",
+ " C(X, \\omega; \\lambda) = ||X\\omega - y||^2 + \\lambda ||\\omega||^2\n",
+ " = (X\\omega - y)^T(X\\omega - y) + \\lambda \\omega^T\\omega.\n",
+ "\\label{_auto31} \\tag{42}\n",
+ "\\end{equation}\n",
+ "$$"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Finding the extremum of this function yields the weights"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "
\n",
+ "\n",
+ "$$\n",
+ "\\begin{equation}\n",
+ " \\omega(\\lambda) = \\frac{X^Ty}{X^TX + \\lambda} \\to \\frac{\\omega_{\\text{LS}}}{1 + \\lambda},\n",
+ "\\label{_auto32} \\tag{43}\n",
+ "\\end{equation}\n",
+ "$$"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "where $\\omega_{\\text{LS}}$ is the weights from ordinary least\n",
+ "squares. The last assumption assumes that $X$ is orthogonal, which it\n",
+ "is not. We will therefore resort to solving the equation as it stands\n",
+ "on the left hand side."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "def get_ridge_weights(x: np.ndarray, y: np.ndarray, _lambda: float) -> np.ndarray:\n",
+ " return x.T @ y @ scl.inv(\n",
+ " x.T @ x + np.eye(x.shape[1], x.shape[1]) * _lambda\n",
+ " )\n",
+ "lambda = 0.1\n",
+ "omega_ridge = get_ridge_weights(X_train_own, y_train, np.array([_lambda]))\n",
+ "clf_ridge = skl.Ridge(alpha=_lambda).fit(X_train, y_train)\n",
+ "J_ridge_own = omega_ridge[1:].reshape(L, L)\n",
+ "J_ridge_sk = clf_ridge.coef_.reshape(L, L)\n",
+ "fig = plt.figure(figsize=(20, 14))\n",
+ "im = plt.imshow(J_ridge_own, **cmap_args)\n",
+ "plt.title(\"Home-made ridge regression\", fontsize=18)\n",
+ "plt.xticks(fontsize=18)\n",
+ "plt.yticks(fontsize=18)\n",
+ "cb = fig.colorbar(im)\n",
+ "cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18)\n",
+ "\n",
+ "fig = plt.figure(figsize=(20, 14))\n",
+ "im = plt.imshow(J_ridge_sk, **cmap_args)\n",
+ "plt.title(\"Ridge from Scikit-learn\", fontsize=18)\n",
+ "plt.xticks(fontsize=18)\n",
+ "plt.yticks(fontsize=18)\n",
+ "cb = fig.colorbar(im)\n",
+ "cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18)\n",
+ "\n",
+ "plt.show()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## LASSO regression\n",
+ "\n",
+ "In the **Least Absolute Shrinkage and Selection Operator** (LASSO)-method we get a third cost function."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "
\n",
+ "\n",
+ "$$\n",
+ "\\begin{equation}\n",
+ " C(X, \\omega; \\lambda) =\n",
+ " ||X\\omega - y||^2 + \\lambda ||\\omega||\n",
+ " = (X\\omega - y)^T(X\\omega - y) + \\lambda \\sqrt{\\omega^T\\omega}.\n",
+ "\\label{_auto33} \\tag{44}\n",
+ "\\end{equation}\n",
+ "$$"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Finding the extremal point of this cost function is not so straight-forward as in least squares and ridge. We will therefore rely solely on the function ``Lasso`` from Scikit-learn."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "clf_lasso = skl.Lasso(alpha=_lambda).fit(X_train, y_train)\n",
+ "J_lasso_sk = clf_lasso.coef_.reshape(L, L)\n",
+ "fig = plt.figure(figsize=(20, 14))\n",
+ "im = plt.imshow(J_lasso_sk, **cmap_args)\n",
+ "plt.title(\"Lasso from Scikit-learn\", fontsize=18)\n",
+ "plt.xticks(fontsize=18)\n",
+ "plt.yticks(fontsize=18)\n",
+ "cb = fig.colorbar(im)\n",
+ "cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18)\n",
+ "\n",
+ "plt.show()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "It is quite striking how LASSO breaks the symmetry of the coupling\n",
+ "constant as opposed to ridge and OLS. We get a sparse solution with\n",
+ "$J_{j, j + 1} = -1$.\n",
+ "\n",
+ "\n",
+ "## Performance of the different models\n",
+ "\n",
+ "In order to judge which model performs best at varying values of $\\lambda$ (for ridge and LASSO) we compute $R^2$ which is given by"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "
\n",
+ "\n",
+ "$$\n",
+ "\\begin{equation}\n",
+ " R^2 = 1 - \\frac{(y - \\hat{y})^2}{(y - \\bar{y})^2},\n",
+ "\\label{_auto34} \\tag{45}\n",
+ "\\end{equation}\n",
+ "$$"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "where $y$ is a vector with the true values of the energy, $\\hat{y}$ is the predicted values of $y$ from the models and $\\bar{y}$ is the mean of $\\hat{y}$."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 27,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "def r_squared(y, y_hat):\n",
+ " return 1 - np.sum((y - y_hat) ** 2) / np.sum((y - np.mean(y_hat)) ** 2)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "This is the same metric used by Scikit-learn for their regression models when scoring."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 28,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "y_hat = clf.predict(X_test)\n",
+ "r_test = r_squared(y_test, y_hat)\n",
+ "sk_r_test = clf.score(X_test, y_test)\n",
+ "\n",
+ "assert abs(r_test - sk_r_test) < 1e-2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Performance as function of the regularization parameter\n",
+ "\n",
+ "We see how the different models perform for a different set of values for $\\lambda$."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 29,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "lambdas = np.logspace(-4, 5, 10)\n",
+ "\n",
+ "train_errors = {\n",
+ " \"ols_own\": np.zeros(lambdas.size),\n",
+ " \"ols_sk\": np.zeros(lambdas.size),\n",
+ " \"ridge_own\": np.zeros(lambdas.size),\n",
+ " \"ridge_sk\": np.zeros(lambdas.size),\n",
+ " \"lasso_sk\": np.zeros(lambdas.size)\n",
+ "}\n",
+ "\n",
+ "test_errors = {\n",
+ " \"ols_own\": np.zeros(lambdas.size),\n",
+ " \"ols_sk\": np.zeros(lambdas.size),\n",
+ " \"ridge_own\": np.zeros(lambdas.size),\n",
+ " \"ridge_sk\": np.zeros(lambdas.size),\n",
+ " \"lasso_sk\": np.zeros(lambdas.size)\n",
+ "}\n",
+ "\n",
+ "plot_counter = 1\n",
+ "\n",
+ "fig = plt.figure(figsize=(32, 54))\n",
+ "\n",
+ "for i, _lambda in enumerate(tqdm.tqdm(lambdas)):\n",
+ " omega = get_ols_weights(X_train_own, y_train)\n",
+ " y_hat_train = X_train_own @ omega\n",
+ " y_hat_test = X_test_own @ omega\n",
+ "\n",
+ " train_errors[\"ols_own\"][i] = r_squared(y_train, y_hat_train)\n",
+ " test_errors[\"ols_own\"][i] = r_squared(y_test, y_hat_test)\n",
+ "\n",
+ " plt.subplot(10, 5, plot_counter)\n",
+ " plt.imshow(omega[1:].reshape(L, L), **cmap_args)\n",
+ " plt.title(\"Home made OLS\")\n",
+ " plot_counter += 1\n",
+ "\n",
+ " omega = get_ridge_weights(X_train_own, y_train, _lambda)\n",
+ " y_hat_train = X_train_own @ omega\n",
+ " y_hat_test = X_test_own @ omega\n",
+ "\n",
+ " train_errors[\"ridge_own\"][i] = r_squared(y_train, y_hat_train)\n",
+ " test_errors[\"ridge_own\"][i] = r_squared(y_test, y_hat_test)\n",
+ "\n",
+ " plt.subplot(10, 5, plot_counter)\n",
+ " plt.imshow(omega[1:].reshape(L, L), **cmap_args)\n",
+ " plt.title(r\"Home made ridge, $\\lambda = %.4f$\" % _lambda)\n",
+ " plot_counter += 1\n",
+ "\n",
+ " for key, method in zip(\n",
+ " [\"ols_sk\", \"ridge_sk\", \"lasso_sk\"],\n",
+ " [skl.LinearRegression(), skl.Ridge(alpha=_lambda), skl.Lasso(alpha=_lambda)]\n",
+ " ):\n",
+ " method = method.fit(X_train, y_train)\n",
+ "\n",
+ " train_errors[key][i] = method.score(X_train, y_train)\n",
+ " test_errors[key][i] = method.score(X_test, y_test)\n",
+ "\n",
+ " omega = method.coef_.reshape(L, L)\n",
+ "\n",
+ " plt.subplot(10, 5, plot_counter)\n",
+ " plt.imshow(omega, **cmap_args)\n",
+ " plt.title(r\"%s, $\\lambda = %.4f$\" % (key, _lambda))\n",
+ " plot_counter += 1\n",
+ "\n",
+ "plt.show()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "We can see that LASSO quite fast reaches a good solution for low\n",
+ "values of $\\lambda$, but will \"wither\" when we increase $\\lambda$ too\n",
+ "much. Ridge is more stable over a larger range of values for\n",
+ "$\\lambda$, but eventually also fades away.\n",
+ "\n",
+ "## Finding the optimal value of $\\lambda$\n",
+ "\n",
+ "To determine which value of $\\lambda$ is best we plot the accuracy of\n",
+ "the models when predicting the training and the testing set. We expect\n",
+ "the accuracy of the training set to be quite good, but if the accuracy\n",
+ "of the testing set is much lower this tells us that we might be\n",
+ "subject to an overfit model. The ideal scenario is an accuracy on the\n",
+ "testing set that is close to the accuracy of the training set."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 30,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "fig = plt.figure(figsize=(20, 14))\n",
+ "\n",
+ "colors = {\n",
+ " \"ols_own\": \"b\",\n",
+ " \"ridge_own\": \"g\",\n",
+ " \"ols_sk\": \"r\",\n",
+ " \"ridge_sk\": \"y\",\n",
+ " \"lasso_sk\": \"c\"\n",
+ "}\n",
+ "\n",
+ "for key in train_errors:\n",
+ " plt.semilogx(\n",
+ " lambdas,\n",
+ " train_errors[key],\n",
+ " colors[key],\n",
+ " label=\"Train {0}\".format(key),\n",
+ " linewidth=4.0\n",
+ " )\n",
+ "\n",
+ "for key in test_errors:\n",
+ " plt.semilogx(\n",
+ " lambdas,\n",
+ " test_errors[key],\n",
+ " colors[key] + \"--\",\n",
+ " label=\"Test {0}\".format(key),\n",
+ " linewidth=4.0\n",
+ " )\n",
+ "#plt.semilogx(lambdas, train_errors[\"ols_own\"], label=\"Train (OLS own)\")\n",
+ "#plt.semilogx(lambdas, test_errors[\"ols_own\"], label=\"Test (OLS own)\")\n",
+ "\n",
+ "plt.legend(loc=\"best\", fontsize=18)\n",
+ "plt.xlabel(r\"$\\lambda$\", fontsize=18)\n",
+ "plt.ylabel(r\"$R^2$\", fontsize=18)\n",
+ "plt.tick_params(labelsize=18)\n",
+ "plt.show()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "From the above figure we can see that LASSO with $\\lambda = 10^{-2}$\n",
+ "achieve a very good accuracy on the test set. This by far surpases the\n",
+ "other models for all values of $\\lambda$."
]
}
],
diff --git a/doc/pub/Regression/ipynb/ipynb-Regression-src.tar.gz b/doc/pub/Regression/ipynb/ipynb-Regression-src.tar.gz
index 424c6b90f..0a0242504 100644
Binary files a/doc/pub/Regression/ipynb/ipynb-Regression-src.tar.gz and b/doc/pub/Regression/ipynb/ipynb-Regression-src.tar.gz differ
diff --git a/doc/pub/Regression/pdf/Regression-beamer-handouts2x3.pdf b/doc/pub/Regression/pdf/Regression-beamer-handouts2x3.pdf
index c84b672da..b80d0630e 100644
Binary files a/doc/pub/Regression/pdf/Regression-beamer-handouts2x3.pdf and b/doc/pub/Regression/pdf/Regression-beamer-handouts2x3.pdf differ
diff --git a/doc/pub/Regression/pdf/Regression-beamer.pdf b/doc/pub/Regression/pdf/Regression-beamer.pdf
index b40b486fc..62dc14085 100644
Binary files a/doc/pub/Regression/pdf/Regression-beamer.pdf and b/doc/pub/Regression/pdf/Regression-beamer.pdf differ
diff --git a/doc/pub/Regression/pdf/Regression-minted.pdf b/doc/pub/Regression/pdf/Regression-minted.pdf
index 1819d5d39..c3db8b023 100644
Binary files a/doc/pub/Regression/pdf/Regression-minted.pdf and b/doc/pub/Regression/pdf/Regression-minted.pdf differ
diff --git a/doc/src/Regression/Regression.do.txt b/doc/src/Regression/Regression.do.txt
index 085e76228..2b8d3974a 100644
--- a/doc/src/Regression/Regression.do.txt
+++ b/doc/src/Regression/Regression.do.txt
@@ -2880,3 +2880,509 @@ 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.
+
+!split
+===== The one-dimensional Ising model, project 2 =====
+
+The one-dimensional Ising model with nearest neighbor interaction, no external field and a constant coupling constant $J$ is given by
+
+!bt
+\begin{align}
+ H = -J \sum_{k}^L s_k s_{k + 1},
+\end{align}
+!et
+where $s_i \in \{-1, 1\}$ and $s_{N + 1} = s_1$. The number of spins in the system is determined by $L$. For the low temperature limit there is no phase transition.
+
+We will look at a system of $L = 40$ spins with a coupling constant of $J = 1$. To get enough training data we will generate 10000 states with their respective energies.
+
+
+!bc pycod
+L = 40
+n = int(1e4)
+
+spins = np.random.choice([-1, 1], size=(n, L))
+J = 1.0
+
+energies = np.zeros(n)
+
+for i in range(n):
+ energies[i] = - J * np.dot(spins[i], np.roll(spins[i], 1))
+!ec
+
+
+
+!split
+===== Example: The one-dimensional Ising model =====
+
+
+Here we use linear (ordinary least squares), ridge and LASSO
+regression to predict the energy in the nearest neighbor
+one-dimensional Ising model on a ring, i.e., the endpoints wrap
+around. We will use the linear regression models to fit a value for
+the coupling constant to achieve this.
+!bc pycod
+import numpy as np
+import matplotlib.pyplot as plt
+from mpl_toolkits.axes_grid1 import make_axes_locatable
+import seaborn as sns
+import scipy.linalg as scl
+from sklearn.model_selection import train_test_split
+import sklearn.linear_model as skl
+import tqdm
+sns.set(color_codes=True)
+cmap_args=dict(vmin=-1., vmax=1., cmap='seismic')
+!ec
+
+!split
+===== Reformulating the problem to suit regression =====
+
+A more general form for the one-dimensional Ising model is
+
+!bt
+\begin{align}
+ H = - \sum_j^L \sum_k^L s_j s_k J_{jk}.
+\end{align}
+!et
+
+Here we allow for interactions beyond the nearest neighbors and a more
+adaptive coupling matrix. This latter expression can be formulated as
+a matrix-product on the form
+!bt
+\begin{align}
+ H = X J,
+\end{align}
+!et
+
+where $X_{jk} = s_j s_k$ and $J$ is the matrix consisting of the
+elements $-J_{jk}$. This form of writing the energy fits perfectly
+with the form utilized in linear regression, viz.
+!bt
+\begin{align}
+ y = X\omega + \epsilon,
+\end{align}
+!et
+
+
+
+!bc pycod
+X = np.zeros((n, L ** 2))
+for i in range(n):
+ X[i] = np.outer(spins[i], spins[i]).ravel()
+y = energies
+X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.96)
+
+X_train_own = np.concatenate(
+ (np.ones(len(X_train))[:, np.newaxis], X_train),
+ axis=1
+)
+
+X_test_own = np.concatenate(
+ (np.ones(len(X_test))[:, np.newaxis], X_test),
+ axis=1
+)
+!ec
+
+!split
+===== Linear regression =====
+
+The problem at hand is to try to fit the equation
+!bt
+\begin{align}
+ y = f(x) + \epsilon,
+\end{align}
+!et
+
+where $f(x)$ is some unknown function of the data $x$ and $\epsilon$
+is normally distributed with mean zero noise with standard deviation
+$\sigma_{\epsilon}$. Our job is to try to find a predictor which
+estimates the function $f(x)$. In linear regression we assume that we
+can formulate the problem as
+
+!bt
+\begin{align}
+ y = X\omega + \epsilon,
+\end{align}
+!et
+
+where $X$ and $\omega$ are now matrices. Our job at hand is now to
+find a _cost function_ $C$, which we wish to minimize in order to find
+the best estimate of $\omega$.
+
+!split
+===== Ordinary least squares =====
+
+In the ordinary least squares method we choose the cost function
+!bt
+\begin{align}
+ C(X, \omega) = ||X\omega - y||^2
+ = (X\omega - y)^T(X\omega - y)
+\end{align}
+!et
+We then find the extremal point of $C$ by taking the derivative with respect to $\omega$ and setting it to zero, i.e.,
+
+!bt
+\begin{align}
+ \dfrac{\mathrm{d}C}{\mathrm{d}\omega}
+ = 0.
+\end{align}
+!et
+This yields the expression for $\omega$ to be
+!bt
+\begin{align}
+ \omega = \frac{X^T y}{X^T X},
+\end{align}
+!et
+
+which immediately imposes some requirements on $X$ as there must exist
+an inverse of $X^T X$. If the expression we are modelling contains an
+intercept, i.e., a constant expression we must make sure that the
+first column of $X$ consists of $1$.
+
+
+!bc pycod
+def get_ols_weights_naive(x: np.ndarray, y: np.ndarray) -> np.ndarray:
+ return scl.inv(x.T @ x) @ (x.T @ y)
+omega = get_ols_weights_naive(X_train_own, y_train)
+!ec
+
+
+!split
+===== Singular Value decomposition =====
+Doing the inversion directly turns out to be a bad idea as the matrix
+$X^TX$ is singular. An alternative approach is to use the _singular
+value decomposition_. Using the definition of the Moore-Penrose
+pseudoinverse we can write the equation for $\omega$ as
+
+!bt
+\begin{align}
+ \omega = X^{+}y,
+\end{align}
+!et
+where the pseudoinverse of $X$ is given by
+!bt
+\begin{align}
+ X^{+} = \frac{X^T}{X^T X}.
+\end{align}
+!et
+
+Using singular value decomposition we have that $X = U\Sigma V^T$,
+where $X^{+} = V\Sigma^{+} U^T$. This reduces the equation for
+$\omega$ to
+!bt
+\begin{align}
+ \omega = V\Sigma^{+} U^T y.
+\end{align}
+!et
+
+Note that solving this equation by actually doing the pseudoinverse
+(which is what we will do) is not a good idea as this operation scales
+as $\mathcal{O}(n^3)$, where $n$ is the number of elements in a
+general matrix. Instead, doing $QR$-factorization and solving the
+linear system as an equation would reduce this down to
+$\mathcal{O}(n^2)$ operations.
+
+
+!bc pycod
+def get_ols_weights(x: np.ndarray, y: np.ndarray) -> np.ndarray:
+ u, s, v = scl.svd(x)
+ return v.T @ scl.pinv(scl.diagsvd(s, u.shape[0], v.shape[0])) @ u.T @ y
+!ec
+Before passing in the data to the function we append a column with ones to the training data.
+
+
+!bc pycod
+omega = get_ols_weights(X_train_own,y_train)
+!ec
+
+!split
+===== Fitting with scikit-learn =====
+
+Next we fit a `LinearRegression`-model from Scikit-learn for comparison.
+
+!bc pycod
+clf = skl.LinearRegression().fit(X_train, y_train)
+!ec
+
+Extracting the $J$-matrix from both our own method and the Scikit-learn model where we make sure to remove the intercept.
+
+
+!bc pycod
+J_own = omega[1:].reshape(L, L)
+J_sk = clf.coef_.reshape(L, L)
+!ec
+
+A way of looking at the coefficients in $J$ is to plot the matrices as images.
+
+
+!bc pycod
+fig = plt.figure(figsize=(20, 14))
+im = plt.imshow(J_own, **cmap_args)
+plt.title("Home-made OLS", fontsize=18)
+plt.xticks(fontsize=18)
+plt.yticks(fontsize=18)
+cb = fig.colorbar(im)
+cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18)
+
+fig = plt.figure(figsize=(20, 14))
+im = plt.imshow(J_sk, **cmap_args)
+plt.title("LinearRegression from Scikit-learn", fontsize=18)
+plt.xticks(fontsize=18)
+plt.yticks(fontsize=18)
+cb = fig.colorbar(im)
+cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18)
+plt.show()
+!ec
+
+We can see that our model for the least squares method performes close
+to the benchmark from Scikit-learn. It is interesting to note that OLS
+considers both $J_{j, j + 1} = -0.5$ and $J_{j, j - 1} = -0.5$ as
+valid matrix elements for $J$.
+
+!split
+===== Ridge regression =====
+
+Having explored the ordinary least squares we move on to ridge
+regression. In ridge regression we include a _regularizer_. This
+involves a new cost function which leads to a new estimate for the
+weights $\omega$. This results in a penalized regression problem. The
+cost function is given by
+
+!bt
+\begin{align}
+ C(X, \omega; \lambda) = ||X\omega - y||^2 + \lambda ||\omega||^2
+ = (X\omega - y)^T(X\omega - y) + \lambda \omega^T\omega.
+\end{align}
+!et
+Finding the extremum of this function yields the weights
+
+!bt
+\begin{align}
+ \omega(\lambda) = \frac{X^Ty}{X^TX + \lambda} \to \frac{\omega_{\text{LS}}}{1 + \lambda},
+\end{align}
+!et
+
+where $\omega_{\text{LS}}$ is the weights from ordinary least
+squares. The last assumption assumes that $X$ is orthogonal, which it
+is not. We will therefore resort to solving the equation as it stands
+on the left hand side.
+
+
+!bc pycod
+def get_ridge_weights(x: np.ndarray, y: np.ndarray, _lambda: float) -> np.ndarray:
+ return x.T @ y @ scl.inv(
+ x.T @ x + np.eye(x.shape[1], x.shape[1]) * _lambda
+ )
+lambda = 0.1
+omega_ridge = get_ridge_weights(X_train_own, y_train, np.array([_lambda]))
+clf_ridge = skl.Ridge(alpha=_lambda).fit(X_train, y_train)
+J_ridge_own = omega_ridge[1:].reshape(L, L)
+J_ridge_sk = clf_ridge.coef_.reshape(L, L)
+fig = plt.figure(figsize=(20, 14))
+im = plt.imshow(J_ridge_own, **cmap_args)
+plt.title("Home-made ridge regression", fontsize=18)
+plt.xticks(fontsize=18)
+plt.yticks(fontsize=18)
+cb = fig.colorbar(im)
+cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18)
+
+fig = plt.figure(figsize=(20, 14))
+im = plt.imshow(J_ridge_sk, **cmap_args)
+plt.title("Ridge from Scikit-learn", fontsize=18)
+plt.xticks(fontsize=18)
+plt.yticks(fontsize=18)
+cb = fig.colorbar(im)
+cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18)
+
+plt.show()
+!ec
+
+!split
+===== LASSO regression =====
+
+In the _Least Absolute Shrinkage and Selection Operator_ (LASSO)-method we get a third cost function.
+!bt
+\begin{align}
+ C(X, \omega; \lambda) =
+ ||X\omega - y||^2 + \lambda ||\omega||
+ = (X\omega - y)^T(X\omega - y) + \lambda \sqrt{\omega^T\omega}.
+\end{align}
+!et
+Finding the extremal point of this cost function is not so straight-forward as in least squares and ridge. We will therefore rely solely on the function ``Lasso`` from Scikit-learn.
+
+!bc pycod
+clf_lasso = skl.Lasso(alpha=_lambda).fit(X_train, y_train)
+J_lasso_sk = clf_lasso.coef_.reshape(L, L)
+fig = plt.figure(figsize=(20, 14))
+im = plt.imshow(J_lasso_sk, **cmap_args)
+plt.title("Lasso from Scikit-learn", fontsize=18)
+plt.xticks(fontsize=18)
+plt.yticks(fontsize=18)
+cb = fig.colorbar(im)
+cb.ax.set_yticklabels(cb.ax.get_yticklabels(), fontsize=18)
+
+plt.show()
+!ec
+
+It is quite striking how LASSO breaks the symmetry of the coupling
+constant as opposed to ridge and OLS. We get a sparse solution with
+$J_{j, j + 1} = -1$.
+
+
+!split
+===== Performance of the different models =====
+
+In order to judge which model performs best at varying values of $\lambda$ (for ridge and LASSO) we compute $R^2$ which is given by
+
+!bt
+\begin{align}
+ R^2 = 1 - \frac{(y - \hat{y})^2}{(y - \bar{y})^2},
+\end{align}
+!et
+where $y$ is a vector with the true values of the energy, $\hat{y}$ is the predicted values of $y$ from the models and $\bar{y}$ is the mean of $\hat{y}$.
+
+
+!bc pycod
+def r_squared(y, y_hat):
+ return 1 - np.sum((y - y_hat) ** 2) / np.sum((y - np.mean(y_hat)) ** 2)
+!ec
+
+This is the same metric used by Scikit-learn for their regression models when scoring.
+!bc pycod
+y_hat = clf.predict(X_test)
+r_test = r_squared(y_test, y_hat)
+sk_r_test = clf.score(X_test, y_test)
+
+assert abs(r_test - sk_r_test) < 1e-2
+!ec
+
+
+!split
+===== Performance as function of the regularization parameter =====
+
+We see how the different models perform for a different set of values for $\lambda$.
+
+
+!bc pycod
+lambdas = np.logspace(-4, 5, 10)
+
+train_errors = {
+ "ols_own": np.zeros(lambdas.size),
+ "ols_sk": np.zeros(lambdas.size),
+ "ridge_own": np.zeros(lambdas.size),
+ "ridge_sk": np.zeros(lambdas.size),
+ "lasso_sk": np.zeros(lambdas.size)
+}
+
+test_errors = {
+ "ols_own": np.zeros(lambdas.size),
+ "ols_sk": np.zeros(lambdas.size),
+ "ridge_own": np.zeros(lambdas.size),
+ "ridge_sk": np.zeros(lambdas.size),
+ "lasso_sk": np.zeros(lambdas.size)
+}
+
+plot_counter = 1
+
+fig = plt.figure(figsize=(32, 54))
+
+for i, _lambda in enumerate(tqdm.tqdm(lambdas)):
+ omega = get_ols_weights(X_train_own, y_train)
+ y_hat_train = X_train_own @ omega
+ y_hat_test = X_test_own @ omega
+
+ train_errors["ols_own"][i] = r_squared(y_train, y_hat_train)
+ test_errors["ols_own"][i] = r_squared(y_test, y_hat_test)
+
+ plt.subplot(10, 5, plot_counter)
+ plt.imshow(omega[1:].reshape(L, L), **cmap_args)
+ plt.title("Home made OLS")
+ plot_counter += 1
+
+ omega = get_ridge_weights(X_train_own, y_train, _lambda)
+ y_hat_train = X_train_own @ omega
+ y_hat_test = X_test_own @ omega
+
+ train_errors["ridge_own"][i] = r_squared(y_train, y_hat_train)
+ test_errors["ridge_own"][i] = r_squared(y_test, y_hat_test)
+
+ plt.subplot(10, 5, plot_counter)
+ plt.imshow(omega[1:].reshape(L, L), **cmap_args)
+ plt.title(r"Home made ridge, $\lambda = %.4f$" % _lambda)
+ plot_counter += 1
+
+ for key, method in zip(
+ ["ols_sk", "ridge_sk", "lasso_sk"],
+ [skl.LinearRegression(), skl.Ridge(alpha=_lambda), skl.Lasso(alpha=_lambda)]
+ ):
+ method = method.fit(X_train, y_train)
+
+ train_errors[key][i] = method.score(X_train, y_train)
+ test_errors[key][i] = method.score(X_test, y_test)
+
+ omega = method.coef_.reshape(L, L)
+
+ plt.subplot(10, 5, plot_counter)
+ plt.imshow(omega, **cmap_args)
+ plt.title(r"%s, $\lambda = %.4f$" % (key, _lambda))
+ plot_counter += 1
+
+plt.show()
+!ec
+
+We can see that LASSO quite fast reaches a good solution for low
+values of $\lambda$, but will "wither" when we increase $\lambda$ too
+much. Ridge is more stable over a larger range of values for
+$\lambda$, but eventually also fades away.
+
+!split
+===== Finding the optimal value of $\lambda$ =====
+
+To determine which value of $\lambda$ is best we plot the accuracy of
+the models when predicting the training and the testing set. We expect
+the accuracy of the training set to be quite good, but if the accuracy
+of the testing set is much lower this tells us that we might be
+subject to an overfit model. The ideal scenario is an accuracy on the
+testing set that is close to the accuracy of the training set.
+
+
+!bc pycod
+fig = plt.figure(figsize=(20, 14))
+
+colors = {
+ "ols_own": "b",
+ "ridge_own": "g",
+ "ols_sk": "r",
+ "ridge_sk": "y",
+ "lasso_sk": "c"
+}
+
+for key in train_errors:
+ plt.semilogx(
+ lambdas,
+ train_errors[key],
+ colors[key],
+ label="Train {0}".format(key),
+ linewidth=4.0
+ )
+
+for key in test_errors:
+ plt.semilogx(
+ lambdas,
+ test_errors[key],
+ colors[key] + "--",
+ label="Test {0}".format(key),
+ linewidth=4.0
+ )
+#plt.semilogx(lambdas, train_errors["ols_own"], label="Train (OLS own)")
+#plt.semilogx(lambdas, test_errors["ols_own"], label="Test (OLS own)")
+
+plt.legend(loc="best", fontsize=18)
+plt.xlabel(r"$\lambda$", fontsize=18)
+plt.ylabel(r"$R^2$", fontsize=18)
+plt.tick_params(labelsize=18)
+plt.show()
+!ec
+
+From the above figure we can see that LASSO with $\lambda = 10^{-2}$
+achieve a very good accuracy on the test set. This by far surpases the
+other models for all values of $\lambda$.