diff --git a/doc/pub/How2ReadData/html/How2ReadData-bs.html b/doc/pub/How2ReadData/html/How2ReadData-bs.html index 3c6bc2386..9b92fb382 100644 --- a/doc/pub/How2ReadData/html/How2ReadData-bs.html +++ b/doc/pub/How2ReadData/html/How2ReadData-bs.html @@ -49,33 +49,33 @@ Automatically generated HTML file from DocOnce source 2, None, '___sec5'), - ('Predator-Prey model from ecology', 2, None, '___sec6'), - ('Case study from Hudson bay', 2, None, '___sec7'), - ('Hudson bay data', 2, None, '___sec8'), - ('Plotting the data', 2, None, '___sec9'), + ('Non-Linear Least squares in R', 2, None, '___sec6'), + ('Predator-Prey model from ecology', 2, None, '___sec7'), + ('Case study from Hudson bay', 2, None, '___sec8'), + ('Hudson bay data', 2, None, '___sec9'), + ('Plotting the data', 2, None, '___sec10'), ('Hares and lynx in Hudson bay from 1900 to 1920', 2, None, - '___sec10'), + '___sec11'), ('Why now create a computer model for the hare and lynx ' 'populations?', 2, None, - '___sec11'), - ('The traditional (top-down) approach', 2, None, '___sec12'), - ('Basic mathematics notation', 2, None, '___sec13'), + '___sec12'), + ('The traditional (top-down) approach', 2, None, '___sec13'), + ('Basic mathematics notation', 2, None, '___sec14'), ('Basic dynamics of the population of hares', 2, None, - '___sec14'), - ('Basic dynamics of the population of lynx', 2, None, '___sec15'), - ('Evolution equations', 2, None, '___sec16'), - ('Adapt the model to the Hudson Bay case', 2, None, '___sec17'), - ('The program', 2, None, '___sec18'), - ('The plot', 2, None, '___sec19'), - ('Linear regression in Python', 2, None, '___sec20'), - ('Linear Least squares in R', 2, None, '___sec21'), - ('Non-Linear Least squares in R', 2, None, '___sec22'), + '___sec15'), + ('Basic dynamics of the population of lynx', 2, None, '___sec16'), + ('Evolution equations', 2, None, '___sec17'), + ('Adapt the model to the Hudson Bay case', 2, None, '___sec18'), + ('The program', 2, None, '___sec19'), + ('The plot', 2, None, '___sec20'), + ('Linear regression in Python', 2, None, '___sec21'), + ('Linear Least squares in R', 2, None, '___sec22'), ('Example: ecoli lab experiment', 2, None, '___sec23'), ('The program', 2, None, '___sec24'), ('The output', 2, None, '___sec25'), @@ -133,23 +133,23 @@ MathJax.Hub.Config({
-
@@ -224,16 +224,20 @@ then use machine learning algorithms included in for example scikit-learn.
-These examples will serve us the purpose of getting started. Furthermore, they -allow us to catch more than two birds with a stone. They will allow us -to bring in some programming specific topics and tools as well as -showing the power of various Python (and R) packages for machine -learning and statistical data analysis. In the lectures on linear -algebra we cover in more detail various programming features of languages like Python and C++ (and other), we will also look into more specific linear functions which -are relevant for the various algorithms we will discuss. Here, we will -mainly focus on two specific Python packages for Machine Learning, -scikit-learn and tensorflow (see below for links etc). -Moreover, the examples we introduce will serve as inputs to many of our discussions later, as well as allowing you to set up models and produce your own data and get started with programming. +These examples will serve us the purpose of getting +started. Furthermore, they allow us to catch more than two birds with +a stone. They will allow us to bring in some programming specific +topics and tools as well as showing the power of various Python (and +R) packages for machine learning and statistical data analysis. In the +lectures on linear algebra we cover in more detail various programming +features of languages like Python and C++ (and other), we will also +look into more specific linear functions which are relevant for the +various algorithms we will discuss. Here, we will mainly focus on two +specific Python packages for Machine Learning, scikit-learn and +tensorflow (see below for links etc). Moreover, the examples we +introduce will serve as inputs to many of our discussions later, as +well as allowing you to set up models and produce your own data and +get started with programming.
@@ -618,7 +622,86 @@ years etc.
We will discuss in more -detail these and more function in the various lectures. +detail these and other functions in the various lectures. We conclude this part with another example. Instead of +a linear \( x \)-dependence we study now a cubic polynomial and use the polynomial regression analysis tools of scikit-learn. + +
+ + +
import numpy as np
+import matplotlib.pyplot as plt
+from sklearn.linear_model import Ridge
+from sklearn.preprocessing import PolynomialFeatures
+from sklearn.pipeline import make_pipeline
+
+def f(x):
+ """ function to approximate by polynomial interpolation"""
+ return x*x*x
+
+# generate points used to plot
+x_plot = np.linspace(0, 10, 100)
+
+# generate points and keep a subset of them
+x = np.linspace(0, 10, 100)
+rng = np.random.RandomState(0)
+rng.shuffle(x)
+x = np.sort(x[:20])
+y = f(x)
+# create matrix versions of these arrays
+X = x[:, np.newaxis]
+X_plot = x_plot[:, np.newaxis]
+
+colors = ['teal', 'yellowgreen', 'gold']
+lw = 2
+plt.plot(x_plot, f(x_plot), color='cornflowerblue', linewidth=lw,
+ label="ground truth")
+plt.scatter(x, y, color='navy', s=30, marker='o', label="training points")
+
+for count, degree in enumerate([3, 4, 5]):
+ model = make_pipeline(PolynomialFeatures(degree), Ridge())
+ model.fit(X, y)
+ y_plot = model.predict(X_plot)
+ plt.plot(x_plot, y_plot, color=colors[count], linewidth=lw,
+ label="degree %d" % degree)
+
+plt.legend(loc='lower left')
+
+plt.show()
++ + +
+
+ + +
set.seed(1485)
+len = 24
+x = runif(len)
+y = x^3+rnorm(len, 0,0.06)
+ds = data.frame(x = x, y = y)
+str(ds)
+plot( y ~ x, main ="Known cubic with noise")
+s = seq(0,1,length =100)
+lines(s, s^3, lty =2, col ="green")
+m = nls(y ~ I(x^power), data = ds, start = list(power=1), trace = T)
+class(m)
+summary(m)
+power = round(summary(m)$coefficients[1], 3)
+power.se = round(summary(m)$coefficients[2], 3)
+plot(y ~ x, main = "Fitted power model", sub = "Blue: fit; green: known")
+s = seq(0, 1, length = 100)
+lines(s, s^3, lty = 2, col = "green")
+lines(s, predict(m, list(x = s)), lty = 1, col = "blue")
+text(0, 0.5, paste("y =x^ (", power, " +/- ", power.se, ")", sep = ""), pos = 4)
++
Another useful Python package is @@ -638,7 +721,7 @@ display(data_pandas)
-
-
-
-
-

-
@@ -819,7 +902,7 @@ climate and other complicating factors. How significant are these?
-
-
@@ -874,7 +957,7 @@ ODEs (which cannot be solved)
-
-
-
-
-
-

-
@@ -1094,7 +1177,7 @@ plt.show()
-
@@ -1126,41 +1209,6 @@ predict(linearMod,data.frame(Year
-
-
-
-
-
-
-
-
-
diff --git a/doc/pub/How2ReadData/html/How2ReadData-reveal.html b/doc/pub/How2ReadData/html/How2ReadData-reveal.html
index 1aa9ac1b8..519fc4df6 100644
--- a/doc/pub/How2ReadData/html/How2ReadData-reveal.html
+++ b/doc/pub/How2ReadData/html/How2ReadData-reveal.html
@@ -148,7 +148,7 @@ MathJax.Hub.Config({
@@ -184,16 +184,20 @@ then use machine learning algorithms included in for example
scikit-learn.
-These examples will serve us the purpose of getting started. Furthermore, they
-allow us to catch more than two birds with a stone. They will allow us
-to bring in some programming specific topics and tools as well as
-showing the power of various Python (and R) packages for machine
-learning and statistical data analysis. In the lectures on linear
-algebra we cover in more detail various programming features of languages like Python and C++ (and other), we will also look into more specific linear functions which
-are relevant for the various algorithms we will discuss. Here, we will
-mainly focus on two specific Python packages for Machine Learning,
-scikit-learn and tensorflow (see below for links etc).
-Moreover, the examples we introduce will serve as inputs to many of our discussions later, as well as allowing you to set up models and produce your own data and get started with programming.
+These examples will serve us the purpose of getting
+started. Furthermore, they allow us to catch more than two birds with
+a stone. They will allow us to bring in some programming specific
+topics and tools as well as showing the power of various Python (and
+R) packages for machine learning and statistical data analysis. In the
+lectures on linear algebra we cover in more detail various programming
+features of languages like Python and C++ (and other), we will also
+look into more specific linear functions which are relevant for the
+various algorithms we will discuss. Here, we will mainly focus on two
+specific Python packages for Machine Learning, scikit-learn and
+tensorflow (see below for links etc). Moreover, the examples we
+introduce will serve as inputs to many of our discussions later, as
+well as allowing you to set up models and produce your own data and
+get started with programming.
@@ -601,7 +605,84 @@ years etc.
We will discuss in more
-detail these and more function in the various lectures.
+detail these and other functions in the various lectures. We conclude this part with another example. Instead of
+a linear \( x \)-dependence we study now a cubic polynomial and use the polynomial regression analysis tools of scikit-learn.
+
+
+
+
+
+
+
+
Another useful Python package is
@@ -622,7 +703,7 @@ display(data_pandas)
@@ -785,7 +866,7 @@ climate and other complicating factors. How significant are these?
@@ -1048,7 +1129,7 @@ plt.show()
@@ -1079,38 +1160,6 @@ predict(linearMod,data.frame
-
-
-
-
-
-These examples will serve us the purpose of getting started. Furthermore, they
-allow us to catch more than two birds with a stone. They will allow us
-to bring in some programming specific topics and tools as well as
-showing the power of various Python (and R) packages for machine
-learning and statistical data analysis. In the lectures on linear
-algebra we cover in more detail various programming features of languages like Python and C++ (and other), we will also look into more specific linear functions which
-are relevant for the various algorithms we will discuss. Here, we will
-mainly focus on two specific Python packages for Machine Learning,
-scikit-learn and tensorflow (see below for links etc).
-Moreover, the examples we introduce will serve as inputs to many of our discussions later, as well as allowing you to set up models and produce your own data and get started with programming.
+These examples will serve us the purpose of getting
+started. Furthermore, they allow us to catch more than two birds with
+a stone. They will allow us to bring in some programming specific
+topics and tools as well as showing the power of various Python (and
+R) packages for machine learning and statistical data analysis. In the
+lectures on linear algebra we cover in more detail various programming
+features of languages like Python and C++ (and other), we will also
+look into more specific linear functions which are relevant for the
+various algorithms we will discuss. Here, we will mainly focus on two
+specific Python packages for Machine Learning, scikit-learn and
+tensorflow (see below for links etc). Moreover, the examples we
+introduce will serve as inputs to many of our discussions later, as
+well as allowing you to set up models and produce your own data and
+get started with programming.
We will discuss in more
-detail these and more function in the various lectures.
+detail these and other functions in the various lectures. We conclude this part with another example. Instead of
+a linear \( x \)-dependence we study now a cubic polynomial and use the polynomial regression analysis tools of scikit-learn.
+
+
+
+
+
+
+
+
+
+
Another useful Python package is
@@ -595,7 +677,7 @@ display(data_pandas)
@@ -766,7 +848,7 @@ climate and other complicating factors. How significant are these?
@@ -819,7 +901,7 @@ ODEs (which cannot be solved)
@@ -1032,7 +1114,7 @@ plt.show()
@@ -1063,40 +1145,6 @@ predict(linearMod,data.frame
-
-
-
-
-
-
-
-These examples will serve us the purpose of getting started. Furthermore, they
-allow us to catch more than two birds with a stone. They will allow us
-to bring in some programming specific topics and tools as well as
-showing the power of various Python (and R) packages for machine
-learning and statistical data analysis. In the lectures on linear
-algebra we cover in more detail various programming features of languages like Python and C++ (and other), we will also look into more specific linear functions which
-are relevant for the various algorithms we will discuss. Here, we will
-mainly focus on two specific Python packages for Machine Learning,
-scikit-learn and tensorflow (see below for links etc).
-Moreover, the examples we introduce will serve as inputs to many of our discussions later, as well as allowing you to set up models and produce your own data and get started with programming.
+These examples will serve us the purpose of getting
+started. Furthermore, they allow us to catch more than two birds with
+a stone. They will allow us to bring in some programming specific
+topics and tools as well as showing the power of various Python (and
+R) packages for machine learning and statistical data analysis. In the
+lectures on linear algebra we cover in more detail various programming
+features of languages like Python and C++ (and other), we will also
+look into more specific linear functions which are relevant for the
+various algorithms we will discuss. Here, we will mainly focus on two
+specific Python packages for Machine Learning, scikit-learn and
+tensorflow (see below for links etc). Moreover, the examples we
+introduce will serve as inputs to many of our discussions later, as
+well as allowing you to set up models and produce your own data and
+get started with programming.
We will discuss in more
-detail these and more function in the various lectures.
+detail these and other functions in the various lectures. We conclude this part with another example. Instead of
+a linear \( x \)-dependence we study now a cubic polynomial and use the polynomial regression analysis tools of scikit-learn.
+
+
+
+
+
+
+
+
+
+
Another useful Python package is
@@ -600,7 +682,7 @@ display(data_pandas)
@@ -771,7 +853,7 @@ climate and other complicating factors. How significant are these?
@@ -824,7 +906,7 @@ ODEs (which cannot be solved)
@@ -1037,7 +1119,7 @@ plt.show()
@@ -1068,40 +1150,6 @@ predict(linearMod,data.frame(Year
-
-
-
-
-
-
Non-Linear Least squares in R
-set.seed(1485)
-len = 24
-x = runif(len)
-y = x^3+rnorm(len, 0,0.06)
-ds = data.frame(x = x, y = y)
-str(ds)
-plot( y ~ x, main ="Known cubic with noise")
-s = seq(0,1,length =100)
-lines(s, s^3, lty =2, col ="green")
-m = nls(y ~ I(x^power), data = ds, start = list(power=1), trace = T)
-class(m)
-summary(m)
-power = round(summary(m)$coefficients[1], 3)
-power.se = round(summary(m)$coefficients[2], 3)
-plot(y ~ x, main = "Fitted power model", sub = "Blue: fit; green: known")
-s = seq(0, 1, length = 100)
-lines(s, s^3, lty = 2, col = "green")
-lines(s, predict(m, list(x = s)), lty = 1, col = "blue")
-text(0, 0.5, paste("y =x^ (", power, " +/- ", power.se, ")", sep = ""), pos = 4)
-
-May 28, 2018
May 29, 2018
import numpy as np
+import matplotlib.pyplot as plt
+from sklearn.linear_model import Ridge
+from sklearn.preprocessing import PolynomialFeatures
+from sklearn.pipeline import make_pipeline
+
+def f(x):
+ """ function to approximate by polynomial interpolation"""
+ return x*x*x
+
+# generate points used to plot
+x_plot = np.linspace(0, 10, 100)
+
+# generate points and keep a subset of them
+x = np.linspace(0, 10, 100)
+rng = np.random.RandomState(0)
+rng.shuffle(x)
+x = np.sort(x[:20])
+y = f(x)
+# create matrix versions of these arrays
+X = x[:, np.newaxis]
+X_plot = x_plot[:, np.newaxis]
+
+colors = ['teal', 'yellowgreen', 'gold']
+lw = 2
+plt.plot(x_plot, f(x_plot), color='cornflowerblue', linewidth=lw,
+ label="ground truth")
+plt.scatter(x, y, color='navy', s=30, marker='o', label="training points")
+
+for count, degree in enumerate([3, 4, 5]):
+ model = make_pipeline(PolynomialFeatures(degree), Ridge())
+ model.fit(X, y)
+ y_plot = model.predict(X_plot)
+ plt.plot(x_plot, y_plot, color=colors[count], linewidth=lw,
+ label="degree %d" % degree)
+
+plt.legend(loc='lower left')
+
+plt.show()
+
Non-Linear Least squares in R
+set.seed(1485)
+len = 24
+x = runif(len)
+y = x^3+rnorm(len, 0,0.06)
+ds = data.frame(x = x, y = y)
+str(ds)
+plot( y ~ x, main ="Known cubic with noise")
+s = seq(0,1,length =100)
+lines(s, s^3, lty =2, col ="green")
+m = nls(y ~ I(x^power), data = ds, start = list(power=1), trace = T)
+class(m)
+summary(m)
+power = round(summary(m)$coefficients[1], 3)
+power.se = round(summary(m)$coefficients[2], 3)
+plot(y ~ x, main = "Fitted power model", sub = "Blue: fit; green: known")
+s = seq(0, 1, length = 100)
+lines(s, s^3, lty = 2, col = "green")
+lines(s, predict(m, list(x = s)), lty = 1, col = "blue")
+text(0, 0.5, paste("y =x^ (", power, " +/- ", power.se, ")", sep = ""), pos = 4)
+
Predator-Prey model from ecology
+Predator-Prey model from ecology
Case study from Hudson bay
+Case study from Hudson bay
Hudson bay data
+Hudson bay data
Plotting the data
+Plotting the data
Hares and lynx in Hudson bay from 1900 to 1920
+Hares and lynx in Hudson bay from 1900 to 1920

@@ -753,7 +834,7 @@ plt.show()
Why now create a computer model for the hare and lynx populations?
+Why now create a computer model for the hare and lynx populations?
The traditional (top-down) approach
+The traditional (top-down) approach
Basic mathematics notation
+Basic mathematics notation
@@ -837,7 +918,7 @@ ODEs (which cannot be solved)
Basic dynamics of the population of hares
+Basic dynamics of the population of hares
Basic dynamics of the population of lynx
+Basic dynamics of the population of lynx
Evolution equations
+Evolution equations
Adapt the model to the Hudson Bay case
+Adapt the model to the Hudson Bay case
The program
+The program
The plot
+The plot

@@ -1017,7 +1098,7 @@ If we perform a least-square fitting, we can find optimal values for the paramet
Linear regression in Python
+Linear regression in Python
Linear Least squares in R
+Linear Least squares in R
Non-Linear Least squares in R
-set.seed(1485)
-len = 24
-x = runif(len)
-y = x^3+rnorm(len, 0,0.06)
-ds = data.frame(x = x, y = y)
-str(ds)
-plot( y ~ x, main ="Known cubic with noise")
-s = seq(0,1,length =100)
-lines(s, s^3, lty =2, col ="green")
-m = nls(y ~ I(x^power), data = ds, start = list(power=1), trace = T)
-class(m)
-summary(m)
-power = round(summary(m)$coefficients[1], 3)
-power.se = round(summary(m)$coefficients[2], 3)
-plot(y ~ x, main = "Fitted power model", sub = "Blue: fit; green: known")
-s = seq(0, 1, length = 100)
-lines(s, s^3, lty = 2, col = "green")
-lines(s, predict(m, list(x = s)), lty = 1, col = "blue")
-text(0, 0.5, paste("y =x^ (", power, " +/- ", power.se, ")", sep = ""), pos = 4)
-
Example: ecoli lab experiment
diff --git a/doc/pub/How2ReadData/html/How2ReadData-solarized.html b/doc/pub/How2ReadData/html/How2ReadData-solarized.html
index 8814a5e31..fead58baf 100644
--- a/doc/pub/How2ReadData/html/How2ReadData-solarized.html
+++ b/doc/pub/How2ReadData/html/How2ReadData-solarized.html
@@ -69,33 +69,33 @@ div { text-align: justify; text-justify: inter-word; }
2,
None,
'___sec5'),
- ('Predator-Prey model from ecology', 2, None, '___sec6'),
- ('Case study from Hudson bay', 2, None, '___sec7'),
- ('Hudson bay data', 2, None, '___sec8'),
- ('Plotting the data', 2, None, '___sec9'),
+ ('Non-Linear Least squares in R', 2, None, '___sec6'),
+ ('Predator-Prey model from ecology', 2, None, '___sec7'),
+ ('Case study from Hudson bay', 2, None, '___sec8'),
+ ('Hudson bay data', 2, None, '___sec9'),
+ ('Plotting the data', 2, None, '___sec10'),
('Hares and lynx in Hudson bay from 1900 to 1920',
2,
None,
- '___sec10'),
+ '___sec11'),
('Why now create a computer model for the hare and lynx '
'populations?',
2,
None,
- '___sec11'),
- ('The traditional (top-down) approach', 2, None, '___sec12'),
- ('Basic mathematics notation', 2, None, '___sec13'),
+ '___sec12'),
+ ('The traditional (top-down) approach', 2, None, '___sec13'),
+ ('Basic mathematics notation', 2, None, '___sec14'),
('Basic dynamics of the population of hares',
2,
None,
- '___sec14'),
- ('Basic dynamics of the population of lynx', 2, None, '___sec15'),
- ('Evolution equations', 2, None, '___sec16'),
- ('Adapt the model to the Hudson Bay case', 2, None, '___sec17'),
- ('The program', 2, None, '___sec18'),
- ('The plot', 2, None, '___sec19'),
- ('Linear regression in Python', 2, None, '___sec20'),
- ('Linear Least squares in R', 2, None, '___sec21'),
- ('Non-Linear Least squares in R', 2, None, '___sec22'),
+ '___sec15'),
+ ('Basic dynamics of the population of lynx', 2, None, '___sec16'),
+ ('Evolution equations', 2, None, '___sec17'),
+ ('Adapt the model to the Hudson Bay case', 2, None, '___sec18'),
+ ('The program', 2, None, '___sec19'),
+ ('The plot', 2, None, '___sec20'),
+ ('Linear regression in Python', 2, None, '___sec21'),
+ ('Linear Least squares in R', 2, None, '___sec22'),
('Example: ecoli lab experiment', 2, None, '___sec23'),
('The program', 2, None, '___sec24'),
('The output', 2, None, '___sec25'),
@@ -151,7 +151,7 @@ MathJax.Hub.Config({
May 28, 2018
May 29, 2018
@@ -181,16 +181,20 @@ then use machine learning algorithms included in for example
scikit-learn.
@@ -575,7 +579,85 @@ years etc.
import numpy as np
+import matplotlib.pyplot as plt
+from sklearn.linear_model import Ridge
+from sklearn.preprocessing import PolynomialFeatures
+from sklearn.pipeline import make_pipeline
+
+def f(x):
+ """ function to approximate by polynomial interpolation"""
+ return x*x*x
+
+# generate points used to plot
+x_plot = np.linspace(0, 10, 100)
+
+# generate points and keep a subset of them
+x = np.linspace(0, 10, 100)
+rng = np.random.RandomState(0)
+rng.shuffle(x)
+x = np.sort(x[:20])
+y = f(x)
+# create matrix versions of these arrays
+X = x[:, np.newaxis]
+X_plot = x_plot[:, np.newaxis]
+
+colors = ['teal', 'yellowgreen', 'gold']
+lw = 2
+plt.plot(x_plot, f(x_plot), color='cornflowerblue', linewidth=lw,
+ label="ground truth")
+plt.scatter(x, y, color='navy', s=30, marker='o', label="training points")
+
+for count, degree in enumerate([3, 4, 5]):
+ model = make_pipeline(PolynomialFeatures(degree), Ridge())
+ model.fit(X, y)
+ y_plot = model.predict(X_plot)
+ plt.plot(x_plot, y_plot, color=colors[count], linewidth=lw,
+ label="degree %d" % degree)
+
+plt.legend(loc='lower left')
+
+plt.show()
+
+
+Non-Linear Least squares in R
+set.seed(1485)
+len = 24
+x = runif(len)
+y = x^3+rnorm(len, 0,0.06)
+ds = data.frame(x = x, y = y)
+str(ds)
+plot( y ~ x, main ="Known cubic with noise")
+s = seq(0,1,length =100)
+lines(s, s^3, lty =2, col ="green")
+m = nls(y ~ I(x^power), data = ds, start = list(power=1), trace = T)
+class(m)
+summary(m)
+power = round(summary(m)$coefficients[1], 3)
+power.se = round(summary(m)$coefficients[2], 3)
+plot(y ~ x, main = "Fitted power model", sub = "Blue: fit; green: known")
+s = seq(0, 1, length = 100)
+lines(s, s^3, lty = 2, col = "green")
+lines(s, predict(m, list(x = s)), lty = 1, col = "blue")
+text(0, 0.5, paste("y =x^ (", power, " +/- ", power.se, ")", sep = ""), pos = 4)
+
-Predator-Prey model from ecology
+Predator-Prey model from ecology
-Case study from Hudson bay
+Case study from Hudson bay
-Hudson bay data
+Hudson bay data
-Plotting the data
+Plotting the data
-Hares and lynx in Hudson bay from 1900 to 1920
+Hares and lynx in Hudson bay from 1900 to 1920

@@ -733,7 +815,7 @@ plt.show()
-Why now create a computer model for the hare and lynx populations?
+Why now create a computer model for the hare and lynx populations?
-The traditional (top-down) approach
+The traditional (top-down) approach
-Basic mathematics notation
+Basic mathematics notation
-Basic dynamics of the population of hares
+Basic dynamics of the population of hares
-Basic dynamics of the population of lynx
+Basic dynamics of the population of lynx
-Evolution equations
+Evolution equations
-Adapt the model to the Hudson Bay case
+Adapt the model to the Hudson Bay case
-The program
+The program
-The plot
+The plot

@@ -999,7 +1081,7 @@ If we perform a least-square fitting, we can find optimal values for the paramet
-Linear regression in Python
+Linear regression in Python
-Linear Least squares in R
+Linear Least squares in R
-
-Non-Linear Least squares in R
-set.seed(1485)
-len = 24
-x = runif(len)
-y = x^3+rnorm(len, 0,0.06)
-ds = data.frame(x = x, y = y)
-str(ds)
-plot( y ~ x, main ="Known cubic with noise")
-s = seq(0,1,length =100)
-lines(s, s^3, lty =2, col ="green")
-m = nls(y ~ I(x^power), data = ds, start = list(power=1), trace = T)
-class(m)
-summary(m)
-power = round(summary(m)$coefficients[1], 3)
-power.se = round(summary(m)$coefficients[2], 3)
-plot(y ~ x, main = "Fitted power model", sub = "Blue: fit; green: known")
-s = seq(0, 1, length = 100)
-lines(s, s^3, lty = 2, col = "green")
-lines(s, predict(m, list(x = s)), lty = 1, col = "blue")
-text(0, 0.5, paste("y =x^ (", power, " +/- ", power.se, ")", sep = ""), pos = 4)
-
diff --git a/doc/pub/How2ReadData/html/How2ReadData.html b/doc/pub/How2ReadData/html/How2ReadData.html
index 6a37184b9..ded14b424 100644
--- a/doc/pub/How2ReadData/html/How2ReadData.html
+++ b/doc/pub/How2ReadData/html/How2ReadData.html
@@ -74,33 +74,33 @@ div { text-align: justify; text-justify: inter-word; }
2,
None,
'___sec5'),
- ('Predator-Prey model from ecology', 2, None, '___sec6'),
- ('Case study from Hudson bay', 2, None, '___sec7'),
- ('Hudson bay data', 2, None, '___sec8'),
- ('Plotting the data', 2, None, '___sec9'),
+ ('Non-Linear Least squares in R', 2, None, '___sec6'),
+ ('Predator-Prey model from ecology', 2, None, '___sec7'),
+ ('Case study from Hudson bay', 2, None, '___sec8'),
+ ('Hudson bay data', 2, None, '___sec9'),
+ ('Plotting the data', 2, None, '___sec10'),
('Hares and lynx in Hudson bay from 1900 to 1920',
2,
None,
- '___sec10'),
+ '___sec11'),
('Why now create a computer model for the hare and lynx '
'populations?',
2,
None,
- '___sec11'),
- ('The traditional (top-down) approach', 2, None, '___sec12'),
- ('Basic mathematics notation', 2, None, '___sec13'),
+ '___sec12'),
+ ('The traditional (top-down) approach', 2, None, '___sec13'),
+ ('Basic mathematics notation', 2, None, '___sec14'),
('Basic dynamics of the population of hares',
2,
None,
- '___sec14'),
- ('Basic dynamics of the population of lynx', 2, None, '___sec15'),
- ('Evolution equations', 2, None, '___sec16'),
- ('Adapt the model to the Hudson Bay case', 2, None, '___sec17'),
- ('The program', 2, None, '___sec18'),
- ('The plot', 2, None, '___sec19'),
- ('Linear regression in Python', 2, None, '___sec20'),
- ('Linear Least squares in R', 2, None, '___sec21'),
- ('Non-Linear Least squares in R', 2, None, '___sec22'),
+ '___sec15'),
+ ('Basic dynamics of the population of lynx', 2, None, '___sec16'),
+ ('Evolution equations', 2, None, '___sec17'),
+ ('Adapt the model to the Hudson Bay case', 2, None, '___sec18'),
+ ('The program', 2, None, '___sec19'),
+ ('The plot', 2, None, '___sec20'),
+ ('Linear regression in Python', 2, None, '___sec21'),
+ ('Linear Least squares in R', 2, None, '___sec22'),
('Example: ecoli lab experiment', 2, None, '___sec23'),
('The program', 2, None, '___sec24'),
('The output', 2, None, '___sec25'),
@@ -156,7 +156,7 @@ MathJax.Hub.Config({
May 28, 2018
May 29, 2018
@@ -186,16 +186,20 @@ then use machine learning algorithms included in for example
scikit-learn.
@@ -580,7 +584,85 @@ years etc.
import numpy as np
+import matplotlib.pyplot as plt
+from sklearn.linear_model import Ridge
+from sklearn.preprocessing import PolynomialFeatures
+from sklearn.pipeline import make_pipeline
+
+def f(x):
+ """ function to approximate by polynomial interpolation"""
+ return x*x*x
+
+# generate points used to plot
+x_plot = np.linspace(0, 10, 100)
+
+# generate points and keep a subset of them
+x = np.linspace(0, 10, 100)
+rng = np.random.RandomState(0)
+rng.shuffle(x)
+x = np.sort(x[:20])
+y = f(x)
+# create matrix versions of these arrays
+X = x[:, np.newaxis]
+X_plot = x_plot[:, np.newaxis]
+
+colors = ['teal', 'yellowgreen', 'gold']
+lw = 2
+plt.plot(x_plot, f(x_plot), color='cornflowerblue', linewidth=lw,
+ label="ground truth")
+plt.scatter(x, y, color='navy', s=30, marker='o', label="training points")
+
+for count, degree in enumerate([3, 4, 5]):
+ model = make_pipeline(PolynomialFeatures(degree), Ridge())
+ model.fit(X, y)
+ y_plot = model.predict(X_plot)
+ plt.plot(x_plot, y_plot, color=colors[count], linewidth=lw,
+ label="degree %d" % degree)
+
+plt.legend(loc='lower left')
+
+plt.show()
+
+
+Non-Linear Least squares in R
+set.seed(1485)
+len = 24
+x = runif(len)
+y = x^3+rnorm(len, 0,0.06)
+ds = data.frame(x = x, y = y)
+str(ds)
+plot( y ~ x, main ="Known cubic with noise")
+s = seq(0,1,length =100)
+lines(s, s^3, lty =2, col ="green")
+m = nls(y ~ I(x^power), data = ds, start = list(power=1), trace = T)
+class(m)
+summary(m)
+power = round(summary(m)$coefficients[1], 3)
+power.se = round(summary(m)$coefficients[2], 3)
+plot(y ~ x, main = "Fitted power model", sub = "Blue: fit; green: known")
+s = seq(0, 1, length = 100)
+lines(s, s^3, lty = 2, col = "green")
+lines(s, predict(m, list(x = s)), lty = 1, col = "blue")
+text(0, 0.5, paste("y =x^ (", power, " +/- ", power.se, ")", sep = ""), pos = 4)
+
-Predator-Prey model from ecology
+Predator-Prey model from ecology
-Case study from Hudson bay
+Case study from Hudson bay
-Hudson bay data
+Hudson bay data
-Plotting the data
+Plotting the data
-Hares and lynx in Hudson bay from 1900 to 1920
+Hares and lynx in Hudson bay from 1900 to 1920

@@ -738,7 +820,7 @@ plt.show()
-Why now create a computer model for the hare and lynx populations?
+Why now create a computer model for the hare and lynx populations?
-The traditional (top-down) approach
+The traditional (top-down) approach
-Basic mathematics notation
+Basic mathematics notation
-Basic dynamics of the population of hares
+Basic dynamics of the population of hares
-Basic dynamics of the population of lynx
+Basic dynamics of the population of lynx
-Evolution equations
+Evolution equations
-Adapt the model to the Hudson Bay case
+Adapt the model to the Hudson Bay case
-The program
+The program
-The plot
+The plot

@@ -1004,7 +1086,7 @@ If we perform a least-square fitting, we can find optimal values for the paramet
-Linear regression in Python
+Linear regression in Python
-Linear Least squares in R
+Linear Least squares in R
-
-Non-Linear Least squares in R
-set.seed(1485)
-len = 24
-x = runif(len)
-y = x^3+rnorm(len, 0,0.06)
-ds = data.frame(x = x, y = y)
-str(ds)
-plot( y ~ x, main ="Known cubic with noise")
-s = seq(0,1,length =100)
-lines(s, s^3, lty =2, col ="green")
-m = nls(y ~ I(x^power), data = ds, start = list(power=1), trace = T)
-class(m)
-summary(m)
-power = round(summary(m)$coefficients[1], 3)
-power.se = round(summary(m)$coefficients[2], 3)
-plot(y ~ x, main = "Fitted power model", sub = "Blue: fit; green: known")
-s = seq(0, 1, length = 100)
-lines(s, s^3, lty = 2, col = "green")
-lines(s, predict(m, list(x = s)), lty = 1, col = "blue")
-text(0, 0.5, paste("y =x^ (", power, " +/- ", power.se, ")", sep = ""), pos = 4)
-
diff --git a/doc/pub/How2ReadData/ipynb/How2ReadData.ipynb b/doc/pub/How2ReadData/ipynb/How2ReadData.ipynb
index d10084e44..3e36c775f 100644
--- a/doc/pub/How2ReadData/ipynb/How2ReadData.ipynb
+++ b/doc/pub/How2ReadData/ipynb/How2ReadData.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: **May 28, 2018**\n",
+ "Date: **May 29, 2018**\n",
"\n",
"Copyright 1999-2018, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license\n",
"\n",
@@ -19,8 +19,6 @@
"\n",
"## Introduction\n",
"\n",
- "\n",
- "\n",
"Our emphasis throughout this series of lectures \n",
"is on understanding the mathematical aspects of\n",
"different algorithms used in the fields of data analysis and machine learning. \n",
@@ -41,16 +39,20 @@
"then use machine learning algorithms included in for example\n",
"**scikit-learn**. \n",
"\n",
- "These examples will serve us the purpose of getting started. Furthermore, they\n",
- "allow us to catch more than two birds with a stone. They will allow us\n",
- "to bring in some programming specific topics and tools as well as\n",
- "showing the power of various Python (and R) packages for machine\n",
- "learning and statistical data analysis. In the lectures on linear\n",
- "algebra we cover in more detail various programming features of languages like Python and C++ (and other), we will also look into more specific linear functions which\n",
- "are relevant for the various algorithms we will discuss. Here, we will\n",
- "mainly focus on two specific Python packages for Machine Learning,\n",
- "scikit-learn and tensorflow (see below for links etc).\n",
- "Moreover, the examples we introduce will serve as inputs to many of our discussions later, as well as allowing you to set up models and produce your own data and get started with programming. \n",
+ "These examples will serve us the purpose of getting\n",
+ "started. Furthermore, they allow us to catch more than two birds with\n",
+ "a stone. They will allow us to bring in some programming specific\n",
+ "topics and tools as well as showing the power of various Python (and\n",
+ "R) packages for machine learning and statistical data analysis. In the\n",
+ "lectures on linear algebra we cover in more detail various programming\n",
+ "features of languages like Python and C++ (and other), we will also\n",
+ "look into more specific linear functions which are relevant for the\n",
+ "various algorithms we will discuss. Here, we will mainly focus on two\n",
+ "specific Python packages for Machine Learning, scikit-learn and\n",
+ "tensorflow (see below for links etc). Moreover, the examples we\n",
+ "introduce will serve as inputs to many of our discussions later, as\n",
+ "well as allowing you to set up models and produce your own data and\n",
+ "get started with programming.\n",
"\n",
"\n",
"\n",
@@ -531,8 +533,95 @@
"years etc. \n",
"\n",
"We will discuss in more\n",
- "detail these and more function in the various lectures.\n",
+ "detail these and other functions in the various lectures. We conclude this part with another example. Instead of \n",
+ "a linear $x$-dependence we study now a cubic polynomial and use the polynomial regression analysis tools of scikit-learn."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "import numpy as np\n",
+ "import matplotlib.pyplot as plt\n",
+ "from sklearn.linear_model import Ridge\n",
+ "from sklearn.preprocessing import PolynomialFeatures\n",
+ "from sklearn.pipeline import make_pipeline\n",
"\n",
+ "def f(x):\n",
+ " \"\"\" function to approximate by polynomial interpolation\"\"\"\n",
+ " return x*x*x\n",
+ "\n",
+ "# generate points used to plot \n",
+ "x_plot = np.linspace(0, 10, 100)\n",
+ "\n",
+ "# generate points and keep a subset of them \n",
+ "x = np.linspace(0, 10, 100)\n",
+ "rng = np.random.RandomState(0)\n",
+ "rng.shuffle(x)\n",
+ "x = np.sort(x[:20])\n",
+ "y = f(x)\n",
+ "# create matrix versions of these arrays \n",
+ "X = x[:, np.newaxis]\n",
+ "X_plot = x_plot[:, np.newaxis]\n",
+ "\n",
+ "colors = ['teal', 'yellowgreen', 'gold']\n",
+ "lw = 2\n",
+ "plt.plot(x_plot, f(x_plot), color='cornflowerblue', linewidth=lw,\n",
+ " label=\"ground truth\")\n",
+ "plt.scatter(x, y, color='navy', s=30, marker='o', label=\"training points\")\n",
+ "\n",
+ "for count, degree in enumerate([3, 4, 5]):\n",
+ " model = make_pipeline(PolynomialFeatures(degree), Ridge())\n",
+ " model.fit(X, y)\n",
+ " y_plot = model.predict(X_plot)\n",
+ " plt.plot(x_plot, y_plot, color=colors[count], linewidth=lw,\n",
+ " label=\"degree %d\" % degree)\n",
+ "\n",
+ "plt.legend(loc='lower left')\n",
+ "\n",
+ "plt.show()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Non-Linear Least squares in R"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ " set.seed(1485)\n",
+ " len = 24\n",
+ " x = runif(len)\n",
+ " y = x^3+rnorm(len, 0,0.06)\n",
+ " ds = data.frame(x = x, y = y)\n",
+ " str(ds)\n",
+ " plot( y ~ x, main =\"Known cubic with noise\")\n",
+ " s = seq(0,1,length =100)\n",
+ " lines(s, s^3, lty =2, col =\"green\")\n",
+ " m = nls(y ~ I(x^power), data = ds, start = list(power=1), trace = T)\n",
+ " class(m)\n",
+ " summary(m)\n",
+ " power = round(summary(m)$coefficients[1], 3)\n",
+ " power.se = round(summary(m)$coefficients[2], 3)\n",
+ " plot(y ~ x, main = \"Fitted power model\", sub = \"Blue: fit; green: known\")\n",
+ " s = seq(0, 1, length = 100)\n",
+ " lines(s, s^3, lty = 2, col = \"green\")\n",
+ " lines(s, predict(m, list(x = s)), lty = 1, col = \"blue\")\n",
+ " text(0, 0.5, paste(\"y =x^ (\", power, \" +/- \", power.se, \")\", sep = \"\"), pos = 4)\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
"Another useful Python package is\n",
"[pandas](https://pandas.pydata.org/), which is an open source library\n",
"providing high-performance, easy-to-use data structures and data\n",
@@ -541,7 +630,7 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 5,
"metadata": {
"collapsed": false
},
@@ -640,7 +729,7 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 6,
"metadata": {
"collapsed": false
},
@@ -897,7 +986,7 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": 7,
"metadata": {
"collapsed": false
},
@@ -971,7 +1060,7 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 8,
"metadata": {
"collapsed": false
},
@@ -1029,38 +1118,6 @@
" predict(linearMod,data.frame(Year=c(1910,1914,1920)),interval=\"confidence\")\n"
]
},
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Non-Linear Least squares in R"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- " set.seed(1485)\n",
- " len = 24\n",
- " x = runif(len)\n",
- " y = x^3+rnorm(len, 0,0.06)\n",
- " ds = data.frame(x = x, y = y)\n",
- " str(ds)\n",
- " plot( y ~ x, main =\"Known cubic with noise\")\n",
- " s = seq(0,1,length =100)\n",
- " lines(s, s^3, lty =2, col =\"green\")\n",
- " m = nls(y ~ I(x^power), data = ds, start = list(power=1), trace = T)\n",
- " class(m)\n",
- " summary(m)\n",
- " power = round(summary(m)$coefficients[1], 3)\n",
- " power.se = round(summary(m)$coefficients[2], 3)\n",
- " plot(y ~ x, main = \"Fitted power model\", sub = \"Blue: fit; green: known\")\n",
- " s = seq(0, 1, length = 100)\n",
- " lines(s, s^3, lty = 2, col = \"green\")\n",
- " lines(s, predict(m, list(x = s)), lty = 1, col = \"blue\")\n",
- " text(0, 0.5, paste(\"y =x^ (\", power, \" +/- \", power.se, \")\", sep = \"\"), pos = 4)\n"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
@@ -1104,7 +1161,7 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 9,
"metadata": {
"collapsed": false
},
@@ -1215,7 +1272,7 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 10,
"metadata": {
"collapsed": false
},
@@ -1407,7 +1464,7 @@
},
{
"cell_type": "code",
- "execution_count": 10,
+ "execution_count": 11,
"metadata": {
"collapsed": false
},
@@ -1606,7 +1663,7 @@
},
{
"cell_type": "code",
- "execution_count": 11,
+ "execution_count": 12,
"metadata": {
"collapsed": false
},
diff --git a/doc/pub/How2ReadData/ipynb/ipynb-How2ReadData-src.tar.gz b/doc/pub/How2ReadData/ipynb/ipynb-How2ReadData-src.tar.gz
index 950467d98..bcef88cb1 100644
Binary files a/doc/pub/How2ReadData/ipynb/ipynb-How2ReadData-src.tar.gz and b/doc/pub/How2ReadData/ipynb/ipynb-How2ReadData-src.tar.gz differ
diff --git a/doc/pub/How2ReadData/pdf/How2ReadData-beamer-handouts2x3.pdf b/doc/pub/How2ReadData/pdf/How2ReadData-beamer-handouts2x3.pdf
index 181b5b427..dc88380db 100644
Binary files a/doc/pub/How2ReadData/pdf/How2ReadData-beamer-handouts2x3.pdf and b/doc/pub/How2ReadData/pdf/How2ReadData-beamer-handouts2x3.pdf differ
diff --git a/doc/pub/How2ReadData/pdf/How2ReadData-beamer.pdf b/doc/pub/How2ReadData/pdf/How2ReadData-beamer.pdf
index 42e2f1dd3..9a90e8f4e 100644
Binary files a/doc/pub/How2ReadData/pdf/How2ReadData-beamer.pdf and b/doc/pub/How2ReadData/pdf/How2ReadData-beamer.pdf differ
diff --git a/doc/pub/How2ReadData/pdf/How2ReadData-minted.pdf b/doc/pub/How2ReadData/pdf/How2ReadData-minted.pdf
index e8e88a825..c1a2b2131 100644
Binary files a/doc/pub/How2ReadData/pdf/How2ReadData-minted.pdf and b/doc/pub/How2ReadData/pdf/How2ReadData-minted.pdf differ
diff --git a/doc/src/How2ReadData/How2ReadData.do.txt b/doc/src/How2ReadData/How2ReadData.do.txt
index 2840ecc6c..25e8f552c 100644
--- a/doc/src/How2ReadData/How2ReadData.do.txt
+++ b/doc/src/How2ReadData/How2ReadData.do.txt
@@ -6,8 +6,6 @@ DATE: today
!split
===== Introduction =====
-
-
Our emphasis throughout this series of lectures
is on understanding the mathematical aspects of
different algorithms used in the fields of data analysis and machine learning.
@@ -28,16 +26,20 @@ models. These are examples where we can easily set up the data and
then use machine learning algorithms included in for example
_scikit-learn_.
-These examples will serve us the purpose of getting started. Furthermore, they
-allow us to catch more than two birds with a stone. They will allow us
-to bring in some programming specific topics and tools as well as
-showing the power of various Python (and R) packages for machine
-learning and statistical data analysis. In the lectures on linear
-algebra we cover in more detail various programming features of languages like Python and C++ (and other), we will also look into more specific linear functions which
-are relevant for the various algorithms we will discuss. Here, we will
-mainly focus on two specific Python packages for Machine Learning,
-scikit-learn and tensorflow (see below for links etc).
-Moreover, the examples we introduce will serve as inputs to many of our discussions later, as well as allowing you to set up models and produce your own data and get started with programming.
+These examples will serve us the purpose of getting
+started. Furthermore, they allow us to catch more than two birds with
+a stone. They will allow us to bring in some programming specific
+topics and tools as well as showing the power of various Python (and
+R) packages for machine learning and statistical data analysis. In the
+lectures on linear algebra we cover in more detail various programming
+features of languages like Python and C++ (and other), we will also
+look into more specific linear functions which are relevant for the
+various algorithms we will discuss. Here, we will mainly focus on two
+specific Python packages for Machine Learning, scikit-learn and
+tensorflow (see below for links etc). Moreover, the examples we
+introduce will serve as inputs to many of our discussions later, as
+well as allowing you to set up models and produce your own data and
+get started with programming.
@@ -391,7 +393,78 @@ as population counts, average sales of a commodity over a span of
years etc.
We will discuss in more
-detail these and more function in the various lectures.
+detail these and other functions in the various lectures. We conclude this part with another example. Instead of
+a linear $x$-dependence we study now a cubic polynomial and use the polynomial regression analysis tools of scikit-learn.
+
+!bc pycod
+import numpy as np
+import matplotlib.pyplot as plt
+from sklearn.linear_model import Ridge
+from sklearn.preprocessing import PolynomialFeatures
+from sklearn.pipeline import make_pipeline
+
+def f(x):
+ """ function to approximate by polynomial interpolation"""
+ return x*x*x
+
+# generate points used to plot
+x_plot = np.linspace(0, 10, 100)
+
+# generate points and keep a subset of them
+x = np.linspace(0, 10, 100)
+rng = np.random.RandomState(0)
+rng.shuffle(x)
+x = np.sort(x[:20])
+y = f(x)
+# create matrix versions of these arrays
+X = x[:, np.newaxis]
+X_plot = x_plot[:, np.newaxis]
+
+colors = ['teal', 'yellowgreen', 'gold']
+lw = 2
+plt.plot(x_plot, f(x_plot), color='cornflowerblue', linewidth=lw,
+ label="ground truth")
+plt.scatter(x, y, color='navy', s=30, marker='o', label="training points")
+
+for count, degree in enumerate([3, 4, 5]):
+ model = make_pipeline(PolynomialFeatures(degree), Ridge())
+ model.fit(X, y)
+ y_plot = model.predict(X_plot)
+ plt.plot(x_plot, y_plot, color=colors[count], linewidth=lw,
+ label="degree %d" % degree)
+
+plt.legend(loc='lower left')
+
+plt.show()
+!ec
+
+!split
+===== Non-Linear Least squares in R =====
+!bblock
+!bc r
+set.seed(1485)
+len = 24
+x = runif(len)
+y = x^3+rnorm(len, 0,0.06)
+ds = data.frame(x = x, y = y)
+str(ds)
+plot( y ~ x, main ="Known cubic with noise")
+s = seq(0,1,length =100)
+lines(s, s^3, lty =2, col ="green")
+m = nls(y ~ I(x^power), data = ds, start = list(power=1), trace = T)
+class(m)
+summary(m)
+power = round(summary(m)$coefficients[1], 3)
+power.se = round(summary(m)$coefficients[2], 3)
+plot(y ~ x, main = "Fitted power model", sub = "Blue: fit; green: known")
+s = seq(0, 1, length = 100)
+lines(s, s^3, lty = 2, col = "green")
+lines(s, predict(m, list(x = s)), lty = 1, col = "blue")
+text(0, 0.5, paste("y =x^ (", power, " +/- ", power.se, ")", sep = ""), pos = 4)
+!ec
+!eblock
+
+
Another useful Python package is
"pandas":"https://pandas.pydata.org/", which is an open source library
@@ -709,31 +782,6 @@ predict(linearMod,data.frame(Year=c(1910,1914,1920)),interval="confidence")
!ec
!eblock
-!split
-===== Non-Linear Least squares in R =====
-!bblock
-!bc r
-set.seed(1485)
-len = 24
-x = runif(len)
-y = x^3+rnorm(len, 0,0.06)
-ds = data.frame(x = x, y = y)
-str(ds)
-plot( y ~ x, main ="Known cubic with noise")
-s = seq(0,1,length =100)
-lines(s, s^3, lty =2, col ="green")
-m = nls(y ~ I(x^power), data = ds, start = list(power=1), trace = T)
-class(m)
-summary(m)
-power = round(summary(m)$coefficients[1], 3)
-power.se = round(summary(m)$coefficients[2], 3)
-plot(y ~ x, main = "Fitted power model", sub = "Blue: fit; green: known")
-s = seq(0, 1, length = 100)
-lines(s, s^3, lty = 2, col = "green")
-lines(s, predict(m, list(x = s)), lty = 1, col = "blue")
-text(0, 0.5, paste("y =x^ (", power, " +/- ", power.se, ")", sep = ""), pos = 4)
-!ec
-!eblock
diff --git a/doc/web/course.do.txt b/doc/web/course.do.txt
index 0d66ded3f..c6a92cfa2 100644
--- a/doc/web/course.do.txt
+++ b/doc/web/course.do.txt
@@ -35,8 +35,6 @@ chapters = {
* LaTeX PDF:
* For printing:
* "Standard one-page format": "${pub_url}/${name}/pdf/${name}-minted.pdf"
- * For screen viewing:
- * "standard Beamer format": "${pub_url}/${name}/pdf/${name}-beamer.pdf"
* HTML:
* "Plain html": "${pub_url}/${name}/html/${name}.html"
* "reveal.js beige slide style": "${pub_url}/${name}/html/${name}-reveal.html"
diff --git a/doc/web/course.html b/doc/web/course.html
index de10c57d1..66a502125 100644
--- a/doc/web/course.html
+++ b/doc/web/course.html
@@ -183,12 +183,6 @@ formulas in HTML or ipython notebook files.