Files
FYS-STK4155/doc/Projects/2018/Project2/html/Project2.html
T

344 lines
17 KiB
HTML

<!--
Automatically generated HTML file from DocOnce source
(https://github.com/hplgit/doconce/)
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="DocOnce: https://github.com/hplgit/doconce/" />
<meta name="description" content="Project 2 on Machine Learning, deadline November 5">
<title>Project 2 on Machine Learning, deadline November 5</title>
<style type="text/css">
/* bloodish style */
body {
font-family: Helvetica, Verdana, Arial, Sans-serif;
color: #404040;
background: #ffffff;
}
h1 { font-size: 1.8em; color: #8A0808; }
h2 { font-size: 1.6em; color: #8A0808; }
h3 { font-size: 1.4em; color: #8A0808; }
h4 { color: #8A0808; }
a { color: #8A0808; text-decoration:none; }
tt { font-family: "Courier New", Courier; }
/* pre style removed because it will interfer with pygments */
p { text-indent: 0px; }
hr { border: 0; width: 80%; border-bottom: 1px solid #aaa}
p.caption { width: 80%; font-style: normal; text-align: left; }
hr.figure { border: 0; width: 80%; border-bottom: 1px solid #aaa}
div { text-align: justify; text-justify: inter-word; }
</style>
</head>
<!-- tocinfo
{'highest level': 2,
'sections': [('Classification and Regression, from linear and logistic '
'regression to neural networks',
2,
None,
'___sec0'),
('Part a): Producing the data', 3, None, '___sec1'),
('Part b): Estimating the coupling constant of the '
'one-dimensional Ising model',
3,
None,
'___sec2'),
('Part c): Determine the phase of the two-dimensional Ising '
'model',
3,
None,
'___sec3'),
('Part d): Classifying the Ising model phase using neural '
'networks',
3,
None,
'___sec4'),
('Background literature', 2, None, '___sec5'),
('Introduction to numerical projects', 2, None, '___sec6'),
('Format for electronic delivery of report and programs',
2,
None,
'___sec7'),
('Software and needed installations', 2, None, '___sec8')]}
end of tocinfo -->
<body>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: {
equationNumbers: { autoNumber: "AMS" },
extensions: ["AMSmath.js", "AMSsymbols.js", "autobold.js", "color.js"]
}
});
</script>
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<!-- ------------------- main content ---------------------- -->
<center><h1>Project 2 on Machine Learning, deadline November 5</h1></center> <!-- document title -->
<p>
<!-- author(s): <a href="http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html" target="_blank">Data Analysis and Machine Learning FYS-STK3155/FYS4155</a> -->
<center>
<b><a href="http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html" target="_blank">Data Analysis and Machine Learning FYS-STK3155/FYS4155</a></b>
</center>
<p>
<!-- institution -->
<center><b>Department of Physics, University of Oslo, Norway</b></center>
<br>
<p>
<center><h4>Oct 8, 2018</h4></center> <!-- date -->
<br>
<ol>
<li> add about ising model</li>
<li> link to where we have the data</li>
<li> explain how to fit the model</li>
<li> link to mehta's article</li>
</ol>
<h2 id="___sec0">Classification and Regression, from linear and logistic regression to neural networks </h2>
<p>
The main aim of this project is to study both classification and
regression problems, starting with the regression algortihms studied
in project 1. We will include logistic regresion for classification
problems and write our own multilayer perceptron code for studying
both regression and classification problems. The codes developed in
project 1, including bootstrap and/or cross-validation as well as the
computation of the mean-squared error and the R2 score function can
also be utilized (and included in logistic regression and the neural
network codes) in the present analysis.
<p>
We will use the Ising model to generate our training data and will
focus mainly on supervised training. We will follow closely the recent
article of <a href="https://arxiv.org/abs/1803.08823" target="_blank">Mehta et al, arXiv
1803.08823</a>. This article stands
out as an excellent review on machine learning (ML) algorithms applied
to typical physics problems. The added benefit is that each figure and
model presented in <a href="https://physics.bu.edu/~pankajm/MLnotebooks.html" target="_blank">this article is accompanied by its jupyter
notebook</a>. This
means that we can start using these and compare with our own
results. In case you wish to use their data for the Ising model, their
data can be downloaded from the same link which lists to the jupyter
notebooks. See also at the end of the project description for more
information on how to install various Python packages.
<p>
With the abovementioned configurations we will determine, using first
various regression methods, the value of the coupling constant for the
energy of the one-dimensional Ising model. Thereafter, we will use the
two-dimensional data, but now computed at different temperatures, in
order to classify the phase of the Ising model. Below the critical
temperature, the system will be in a so-called ferromagnetic
phase. Close to the critical temperature, the final magnetization
becomes smaller and smaller in absolute value while above the critical
temperature, the net magnetization is zero. This classification case,
that is the two-dimensional Ising model, will be studied using
logistic regression and deep neural networks. The aim is to develop
your own logistic regression code for the classification of the phases
(this is a binary model) and your multilayer perceptron code for the
classification and regression case.
<p>
Feel free to use the notebooks to benchmark your code. If you wish to
write your own C++ or Fortran program for say a simple neural network
model and a logistic regression model, please feel free to do so. You can then benchmark your results
against the above jupyter notebooks.
<h3 id="___sec1">Part a): Producing the data </h3>
<p>
You can use the Ising model data from the article of Mehta <em>et al.</em>,
or generate your own data. If you opt for using your own Ising model
code, you need to generate \( 10000 \) energy configurations with their
spin orientations after the system has reached its most likely
state. These energies and their corresponding spin orientations
represent then your data. We will use a fixed lattice of \( L\times L =
40 \times 40 \) spins in two dimensions and \( L=40 \) spins in one
dimension. Make sure the calculations have been equilibrated. For the
two-dimensional system, compute the configurations for three values of
the temperature, namely \( T=0.75 \) (ordered phase), \( T=2.3 \) (near the
critical point) and \( T=4.0 \) (disordered phase). For the
one-dimensional system it suffices to compute the various
configurations for one temperature only, say \( T=2.0 \). These are the
data you will use to study different ML algorithms. We generate our
data with \( J=1 \).
<h3 id="___sec2">Part b): Estimating the coupling constant of the one-dimensional Ising model </h3>
<p>
We start with the one-dimensional Ising model and use the data we have
generated with \( J=1 \). Use linear regression, Lasso and Ridge
regression as described section 6 and in Notebook 4 of <a href="https://physics.bu.edu/~pankajm/ML-Notebooks/HTML/NB_CVI-linreg_ising.html" target="_blank">Mehta *et
al.*</a>. Discuss
the methods and how they perform in computing the coupling constant
\( J \). Give a critical analysis and discuss how to evaluate the <em>cost
function</em>. You should feel free to write your own code, see also the
lecture notes of
<a href="https://compphysics.github.io/MachineLearning/doc/web/course.html" target="_blank">FYS-STK4155</a>,
in particular te material on least square methods. You can use
scikit-learn to perform these analyses. See below for instruction on
how to install scikit-learn.
<h3 id="___sec3">Part c): Determine the phase of the two-dimensional Ising model </h3>
<p>
We switch now to binary classification methods and use logistic
regression to define the phases of the Ising model. Use described
section 7 and in Notebook 6 of <a href="https://physics.bu.edu/~pankajm/ML-Notebooks/HTML/NB_CVII-logreg_ising.html" target="_blank">Mehta *et
al.*</a>. Discuss
the methods and how they perform. Give a critical analysis and discuss
how to evaluate the <em>cost function</em>. You should feel free to write
your own code.
<h3 id="___sec4">Part d): Classifying the Ising model phase using neural networks </h3>
<p>
We end the classification problem of the phases of the Ising model by
employing the algorithm for so-called feed-forward deep neural
networks (see section 9 of Mehta <em>et al.</em>). The method is described in
<a href="https://physics.bu.edu/~pankajm/ML-Notebooks/HTML/NB_CIX-DNN_ising_TFlow.html" target="_blank">notebook
12</a>.
<p>
You can use tensorflow to perform these analyses. See below for instruction on how to install tensorflow.
<h2 id="___sec5">Background literature </h2>
<ol>
<li> The textbook of <a href="https://www.springer.com/gp/book/9780387848570" target="_blank">Trevor Hastie, Robert Tibshirani, Jerome H. Friedman, The Elements of Statistical Learning, Springer</a>, chapters 3 and 7 are the most relevant ones for the analysis here.</li>
<li> <a href="https://arxiv.org/abs/1803.08823" target="_blank">Mehta et al, arXiv 1803.08823</a>, <em>A high-bias, low-variance introduction to Machine Learning for physicists</em>, ArXiv:1803.08823.</li>
</ol>
If you wish to read more about the Ising model and statistical physics here are three suggestions.
<ol>
<li> <a href="http://www.worldscientific.com/worldscibooks/10.1142/5660" target="_blank">M. Plischke and B. Bergersen</a>, <em>Equilibrium Statistical Physics</em>, World Scientific, see chapters 5 and 6.</li>
<li> <a href="http://www.cambridge.org/no/academic/subjects/physics/computational-science-and-modelling/guide-monte-carlo-simulations-statistical-physics-4th-edition?format=HB" target="_blank">D. P. Landau and K. Binder</a>, <em>A Guide to Monte Carlo Simulations in Statistical Physics</em>, Cambridge, see chapters 2,3 and 4.</li>
<li> <a href="https://global.oup.com/academic/product/monte-carlo-methods-in-statistical-physics-9780198517979?cc=no&lang=en&" target="_blank">M. E. J. Newman and T. Barkema</a>, <em>Monte Carlo Methods in Statistical Physics</em>, Oxford, see chapters 3 and 4.</li>
</ol>
<h2 id="___sec6">Introduction to numerical projects </h2>
<p>
Here follows a brief recipe and recommendation on how to write a report for each
project.
<ul>
<li> Give a short description of the nature of the problem and the eventual numerical methods you have used.</li>
<li> Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself.</li>
<li> Include the source code of your program. Comment your program properly.</li>
<li> If possible, try to find analytic solutions, or known limits in order to test your program when developing the code.</li>
<li> Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes.</li>
<li> Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc.</li>
<li> Try to give an interpretation of you results in your answers to the problems.</li>
<li> Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you've made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it.</li>
<li> Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don't properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning.</li>
</ul>
<h2 id="___sec7">Format for electronic delivery of report and programs </h2>
<p>
The preferred format for the report is a PDF file. You can also use DOC or postscript formats or as an ipython notebook file. As programming language we prefer that you choose between C/C++, Fortran2008 or Python. The following prescription should be followed when preparing the report:
<ul>
<li> Use Devilry to hand in your projects, log in at <a href="http://devilry.ifi.uio.no" target="_blank"><tt>http://devilry.ifi.uio.no</tt></a> with your normal UiO username and password and choose either 'fysstk3155' or 'fysstk4155'. There you can load up the files within the deadline.</li>
<li> Upload <b>only</b> the report file! For the source code file(s) you have developed please provide us with your link to your github domain. The report file should include all of your discussions and a list of the codes you have developed. Do not include library files which are available at the course homepage, unless you have made specific changes to them.</li>
<li> In your git repository, please include a folder which contains selected results. These can be in the form of output from your code for a selected set of runs and input parameters.</li>
<li> In this and all later projects, you should include tests (for example unit tests) of your code(s).</li>
<li> Comments from us on your projects, approval or not, corrections to be made etc can be found under your Devilry domain and are only visible to you and the teachers of the course.</li>
</ul>
Finally,
we encourage you to collaborate. Optimal working groups consist of
2-3 students. You can then hand in a common report.
<h2 id="___sec8">Software and needed installations </h2>
<p>
If you have Python installed (we recommend Python3) and you feel pretty familiar with installing different packages,
we recommend that you install the following Python packages via <b>pip</b> as
<ol>
<li> pip install numpy scipy matplotlib ipython scikit-learn tensorflow sympy pandas pillow</li>
</ol>
For Python3, replace <b>pip</b> with <b>pip3</b>.
<p>
See below for a discussion of <b>tensorflow</b> and <b>scikit-learn</b>.
<p>
For OSX users we recommend also, after having installed Xcode, to install <b>brew</b>. Brew allows
for a seamless installation of additional software via for example
<ol>
<li> brew install python3</li>
</ol>
For Linux users, with its variety of distributions like for example the widely popular Ubuntu distribution
you can use <b>pip</b> as well and simply install Python as
<ol>
<li> sudo apt-get install python3 (or python for python2.7)</li>
</ol>
etc etc.
<p>
If you don't want to install various Python packages with their dependencies separately, we recommend two widely used distrubutions which set up all relevant dependencies for Python, namely
<ol>
<li> <a href="https://docs.anaconda.com/" target="_blank">Anaconda</a> Anaconda is an open source distribution of the Python and R programming languages for large-scale data processing, predictive analytics, and scientific computing, that aims to simplify package management and deployment. Package versions are managed by the package management system <b>conda</b></li>
<li> <a href="https://www.enthought.com/product/canopy/" target="_blank">Enthought canopy</a> is a Python distribution for scientific and analytic computing distribution and analysis environment, available for free and under a commercial license.</li>
</ol>
Popular software packages written in Python for ML are
<ul>
<li> <a href="http://scikit-learn.org/stable/" target="_blank">Scikit-learn</a>,</li>
<li> <a href="https://www.tensorflow.org/" target="_blank">Tensorflow</a>,</li>
<li> <a href="http://pytorch.org/" target="_blank">PyTorch</a> and</li>
<li> <a href="https://keras.io/" target="_blank">Keras</a>.</li>
</ul>
These are all freely available at their respective GitHub sites. They
encompass communities of developers in the thousands or more. And the number
of code developers and contributors keeps increasing.
<p>
<!-- ------------------- end of main content --------------- -->
<center style="font-size:80%">
<!-- copyright --> &copy; 1999-2018, "Data Analysis and Machine Learning FYS-STK3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html". Released under CC Attribution-NonCommercial 4.0 license
</center>
</body>
</html>