Typos in hw corrected
This commit is contained in:
@@ -5,7 +5,7 @@ DATE:Today
|
||||
|
||||
===== Exercise 1 =====
|
||||
|
||||
The first exercise here is of a mere technical art. We want you have installed
|
||||
The first exercise here is of a mere technical art. We want you to have
|
||||
* git as a version control software and to establish a user account on a provider like GitHub. Other providers like GitLab etc are equally fine. You can also use the University of Oslo "GitHub facilities":"https://www.uio.no/tjenester/it/maskin/filer/versjonskontroll/github.html".
|
||||
* Install various Python packages
|
||||
|
||||
@@ -15,10 +15,7 @@ IPython/Jupyter notebooks invaluable in your work. You can run _R_
|
||||
codes in the Jupyter/IPython notebooks, with the immediate benefit of
|
||||
visualizing your data. You can also use compiled languages like C++,
|
||||
Rust, Fortran etc if you prefer. The focus in these lectures will be
|
||||
on Python, but we will provide many code examples for those of you who
|
||||
prefer R or compiled languages. You can integrate C++ codes and R in for example
|
||||
a Jupyter notebook.
|
||||
|
||||
on Python.
|
||||
|
||||
If you have Python installed (we recommend Python3) and you feel
|
||||
pretty familiar with installing different packages, we recommend that
|
||||
@@ -68,16 +65,16 @@ We recommend using _Anaconda_.
|
||||
|
||||
===== Exercise 2 =====
|
||||
|
||||
We will generate our own dataset for function $y(x)$ where $x \in [0,2]$ and defined by random numbers computed with the uniform distribution. The function $y$ is a quadratic polynomial in $x$ with added stochastic noise according to the normal distribution $\cal {N}(0,1)$.
|
||||
We will generate our own dataset for a function $y(x)$ where $x \in [0,1]$ and defined by random numbers computed with the uniform distribution. The function $y$ is a quadratic polynomial in $x$ with added stochastic noise according to the normal distribution $\cal {N}(0,1)$.
|
||||
The following simple Python instructions define our $x$ and $y$ values (with 100 data points).
|
||||
!bc pycod
|
||||
x = np.random.rand(100,1)
|
||||
y = 5*x*x+0.1*np.random.randn(100,1)
|
||||
!ec
|
||||
|
||||
o Write your own code (following the examples under the "regression slides":"https://compphysics.github.io/MachineLearning/doc/pub/Regression/html/Regression-bs.html" for computing the parametrization of the data set fitting a second-order polynomial.
|
||||
o Write your own code (following the examples under the "regression slides":"https://compphysics.github.io/MachineLearning/doc/pub/Regression/html/Regression-bs.html") for computing the parametrization of the data set fitting a second-order polynomial.
|
||||
o Use thereafter _scikit-learn_ (see again the examples in the regression slides) and compare with your own code.
|
||||
o Using scikit-learn, compute also the mean square error, a risk metric corresponding to the expected value of the squared (quadratic) error or loss defined as
|
||||
o Using scikit-learn, compute also the mean square error, a risk metric corresponding to the expected value of the squared (quadratic) error defined as
|
||||
!bt
|
||||
\[ MSE(\hat{y},\hat{\tilde{y}}) = \frac{1}{n}
|
||||
\sum_{i=0}^{n-1}(y_i-\tilde{y}_i)^2,
|
||||
@@ -96,7 +93,7 @@ where we have defined the mean value of $\hat{y}$ as
|
||||
\bar{y} = \frac{1}{n} \sum_{i=0}^{n - 1} y_i.
|
||||
\]
|
||||
!et
|
||||
|
||||
You can use the functionality included in scikit-learn. If you feel for it, you can use your own program and define functions which compute the above two functions.
|
||||
Discuss the meaning of these results. Try also to vary the coefficient in front of the added stochastic noise term and discuss the quality of the fits.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user