Update on project 1
This commit is contained in:
@@ -0,0 +1,364 @@
|
||||
<!--
|
||||
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 on Machine Learning">
|
||||
|
||||
<title>Project on Machine Learning</title>
|
||||
|
||||
<!-- Bootstrap style: bootstrap -->
|
||||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- not necessary
|
||||
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
-->
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Add scrollbar to dropdown menus in bootstrap navigation bar */
|
||||
.dropdown-menu {
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Adds an invisible element before each target to offset for the navigation
|
||||
bar */
|
||||
.anchor::before {
|
||||
content:"";
|
||||
display:block;
|
||||
height:50px; /* fixed header height for style bootstrap */
|
||||
margin:-50px 0 0; /* negative fixed header height */
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<!-- tocinfo
|
||||
{'highest level': 2,
|
||||
'sections': [('Machine learning (ML) approaches to data from Ising model '
|
||||
'calculations',
|
||||
2,
|
||||
None,
|
||||
'___sec0'),
|
||||
('Introduction', 3, None, '___sec1'),
|
||||
('Part a): Producing the data', 3, None, '___sec2'),
|
||||
('Part b): Estimating the coupling constant of the '
|
||||
'one-dimensional Ising model',
|
||||
3,
|
||||
None,
|
||||
'___sec3'),
|
||||
('Part c): Determine the phase of the two-dimensional Ising '
|
||||
'model',
|
||||
3,
|
||||
None,
|
||||
'___sec4'),
|
||||
('Part d): Classifying the Ising model phase using neural '
|
||||
'networks',
|
||||
3,
|
||||
None,
|
||||
'___sec5'),
|
||||
('Part e): Summary', 3, None, '___sec6'),
|
||||
('Background literature', 2, None, '___sec7'),
|
||||
('Introduction to numerical projects', 2, None, '___sec8'),
|
||||
('Software and needed installations', 2, None, '___sec9')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Config({
|
||||
TeX: {
|
||||
equationNumbers: { autoNumber: "none" },
|
||||
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>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap navigation bar -->
|
||||
<div class="navbar navbar-default navbar-fixed-top">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="Project-bs.html">Project on Machine Learning</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Contents <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<!-- navigation toc: --> <li><a href="#___sec0" style="font-size: 80%;"><b>Machine learning (ML) approaches to data from Ising model calculations</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec1" style="font-size: 80%;"> Introduction</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec2" style="font-size: 80%;"> Part a): Producing the data</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec3" style="font-size: 80%;"> Part b): Estimating the coupling constant of the one-dimensional Ising model</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec4" style="font-size: 80%;"> Part c): Determine the phase of the two-dimensional Ising model</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec5" style="font-size: 80%;"> Part d): Classifying the Ising model phase using neural networks</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec6" style="font-size: 80%;"> Part e): Summary</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec7" style="font-size: 80%;"><b>Background literature</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec8" style="font-size: 80%;"><b>Introduction to numerical projects</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec9" style="font-size: 80%;"><b>Software and needed installations</b></a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of navigation bar -->
|
||||
|
||||
<div class="container">
|
||||
|
||||
<p> </p><p> </p><p> </p> <!-- add vertical space -->
|
||||
|
||||
<a name="part0000"></a>
|
||||
<!-- ------------------- main content ---------------------- -->
|
||||
|
||||
|
||||
|
||||
<div class="jumbotron">
|
||||
<center><h1>Project on Machine Learning</h1></center> <!-- document title -->
|
||||
|
||||
<p>
|
||||
<!-- author(s): <a href="http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html" target="_self">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="_self">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>May 2018</h4></center> <!-- date -->
|
||||
<br>
|
||||
<p>
|
||||
</div> <!-- end jumbotron -->
|
||||
|
||||
<h2 id="___sec0" class="anchor">Machine learning (ML) approaches to data from Ising model calculations </h2>
|
||||
|
||||
<h3 id="___sec1" class="anchor">Introduction </h3>
|
||||
|
||||
<p>
|
||||
The aim of this project is to use an already developed Monte Carlo program for the one-dimensional and two-dimensional <a href="https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/IsingModel" target="_self">Ising model</a>, in order to produce the spin configurations for a series of energies \( E_i \) (10000 in total) for a system of \( L=40 \) spins in one dimension and \( L=40\times 40 \) in two dimensions at three different temperatures.
|
||||
In its simplest form
|
||||
the energy of the Ising model is expressed as, without an externally applied magnetic field,
|
||||
$$
|
||||
E=-J\sum_{< kl >}^{N}s_ks_l
|
||||
$$
|
||||
|
||||
with
|
||||
\( s_k=\pm 1 \). The quantity \( N \) represents the total number of spins and \( J \) is a coupling
|
||||
constant expressing the strength of the interaction between
|
||||
neighboring spins. The symbol \( < kl> \) indicates that we sum over
|
||||
nearest neighbors only. We will assume that we have a ferromagnetic
|
||||
ordering, viz \( J> 0 \). We will use periodic boundary conditions and
|
||||
the Metropolis algorithm only.
|
||||
|
||||
<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="_self">Mehta et al, arXiv 1803.08823</a>. This article stands out as an excellent review of 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="_self">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, thir 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 so-called ferromagnetic
|
||||
phase. Close to the critical temperature, the final magnetizations
|
||||
starts becoming close to zero while above the critical temperature,
|
||||
the net magnetization is zero. The latter case, that is the
|
||||
two-dimensional Ising model, will be studied using a <b>random forest</b>
|
||||
algorithm and deep neural networks.
|
||||
|
||||
<p>
|
||||
You should try to program at least one of these methods yourself (choose the one you prefer).
|
||||
Feel free to use the notebooks to benchmark your code. If you wish to write your C++ or Fortran program for say a simple neural network model, please feel free to do so.
|
||||
You can then benchmark your results against the above jupyter notebooks. More information can also be found at the link for the lecture notes of <a href="https://compphysics.github.io/MachineLearning/doc/web/course.html" target="_self">FYS-STK4155</a>.
|
||||
|
||||
<p>
|
||||
We recommend that you form groups of 2-3 students and try to
|
||||
collaborate on the notebooks, develop your own software and discuss
|
||||
the final presentations. You can collaborate on all these topics. The
|
||||
final presentation should include an overview of popular machine
|
||||
learning algorithms as introduction and motivation. Thereafter you
|
||||
discuss the explicit Ising model data and how you have implemented the
|
||||
ML algorithms discussed here, discuss their pros and cons and try to
|
||||
develop your own code for at least one of these algorithms. You are
|
||||
encouraged to use the abovementioned notebooks as starting point and
|
||||
guidance. The duration of your presentation should at most be 30
|
||||
mins. Allow for approximately 15 mins for discussions and questions.
|
||||
|
||||
<h3 id="___sec2" class="anchor">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="___sec3" class="anchor">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="_self">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="_self">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="___sec4" class="anchor">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="_self">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. Use thereafter the <em>random forests</em> algorithm to classify the same phases as done with logistic regression and discuss the pros and cons of these methods. For <em>random forests</em> you can use <a href="https://physics.bu.edu/~pankajm/ML-Notebooks/HTML/NB_CVIII-randomforests_ising.html" target="_self">notebook 9</a> of Mehta <em>et al.</em>
|
||||
|
||||
<p>
|
||||
You can use scikit-learn to perform these analyses. See below for instruction on how to install scikit-learn.
|
||||
|
||||
<h3 id="___sec5" class="anchor">Part d): Classifying the Ising model phase using neural networks </h3>
|
||||
|
||||
We end the classification problem of the phases of the Ising model by emplpying 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="_self">notebook 12</a>.
|
||||
|
||||
<p>
|
||||
You can use tensorflow to perform these analyses. See below for instruction on how to install tensorflow.
|
||||
|
||||
<h3 id="___sec6" class="anchor">Part e): Summary </h3>
|
||||
|
||||
<p>
|
||||
You should make a summary of the various methods and their pros and cons. For the final presentation, you should have at least coded one of these methods yourself and discussed the evaluation of the cost function.
|
||||
|
||||
<h2 id="___sec7" class="anchor">Background literature </h2>
|
||||
|
||||
<p>
|
||||
On Machine Learning we recommend strongly the article of Mehta <em>et al.</em>
|
||||
Textbooks on Machine Learning can be found at the <a href="https://github.com/CompPhysics/MachineLearning/tree/master/doc/Textbooks" target="_self">Github address of FYS-STK4155</a>, see in particular Marsland's text.
|
||||
|
||||
<ul>
|
||||
<li> <a href="https://arxiv.org/abs/1803.08823" target="_self">Mehta et al, arXiv 1803.08823</a>, <em>A high-bias, low-variance introduction to Machine Learning for physicists</em>, ArXiv:1803.08823.</li>
|
||||
</ul>
|
||||
|
||||
If you wish to read more about the Ising model and statistical physics here are three suggestions.
|
||||
|
||||
<ul>
|
||||
<li> <a href="http://www.worldscientific.com/worldscibooks/10.1142/5660" target="_self">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="_self">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="_self">M. E. J. Newman and T. Barkema</a>, <em>Monte Carlo Methods in Statistical Physics</em>, Oxford, see chapters 3 and 4.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="___sec8" class="anchor">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="___sec9" class="anchor">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="_self">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="_self">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="_self">Scikit-learn</a>,</li>
|
||||
<li> <a href="https://www.tensorflow.org/" target="_self">Tensorflow</a>,</li>
|
||||
<li> <a href="http://pytorch.org/" target="_self">PyTorch</a> and</li>
|
||||
<li> <a href="https://keras.io/" target="_self">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>
|
||||
<!-- navigation buttons at the bottom of the page -->
|
||||
<ul class="pagination">
|
||||
<li class="active"><a href="._Project-bs000.html">1</a></li>
|
||||
</ul>
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
</div> <!-- end container -->
|
||||
<!-- include javascript, jQuery *first* -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Bootstrap footer
|
||||
<footer>
|
||||
<a href="http://..."><img width="250" align=right src="http://..."></a>
|
||||
</footer>
|
||||
-->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright --> © 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>
|
||||
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
<!--
|
||||
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 on Machine Learning">
|
||||
|
||||
<title>Project on Machine Learning</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': [('Machine learning (ML) approaches to data from Ising model '
|
||||
'calculations',
|
||||
2,
|
||||
None,
|
||||
'___sec0'),
|
||||
('Introduction', 3, None, '___sec1'),
|
||||
('Part a): Producing the data', 3, None, '___sec2'),
|
||||
('Part b): Estimating the coupling constant of the '
|
||||
'one-dimensional Ising model',
|
||||
3,
|
||||
None,
|
||||
'___sec3'),
|
||||
('Part c): Determine the phase of the two-dimensional Ising '
|
||||
'model',
|
||||
3,
|
||||
None,
|
||||
'___sec4'),
|
||||
('Part d): Classifying the Ising model phase using neural '
|
||||
'networks',
|
||||
3,
|
||||
None,
|
||||
'___sec5'),
|
||||
('Part e): Summary', 3, None, '___sec6'),
|
||||
('Background literature', 2, None, '___sec7'),
|
||||
('Introduction to numerical projects', 2, None, '___sec8'),
|
||||
('Software and needed installations', 2, None, '___sec9')]}
|
||||
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 on Machine Learning</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>May 2018</h4></center> <!-- date -->
|
||||
<br>
|
||||
|
||||
<h2 id="___sec0">Machine learning (ML) approaches to data from Ising model calculations </h2>
|
||||
|
||||
<h3 id="___sec1">Introduction </h3>
|
||||
|
||||
<p>
|
||||
The aim of this project is to use an already developed Monte Carlo program for the one-dimensional and two-dimensional <a href="https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/IsingModel" target="_blank">Ising model</a>, in order to produce the spin configurations for a series of energies \( E_i \) (10000 in total) for a system of \( L=40 \) spins in one dimension and \( L=40\times 40 \) in two dimensions at three different temperatures.
|
||||
In its simplest form
|
||||
the energy of the Ising model is expressed as, without an externally applied magnetic field,
|
||||
$$
|
||||
E=-J\sum_{< kl >}^{N}s_ks_l
|
||||
$$
|
||||
|
||||
with
|
||||
\( s_k=\pm 1 \). The quantity \( N \) represents the total number of spins and \( J \) is a coupling
|
||||
constant expressing the strength of the interaction between
|
||||
neighboring spins. The symbol \( < kl> \) indicates that we sum over
|
||||
nearest neighbors only. We will assume that we have a ferromagnetic
|
||||
ordering, viz \( J> 0 \). We will use periodic boundary conditions and
|
||||
the Metropolis algorithm only.
|
||||
|
||||
<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 of 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, thir 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 so-called ferromagnetic
|
||||
phase. Close to the critical temperature, the final magnetizations
|
||||
starts becoming close to zero while above the critical temperature,
|
||||
the net magnetization is zero. The latter case, that is the
|
||||
two-dimensional Ising model, will be studied using a <b>random forest</b>
|
||||
algorithm and deep neural networks.
|
||||
|
||||
<p>
|
||||
You should try to program at least one of these methods yourself (choose the one you prefer).
|
||||
Feel free to use the notebooks to benchmark your code. If you wish to write your C++ or Fortran program for say a simple neural network model, please feel free to do so.
|
||||
You can then benchmark your results against the above jupyter notebooks. More information can also be found at the link for the lecture notes of <a href="https://compphysics.github.io/MachineLearning/doc/web/course.html" target="_blank">FYS-STK4155</a>.
|
||||
|
||||
<p>
|
||||
We recommend that you form groups of 2-3 students and try to
|
||||
collaborate on the notebooks, develop your own software and discuss
|
||||
the final presentations. You can collaborate on all these topics. The
|
||||
final presentation should include an overview of popular machine
|
||||
learning algorithms as introduction and motivation. Thereafter you
|
||||
discuss the explicit Ising model data and how you have implemented the
|
||||
ML algorithms discussed here, discuss their pros and cons and try to
|
||||
develop your own code for at least one of these algorithms. You are
|
||||
encouraged to use the abovementioned notebooks as starting point and
|
||||
guidance. The duration of your presentation should at most be 30
|
||||
mins. Allow for approximately 15 mins for discussions and questions.
|
||||
|
||||
<h3 id="___sec2">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="___sec3">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="___sec4">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. Use thereafter the <em>random forests</em> algorithm to classify the same phases as done with logistic regression and discuss the pros and cons of these methods. For <em>random forests</em> you can use <a href="https://physics.bu.edu/~pankajm/ML-Notebooks/HTML/NB_CVIII-randomforests_ising.html" target="_blank">notebook 9</a> of Mehta <em>et al.</em>
|
||||
|
||||
<p>
|
||||
You can use scikit-learn to perform these analyses. See below for instruction on how to install scikit-learn.
|
||||
|
||||
<h3 id="___sec5">Part d): Classifying the Ising model phase using neural networks </h3>
|
||||
|
||||
We end the classification problem of the phases of the Ising model by emplpying 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.
|
||||
|
||||
<h3 id="___sec6">Part e): Summary </h3>
|
||||
|
||||
<p>
|
||||
You should make a summary of the various methods and their pros and cons. For the final presentation, you should have at least coded one of these methods yourself and discussed the evaluation of the cost function.
|
||||
|
||||
<h2 id="___sec7">Background literature </h2>
|
||||
|
||||
<p>
|
||||
On Machine Learning we recommend strongly the article of Mehta <em>et al.</em>
|
||||
Textbooks on Machine Learning can be found at the <a href="https://github.com/CompPhysics/MachineLearning/tree/master/doc/Textbooks" target="_blank">Github address of FYS-STK4155</a>, see in particular Marsland's text.
|
||||
|
||||
<ul>
|
||||
<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>
|
||||
</ul>
|
||||
|
||||
If you wish to read more about the Ising model and statistical physics here are three suggestions.
|
||||
|
||||
<ul>
|
||||
<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>
|
||||
</ul>
|
||||
|
||||
<h2 id="___sec8">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="___sec9">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.
|
||||
|
||||
<!-- ------------------- end of main content --------------- -->
|
||||
|
||||
|
||||
<center style="font-size:80%">
|
||||
<!-- copyright --> © 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>
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,349 @@
|
||||
%%
|
||||
%% Automatically generated file from DocOnce source
|
||||
%% (https://github.com/hplgit/doconce/)
|
||||
%%
|
||||
%%
|
||||
% #ifdef PTEX2TEX_EXPLANATION
|
||||
%%
|
||||
%% The file follows the ptex2tex extended LaTeX format, see
|
||||
%% ptex2tex: http://code.google.com/p/ptex2tex/
|
||||
%%
|
||||
%% Run
|
||||
%% ptex2tex myfile
|
||||
%% or
|
||||
%% doconce ptex2tex myfile
|
||||
%%
|
||||
%% to turn myfile.p.tex into an ordinary LaTeX file myfile.tex.
|
||||
%% (The ptex2tex program: http://code.google.com/p/ptex2tex)
|
||||
%% Many preprocess options can be added to ptex2tex or doconce ptex2tex
|
||||
%%
|
||||
%% ptex2tex -DMINTED myfile
|
||||
%% doconce ptex2tex myfile envir=minted
|
||||
%%
|
||||
%% ptex2tex will typeset code environments according to a global or local
|
||||
%% .ptex2tex.cfg configure file. doconce ptex2tex will typeset code
|
||||
%% according to options on the command line (just type doconce ptex2tex to
|
||||
%% see examples). If doconce ptex2tex has envir=minted, it enables the
|
||||
%% minted style without needing -DMINTED.
|
||||
% #endif
|
||||
|
||||
% #define PREAMBLE
|
||||
|
||||
% #ifdef PREAMBLE
|
||||
%-------------------- begin preamble ----------------------
|
||||
|
||||
\documentclass[%
|
||||
oneside, % oneside: electronic viewing, twoside: printing
|
||||
final, % draft: marks overfull hboxes, figures with paths
|
||||
10pt]{article}
|
||||
|
||||
\listfiles % print all files needed to compile this document
|
||||
|
||||
\usepackage{relsize,makeidx,color,setspace,amsmath,amsfonts,amssymb}
|
||||
\usepackage[table]{xcolor}
|
||||
\usepackage{bm,ltablex,microtype}
|
||||
|
||||
\usepackage[pdftex]{graphicx}
|
||||
|
||||
\usepackage[T1]{fontenc}
|
||||
%\usepackage[latin1]{inputenc}
|
||||
\usepackage{ucs}
|
||||
\usepackage[utf8x]{inputenc}
|
||||
|
||||
\usepackage{lmodern} % Latin Modern fonts derived from Computer Modern
|
||||
|
||||
% Hyperlinks in PDF:
|
||||
\definecolor{linkcolor}{rgb}{0,0,0.4}
|
||||
\usepackage{hyperref}
|
||||
\hypersetup{
|
||||
breaklinks=true,
|
||||
colorlinks=true,
|
||||
linkcolor=linkcolor,
|
||||
urlcolor=linkcolor,
|
||||
citecolor=black,
|
||||
filecolor=black,
|
||||
%filecolor=blue,
|
||||
pdfmenubar=true,
|
||||
pdftoolbar=true,
|
||||
bookmarksdepth=3 % Uncomment (and tweak) for PDF bookmarks with more levels than the TOC
|
||||
}
|
||||
%\hyperbaseurl{} % hyperlinks are relative to this root
|
||||
|
||||
\setcounter{tocdepth}{2} % levels in table of contents
|
||||
|
||||
% --- fancyhdr package for fancy headers ---
|
||||
\usepackage{fancyhdr}
|
||||
\fancyhf{} % sets both header and footer to nothing
|
||||
\renewcommand{\headrulewidth}{0pt}
|
||||
\fancyfoot[LE,RO]{\thepage}
|
||||
% Ensure copyright on titlepage (article style) and chapter pages (book style)
|
||||
\fancypagestyle{plain}{
|
||||
\fancyhf{}
|
||||
\fancyfoot[C]{{\footnotesize \copyright\ 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}}
|
||||
% \renewcommand{\footrulewidth}{0mm}
|
||||
\renewcommand{\headrulewidth}{0mm}
|
||||
}
|
||||
% Ensure copyright on titlepages with \thispagestyle{empty}
|
||||
\fancypagestyle{empty}{
|
||||
\fancyhf{}
|
||||
\fancyfoot[C]{{\footnotesize \copyright\ 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}}
|
||||
\renewcommand{\footrulewidth}{0mm}
|
||||
\renewcommand{\headrulewidth}{0mm}
|
||||
}
|
||||
|
||||
\pagestyle{fancy}
|
||||
|
||||
|
||||
% prevent orhpans and widows
|
||||
\clubpenalty = 10000
|
||||
\widowpenalty = 10000
|
||||
|
||||
% --- end of standard preamble for documents ---
|
||||
|
||||
|
||||
% insert custom LaTeX commands...
|
||||
|
||||
\raggedbottom
|
||||
\makeindex
|
||||
\usepackage[totoc]{idxlayout} % for index in the toc
|
||||
\usepackage[nottoc]{tocbibind} % for references/bibliography in the toc
|
||||
|
||||
%-------------------- end preamble ----------------------
|
||||
|
||||
\begin{document}
|
||||
|
||||
% matching end for #ifdef PREAMBLE
|
||||
% #endif
|
||||
|
||||
\newcommand{\exercisesection}[1]{\subsection*{#1}}
|
||||
|
||||
|
||||
% ------------------- main content ----------------------
|
||||
|
||||
|
||||
|
||||
% ----------------- title -------------------------
|
||||
|
||||
\thispagestyle{empty}
|
||||
|
||||
\begin{center}
|
||||
{\LARGE\bf
|
||||
\begin{spacing}{1.25}
|
||||
Project on Machine Learning
|
||||
\end{spacing}
|
||||
}
|
||||
\end{center}
|
||||
|
||||
% ----------------- author(s) -------------------------
|
||||
|
||||
\begin{center}
|
||||
{\bf \href{{http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html}}{Data Analysis and Machine Learning FYS-STK3155/FYS4155}}
|
||||
\end{center}
|
||||
|
||||
\begin{center}
|
||||
% List of all institutions:
|
||||
\centerline{{\small Department of Physics, University of Oslo, Norway}}
|
||||
\end{center}
|
||||
|
||||
% ----------------- end author(s) -------------------------
|
||||
|
||||
% --- begin date ---
|
||||
\begin{center}
|
||||
May 2018
|
||||
\end{center}
|
||||
% --- end date ---
|
||||
|
||||
\vspace{1cm}
|
||||
|
||||
|
||||
\subsection{Machine learning (ML) approaches to data from Ising model calculations}
|
||||
|
||||
\paragraph{Introduction.}
|
||||
The aim of this project is to use an already developed Monte Carlo program for the one-dimensional and two-dimensional \href{{https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/IsingModel}}{Ising model}, in order to produce the spin configurations for a series of energies $E_i$ (10000 in total) for a system of $L=40$ spins in one dimension and $L=40\times 40$ in two dimensions at three different temperatures.
|
||||
In its simplest form
|
||||
the energy of the Ising model is expressed as, without an externally applied magnetic field,
|
||||
\[
|
||||
E=-J\sum_{< kl >}^{N}s_ks_l
|
||||
\]
|
||||
with
|
||||
$s_k=\pm 1$. The quantity $N$ represents the total number of spins and $J$ is a coupling
|
||||
constant expressing the strength of the interaction between
|
||||
neighboring spins. The symbol $<kl>$ indicates that we sum over
|
||||
nearest neighbors only. We will assume that we have a ferromagnetic
|
||||
ordering, viz $J> 0$. We will use periodic boundary conditions and
|
||||
the Metropolis algorithm only.
|
||||
|
||||
|
||||
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 \href{{https://arxiv.org/abs/1803.08823}}{Mehta et al, arXiv 1803.08823}. This article stands out as an excellent review of machine learning (ML) algorithms applied to typical physics problems. The added benefit is that each figure and model presented in \href{{https://physics.bu.edu/~pankajm/MLnotebooks.html}}{this article is accompanied by its jupyter notebook}. 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, thir 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.
|
||||
|
||||
|
||||
|
||||
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 so-called ferromagnetic
|
||||
phase. Close to the critical temperature, the final magnetizations
|
||||
starts becoming close to zero while above the critical temperature,
|
||||
the net magnetization is zero. The latter case, that is the
|
||||
two-dimensional Ising model, will be studied using a \textbf{random forest}
|
||||
algorithm and deep neural networks.
|
||||
|
||||
You should try to program at least one of these methods yourself (choose the one you prefer).
|
||||
Feel free to use the notebooks to benchmark your code. If you wish to write your C++ or Fortran program for say a simple neural network model, please feel free to do so.
|
||||
You can then benchmark your results against the above jupyter notebooks. More information can also be found at the link for the lecture notes of \href{{https://compphysics.github.io/MachineLearning/doc/web/course.html}}{FYS-STK4155}.
|
||||
|
||||
|
||||
We recommend that you form groups of 2-3 students and try to
|
||||
collaborate on the notebooks, develop your own software and discuss
|
||||
the final presentations. You can collaborate on all these topics. The
|
||||
final presentation should include an overview of popular machine
|
||||
learning algorithms as introduction and motivation. Thereafter you
|
||||
discuss the explicit Ising model data and how you have implemented the
|
||||
ML algorithms discussed here, discuss their pros and cons and try to
|
||||
develop your own code for at least one of these algorithms. You are
|
||||
encouraged to use the abovementioned notebooks as starting point and
|
||||
guidance. The duration of your presentation should at most be 30
|
||||
mins. Allow for approximately 15 mins for discussions and questions.
|
||||
|
||||
|
||||
|
||||
\paragraph{Part a): Producing the data.}
|
||||
You can use the Ising model data from the article of Mehta \emph{et al.}, 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$.
|
||||
|
||||
\paragraph{Part b): Estimating the coupling constant of the one-dimensional Ising model.}
|
||||
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 \href{{https://physics.bu.edu/~pankajm/ML-Notebooks/HTML/NB_CVI-linreg_ising.html}}{Mehta *et al.*}. Discuss the methods and how they perform in computing the coupling constant $J$. Give a critical analysis and discuss how to evaluate the \emph{cost function}. You should feel free to write your own code, see also
|
||||
the lecture notes of \href{{https://compphysics.github.io/MachineLearning/doc/web/course.html}}{FYS-STK4155}, 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.
|
||||
|
||||
\paragraph{Part c): Determine the phase of the two-dimensional Ising model.}
|
||||
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 \href{{https://physics.bu.edu/~pankajm/ML-Notebooks/HTML/NB_CVII-logreg_ising.html}}{Mehta *et al.*}. Discuss the methods and how they perform. Give a critical analysis and discuss how to evaluate the \emph{cost function}. You should feel free to write your own code. Use thereafter the \emph{random forests} algorithm to classify the same phases as done with logistic regression and discuss the pros and cons of these methods. For \emph{random forests} you can use \href{{https://physics.bu.edu/~pankajm/ML-Notebooks/HTML/NB_CVIII-randomforests_ising.html}}{notebook 9} of Mehta \emph{et al.}
|
||||
|
||||
You can use scikit-learn to perform these analyses. See below for instruction on how to install scikit-learn.
|
||||
|
||||
\paragraph{Part d): Classifying the Ising model phase using neural networks.}
|
||||
We end the classification problem of the phases of the Ising model by emplpying feed-forward deep neural networks (see section 9 of Mehta \emph{et al.}). The method is described in \href{{https://physics.bu.edu/~pankajm/ML-Notebooks/HTML/NB_CIX-DNN_ising_TFlow.html}}{notebook 12}.
|
||||
|
||||
You can use tensorflow to perform these analyses. See below for instruction on how to install tensorflow.
|
||||
|
||||
|
||||
\paragraph{Part e): Summary.}
|
||||
You should make a summary of the various methods and their pros and cons. For the final presentation, you should have at least coded one of these methods yourself and discussed the evaluation of the cost function.
|
||||
|
||||
\subsection{Background literature}
|
||||
|
||||
On Machine Learning we recommend strongly the article of Mehta \emph{et al.}
|
||||
Textbooks on Machine Learning can be found at the \href{{https://github.com/CompPhysics/MachineLearning/tree/master/doc/Textbooks}}{Github address of FYS-STK4155}, see in particular Marsland's text.
|
||||
|
||||
\begin{itemize}
|
||||
\item \href{{https://arxiv.org/abs/1803.08823}}{Mehta et al, arXiv 1803.08823}, \emph{A high-bias, low-variance introduction to Machine Learning for physicists}, ArXiv:1803.08823.
|
||||
\end{itemize}
|
||||
|
||||
\noindent
|
||||
If you wish to read more about the Ising model and statistical physics here are three suggestions.
|
||||
|
||||
\begin{itemize}
|
||||
\item \href{{http://www.worldscientific.com/worldscibooks/10.1142/5660}}{M. Plischke and B. Bergersen}, \emph{Equilibrium Statistical Physics}, World Scientific, see chapters 5 and 6.
|
||||
|
||||
\item \href{{http://www.cambridge.org/no/academic/subjects/physics/computational-science-and-modelling/guide-monte-carlo-simulations-statistical-physics-4th-edition?format=HB}}{D. P. Landau and K. Binder}, \emph{A Guide to Monte Carlo Simulations in Statistical Physics}, Cambridge, see chapters 2,3 and 4.
|
||||
|
||||
\item \href{{https://global.oup.com/academic/product/monte-carlo-methods-in-statistical-physics-9780198517979?cc=no&lang=en&}}{M. E. J. Newman and T. Barkema}, \emph{Monte Carlo Methods in Statistical Physics}, Oxford, see chapters 3 and 4.
|
||||
\end{itemize}
|
||||
|
||||
\noindent
|
||||
\subsection{Introduction to numerical projects}
|
||||
|
||||
Here follows a brief recipe and recommendation on how to write a report for each
|
||||
project.
|
||||
|
||||
\begin{itemize}
|
||||
\item Give a short description of the nature of the problem and the eventual numerical methods you have used.
|
||||
|
||||
\item 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.
|
||||
|
||||
\item Include the source code of your program. Comment your program properly.
|
||||
|
||||
\item If possible, try to find analytic solutions, or known limits in order to test your program when developing the code.
|
||||
|
||||
\item 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.
|
||||
|
||||
\item 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.
|
||||
|
||||
\item Try to give an interpretation of you results in your answers to the problems.
|
||||
|
||||
\item 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.
|
||||
|
||||
\item 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.
|
||||
\end{itemize}
|
||||
|
||||
\noindent
|
||||
\subsection{Software and needed installations}
|
||||
|
||||
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 \textbf{pip} as
|
||||
\begin{enumerate}
|
||||
\item pip install numpy scipy matplotlib ipython scikit-learn tensorflow sympy pandas pillow
|
||||
\end{enumerate}
|
||||
|
||||
\noindent
|
||||
For Python3, replace \textbf{pip} with \textbf{pip3}.
|
||||
|
||||
See below for a discussion of \textbf{tensorflow} and \textbf{scikit-learn}.
|
||||
|
||||
For OSX users we recommend also, after having installed Xcode, to install \textbf{brew}. Brew allows
|
||||
for a seamless installation of additional software via for example
|
||||
\begin{enumerate}
|
||||
\item brew install python3
|
||||
\end{enumerate}
|
||||
|
||||
\noindent
|
||||
For Linux users, with its variety of distributions like for example the widely popular Ubuntu distribution
|
||||
you can use \textbf{pip} as well and simply install Python as
|
||||
\begin{enumerate}
|
||||
\item sudo apt-get install python3 (or python for python2.7)
|
||||
\end{enumerate}
|
||||
|
||||
\noindent
|
||||
etc etc.
|
||||
|
||||
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
|
||||
\begin{enumerate}
|
||||
\item \href{{https://docs.anaconda.com/}}{Anaconda} 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 \textbf{conda}
|
||||
|
||||
\item \href{{https://www.enthought.com/product/canopy/}}{Enthought canopy} is a Python distribution for scientific and analytic computing distribution and analysis environment, available for free and under a commercial license.
|
||||
\end{enumerate}
|
||||
|
||||
\noindent
|
||||
Popular software packages written in Python for ML are
|
||||
|
||||
\begin{itemize}
|
||||
\item \href{{http://scikit-learn.org/stable/}}{Scikit-learn},
|
||||
|
||||
\item \href{{https://www.tensorflow.org/}}{Tensorflow},
|
||||
|
||||
\item \href{{http://pytorch.org/}}{PyTorch} and
|
||||
|
||||
\item \href{{https://keras.io/}}{Keras}.
|
||||
\end{itemize}
|
||||
|
||||
\noindent
|
||||
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.
|
||||
|
||||
|
||||
% ------------------- end of main content ---------------
|
||||
|
||||
% #ifdef PREAMBLE
|
||||
\end{document}
|
||||
% #endif
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,321 @@
|
||||
%%
|
||||
%% Automatically generated file from DocOnce source
|
||||
%% (https://github.com/hplgit/doconce/)
|
||||
%%
|
||||
%%
|
||||
|
||||
|
||||
%-------------------- begin preamble ----------------------
|
||||
|
||||
\documentclass[%
|
||||
oneside, % oneside: electronic viewing, twoside: printing
|
||||
final, % draft: marks overfull hboxes, figures with paths
|
||||
10pt]{article}
|
||||
|
||||
\listfiles % print all files needed to compile this document
|
||||
|
||||
\usepackage{relsize,makeidx,color,setspace,amsmath,amsfonts,amssymb}
|
||||
\usepackage[table]{xcolor}
|
||||
\usepackage{bm,ltablex,microtype}
|
||||
|
||||
\usepackage[pdftex]{graphicx}
|
||||
|
||||
\usepackage[T1]{fontenc}
|
||||
%\usepackage[latin1]{inputenc}
|
||||
\usepackage{ucs}
|
||||
\usepackage[utf8x]{inputenc}
|
||||
|
||||
\usepackage{lmodern} % Latin Modern fonts derived from Computer Modern
|
||||
|
||||
% Hyperlinks in PDF:
|
||||
\definecolor{linkcolor}{rgb}{0,0,0.4}
|
||||
\usepackage{hyperref}
|
||||
\hypersetup{
|
||||
breaklinks=true,
|
||||
colorlinks=true,
|
||||
linkcolor=linkcolor,
|
||||
urlcolor=linkcolor,
|
||||
citecolor=black,
|
||||
filecolor=black,
|
||||
%filecolor=blue,
|
||||
pdfmenubar=true,
|
||||
pdftoolbar=true,
|
||||
bookmarksdepth=3 % Uncomment (and tweak) for PDF bookmarks with more levels than the TOC
|
||||
}
|
||||
%\hyperbaseurl{} % hyperlinks are relative to this root
|
||||
|
||||
\setcounter{tocdepth}{2} % levels in table of contents
|
||||
|
||||
% --- fancyhdr package for fancy headers ---
|
||||
\usepackage{fancyhdr}
|
||||
\fancyhf{} % sets both header and footer to nothing
|
||||
\renewcommand{\headrulewidth}{0pt}
|
||||
\fancyfoot[LE,RO]{\thepage}
|
||||
% Ensure copyright on titlepage (article style) and chapter pages (book style)
|
||||
\fancypagestyle{plain}{
|
||||
\fancyhf{}
|
||||
\fancyfoot[C]{{\footnotesize \copyright\ 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}}
|
||||
% \renewcommand{\footrulewidth}{0mm}
|
||||
\renewcommand{\headrulewidth}{0mm}
|
||||
}
|
||||
% Ensure copyright on titlepages with \thispagestyle{empty}
|
||||
\fancypagestyle{empty}{
|
||||
\fancyhf{}
|
||||
\fancyfoot[C]{{\footnotesize \copyright\ 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}}
|
||||
\renewcommand{\footrulewidth}{0mm}
|
||||
\renewcommand{\headrulewidth}{0mm}
|
||||
}
|
||||
|
||||
\pagestyle{fancy}
|
||||
|
||||
|
||||
% prevent orhpans and widows
|
||||
\clubpenalty = 10000
|
||||
\widowpenalty = 10000
|
||||
|
||||
% --- end of standard preamble for documents ---
|
||||
|
||||
|
||||
% insert custom LaTeX commands...
|
||||
|
||||
\raggedbottom
|
||||
\makeindex
|
||||
\usepackage[totoc]{idxlayout} % for index in the toc
|
||||
\usepackage[nottoc]{tocbibind} % for references/bibliography in the toc
|
||||
|
||||
%-------------------- end preamble ----------------------
|
||||
|
||||
\begin{document}
|
||||
|
||||
% matching end for #ifdef PREAMBLE
|
||||
|
||||
\newcommand{\exercisesection}[1]{\subsection*{#1}}
|
||||
|
||||
|
||||
% ------------------- main content ----------------------
|
||||
|
||||
|
||||
|
||||
% ----------------- title -------------------------
|
||||
|
||||
\thispagestyle{empty}
|
||||
|
||||
\begin{center}
|
||||
{\LARGE\bf
|
||||
\begin{spacing}{1.25}
|
||||
Project on Machine Learning
|
||||
\end{spacing}
|
||||
}
|
||||
\end{center}
|
||||
|
||||
% ----------------- author(s) -------------------------
|
||||
|
||||
\begin{center}
|
||||
{\bf \href{{http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html}}{Data Analysis and Machine Learning FYS-STK3155/FYS4155}}
|
||||
\end{center}
|
||||
|
||||
\begin{center}
|
||||
% List of all institutions:
|
||||
\centerline{{\small Department of Physics, University of Oslo, Norway}}
|
||||
\end{center}
|
||||
|
||||
% ----------------- end author(s) -------------------------
|
||||
|
||||
% --- begin date ---
|
||||
\begin{center}
|
||||
May 2018
|
||||
\end{center}
|
||||
% --- end date ---
|
||||
|
||||
\vspace{1cm}
|
||||
|
||||
|
||||
\subsection*{Machine learning (ML) approaches to data from Ising model calculations}
|
||||
|
||||
\paragraph{Introduction.}
|
||||
The aim of this project is to use an already developed Monte Carlo program for the one-dimensional and two-dimensional \href{{https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/IsingModel}}{Ising model}, in order to produce the spin configurations for a series of energies $E_i$ (10000 in total) for a system of $L=40$ spins in one dimension and $L=40\times 40$ in two dimensions at three different temperatures.
|
||||
In its simplest form
|
||||
the energy of the Ising model is expressed as, without an externally applied magnetic field,
|
||||
\[
|
||||
E=-J\sum_{< kl >}^{N}s_ks_l
|
||||
\]
|
||||
with
|
||||
$s_k=\pm 1$. The quantity $N$ represents the total number of spins and $J$ is a coupling
|
||||
constant expressing the strength of the interaction between
|
||||
neighboring spins. The symbol $<kl>$ indicates that we sum over
|
||||
nearest neighbors only. We will assume that we have a ferromagnetic
|
||||
ordering, viz $J> 0$. We will use periodic boundary conditions and
|
||||
the Metropolis algorithm only.
|
||||
|
||||
|
||||
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 \href{{https://arxiv.org/abs/1803.08823}}{Mehta et al, arXiv 1803.08823}. This article stands out as an excellent review of machine learning (ML) algorithms applied to typical physics problems. The added benefit is that each figure and model presented in \href{{https://physics.bu.edu/~pankajm/MLnotebooks.html}}{this article is accompanied by its jupyter notebook}. 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, thir 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.
|
||||
|
||||
|
||||
|
||||
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 so-called ferromagnetic
|
||||
phase. Close to the critical temperature, the final magnetizations
|
||||
starts becoming close to zero while above the critical temperature,
|
||||
the net magnetization is zero. The latter case, that is the
|
||||
two-dimensional Ising model, will be studied using a \textbf{random forest}
|
||||
algorithm and deep neural networks.
|
||||
|
||||
You should try to program at least one of these methods yourself (choose the one you prefer).
|
||||
Feel free to use the notebooks to benchmark your code. If you wish to write your C++ or Fortran program for say a simple neural network model, please feel free to do so.
|
||||
You can then benchmark your results against the above jupyter notebooks. More information can also be found at the link for the lecture notes of \href{{https://compphysics.github.io/MachineLearning/doc/web/course.html}}{FYS-STK4155}.
|
||||
|
||||
|
||||
We recommend that you form groups of 2-3 students and try to
|
||||
collaborate on the notebooks, develop your own software and discuss
|
||||
the final presentations. You can collaborate on all these topics. The
|
||||
final presentation should include an overview of popular machine
|
||||
learning algorithms as introduction and motivation. Thereafter you
|
||||
discuss the explicit Ising model data and how you have implemented the
|
||||
ML algorithms discussed here, discuss their pros and cons and try to
|
||||
develop your own code for at least one of these algorithms. You are
|
||||
encouraged to use the abovementioned notebooks as starting point and
|
||||
guidance. The duration of your presentation should at most be 30
|
||||
mins. Allow for approximately 15 mins for discussions and questions.
|
||||
|
||||
|
||||
|
||||
\paragraph{Part a): Producing the data.}
|
||||
You can use the Ising model data from the article of Mehta \emph{et al.}, 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$.
|
||||
|
||||
\paragraph{Part b): Estimating the coupling constant of the one-dimensional Ising model.}
|
||||
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 \href{{https://physics.bu.edu/~pankajm/ML-Notebooks/HTML/NB_CVI-linreg_ising.html}}{Mehta *et al.*}. Discuss the methods and how they perform in computing the coupling constant $J$. Give a critical analysis and discuss how to evaluate the \emph{cost function}. You should feel free to write your own code, see also
|
||||
the lecture notes of \href{{https://compphysics.github.io/MachineLearning/doc/web/course.html}}{FYS-STK4155}, 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.
|
||||
|
||||
\paragraph{Part c): Determine the phase of the two-dimensional Ising model.}
|
||||
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 \href{{https://physics.bu.edu/~pankajm/ML-Notebooks/HTML/NB_CVII-logreg_ising.html}}{Mehta *et al.*}. Discuss the methods and how they perform. Give a critical analysis and discuss how to evaluate the \emph{cost function}. You should feel free to write your own code. Use thereafter the \emph{random forests} algorithm to classify the same phases as done with logistic regression and discuss the pros and cons of these methods. For \emph{random forests} you can use \href{{https://physics.bu.edu/~pankajm/ML-Notebooks/HTML/NB_CVIII-randomforests_ising.html}}{notebook 9} of Mehta \emph{et al.}
|
||||
|
||||
You can use scikit-learn to perform these analyses. See below for instruction on how to install scikit-learn.
|
||||
|
||||
\paragraph{Part d): Classifying the Ising model phase using neural networks.}
|
||||
We end the classification problem of the phases of the Ising model by emplpying feed-forward deep neural networks (see section 9 of Mehta \emph{et al.}). The method is described in \href{{https://physics.bu.edu/~pankajm/ML-Notebooks/HTML/NB_CIX-DNN_ising_TFlow.html}}{notebook 12}.
|
||||
|
||||
You can use tensorflow to perform these analyses. See below for instruction on how to install tensorflow.
|
||||
|
||||
|
||||
\paragraph{Part e): Summary.}
|
||||
You should make a summary of the various methods and their pros and cons. For the final presentation, you should have at least coded one of these methods yourself and discussed the evaluation of the cost function.
|
||||
|
||||
\subsection*{Background literature}
|
||||
|
||||
On Machine Learning we recommend strongly the article of Mehta \emph{et al.}
|
||||
Textbooks on Machine Learning can be found at the \href{{https://github.com/CompPhysics/MachineLearning/tree/master/doc/Textbooks}}{Github address of FYS-STK4155}, see in particular Marsland's text.
|
||||
|
||||
\begin{itemize}
|
||||
\item \href{{https://arxiv.org/abs/1803.08823}}{Mehta et al, arXiv 1803.08823}, \emph{A high-bias, low-variance introduction to Machine Learning for physicists}, ArXiv:1803.08823.
|
||||
\end{itemize}
|
||||
|
||||
\noindent
|
||||
If you wish to read more about the Ising model and statistical physics here are three suggestions.
|
||||
|
||||
\begin{itemize}
|
||||
\item \href{{http://www.worldscientific.com/worldscibooks/10.1142/5660}}{M. Plischke and B. Bergersen}, \emph{Equilibrium Statistical Physics}, World Scientific, see chapters 5 and 6.
|
||||
|
||||
\item \href{{http://www.cambridge.org/no/academic/subjects/physics/computational-science-and-modelling/guide-monte-carlo-simulations-statistical-physics-4th-edition?format=HB}}{D. P. Landau and K. Binder}, \emph{A Guide to Monte Carlo Simulations in Statistical Physics}, Cambridge, see chapters 2,3 and 4.
|
||||
|
||||
\item \href{{https://global.oup.com/academic/product/monte-carlo-methods-in-statistical-physics-9780198517979?cc=no&lang=en&}}{M. E. J. Newman and T. Barkema}, \emph{Monte Carlo Methods in Statistical Physics}, Oxford, see chapters 3 and 4.
|
||||
\end{itemize}
|
||||
|
||||
\noindent
|
||||
\subsection*{Introduction to numerical projects}
|
||||
|
||||
Here follows a brief recipe and recommendation on how to write a report for each
|
||||
project.
|
||||
|
||||
\begin{itemize}
|
||||
\item Give a short description of the nature of the problem and the eventual numerical methods you have used.
|
||||
|
||||
\item 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.
|
||||
|
||||
\item Include the source code of your program. Comment your program properly.
|
||||
|
||||
\item If possible, try to find analytic solutions, or known limits in order to test your program when developing the code.
|
||||
|
||||
\item 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.
|
||||
|
||||
\item 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.
|
||||
|
||||
\item Try to give an interpretation of you results in your answers to the problems.
|
||||
|
||||
\item 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.
|
||||
|
||||
\item 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.
|
||||
\end{itemize}
|
||||
|
||||
\noindent
|
||||
\subsection*{Software and needed installations}
|
||||
|
||||
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 \textbf{pip} as
|
||||
\begin{enumerate}
|
||||
\item pip install numpy scipy matplotlib ipython scikit-learn tensorflow sympy pandas pillow
|
||||
\end{enumerate}
|
||||
|
||||
\noindent
|
||||
For Python3, replace \textbf{pip} with \textbf{pip3}.
|
||||
|
||||
See below for a discussion of \textbf{tensorflow} and \textbf{scikit-learn}.
|
||||
|
||||
For OSX users we recommend also, after having installed Xcode, to install \textbf{brew}. Brew allows
|
||||
for a seamless installation of additional software via for example
|
||||
\begin{enumerate}
|
||||
\item brew install python3
|
||||
\end{enumerate}
|
||||
|
||||
\noindent
|
||||
For Linux users, with its variety of distributions like for example the widely popular Ubuntu distribution
|
||||
you can use \textbf{pip} as well and simply install Python as
|
||||
\begin{enumerate}
|
||||
\item sudo apt-get install python3 (or python for python2.7)
|
||||
\end{enumerate}
|
||||
|
||||
\noindent
|
||||
etc etc.
|
||||
|
||||
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
|
||||
\begin{enumerate}
|
||||
\item \href{{https://docs.anaconda.com/}}{Anaconda} 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 \textbf{conda}
|
||||
|
||||
\item \href{{https://www.enthought.com/product/canopy/}}{Enthought canopy} is a Python distribution for scientific and analytic computing distribution and analysis environment, available for free and under a commercial license.
|
||||
\end{enumerate}
|
||||
|
||||
\noindent
|
||||
Popular software packages written in Python for ML are
|
||||
|
||||
\begin{itemize}
|
||||
\item \href{{http://scikit-learn.org/stable/}}{Scikit-learn},
|
||||
|
||||
\item \href{{https://www.tensorflow.org/}}{Tensorflow},
|
||||
|
||||
\item \href{{http://pytorch.org/}}{PyTorch} and
|
||||
|
||||
\item \href{{https://keras.io/}}{Keras}.
|
||||
\end{itemize}
|
||||
|
||||
\noindent
|
||||
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.
|
||||
|
||||
|
||||
% ------------------- end of main content ---------------
|
||||
|
||||
\end{document}
|
||||
|
||||
@@ -3,11 +3,11 @@ AUTHOR: "Data Analysis and Machine Learning FYS-STK3155/FYS4155":"http://www.uio
|
||||
DATE: May 2018
|
||||
|
||||
|
||||
===== Machine learning approaches to data from Ising model calculations =====
|
||||
===== Machine learning (ML) approaches to data from Ising model calculations =====
|
||||
|
||||
=== Introduction ===
|
||||
|
||||
The aim of this project is to use an already developed Monte Carlo program for the one-dimensional and two-dimensional "Ising model":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/IsingModel", in order to produce the spin configurations for a series of energies $E_i$ (10000 in total) for a system of $20$ spins in one dimension and $20\times 20$ in two dimensions at three different temperatures.
|
||||
The aim of this project is to use an already developed Monte Carlo program for the one-dimensional and two-dimensional "Ising model":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/IsingModel", in order to produce the spin configurations for a series of energies $E_i$ (10000 in total) for a system of $L=40$ spins in one dimension and $L=40\times 40$ in two dimensions at three different temperatures.
|
||||
In its simplest form
|
||||
the energy of the Ising model is expressed as, without an externally applied magnetic field,
|
||||
!bt
|
||||
@@ -23,210 +23,83 @@ nearest neighbors only. We will assume that we have a ferromagnetic
|
||||
ordering, viz $J> 0$. We will use periodic boundary conditions and
|
||||
the Metropolis algorithm only.
|
||||
|
||||
With these configurations we will determine, using first various
|
||||
|
||||
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 "Mehta et al, arXiv 1803.08823":"https://arxiv.org/abs/1803.08823". This article stands out as an excellent review of machine learning (ML) algorithms applied to typical physics problems. The added benefit is that each figure and model presented in "this article is accompanied by its jupyter notebook":"https://physics.bu.edu/~pankajm/MLnotebooks.html". 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, thir 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.
|
||||
|
||||
|
||||
|
||||
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
|
||||
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 so-called ferromagnetic
|
||||
phase. Close to the critical temperature, the final magnetizations
|
||||
starts becoming close to zero while above the critical temperature,
|
||||
the net magnetization is zero. The latter case, that is the
|
||||
two-dimensional Ising model, will be studied using a _random forest_
|
||||
algorithm and deep neural networks.
|
||||
|
||||
You should try to program at least one of these methods yourself (choose the one you prefer).
|
||||
Feel free to use the notebooks to benchmark your code. If you wish to write your C++ or Fortran program for say a simple neural network model, please feel free to do so.
|
||||
You can then benchmark your results against the above jupyter notebooks. More information can also be found at the link for the lecture notes of "FYS-STK4155":"https://compphysics.github.io/MachineLearning/doc/web/course.html".
|
||||
|
||||
|
||||
We recommend that you form groups of 2-3 students and try to
|
||||
collaborate on the notebooks, develop your own software and discuss
|
||||
the final presentations. You can collaborate on all these topics. The
|
||||
final presentation should include an overview of popular machine
|
||||
learning algorithms as introduction and motivation. Thereafter you
|
||||
discuss the explicit Ising model data and how you have implemented the
|
||||
ML algorithms discussed here, discuss their pros and cons and try to
|
||||
develop your own code for at least one of these algorithms. You are
|
||||
encouraged to use the abovementioned notebooks as starting point and
|
||||
guidance. The duration of your presentation should at most be 30
|
||||
mins. Allow for approximately 15 mins for discussions and questions.
|
||||
|
||||
|
||||
Alternatively we can use the supplied variational Monte Carlo program which solves Schroedinger's equation for two interacting electrons in a harmonic oscillator trap. Both codes can be found at the webpage of the "course under programs":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/".
|
||||
|
||||
=== Part a): Producing the data ===
|
||||
|
||||
If we opt for the Ising model code, we need to generate for every span over the lattice and output of the total energy and the magnetic moment (if we wish to study this quantity as well), that is compute and write to file as function of temperature
|
||||
$\langle E\rangle$ and $\langle \vert M\vert \rangle$.
|
||||
We will use a fixed lattice siste of $L\times L = 40 \times 40$. Make sure the calculations have been equilibrated and compute these expectation values for
|
||||
for $T\in [1.0,3.0]$ with a step in
|
||||
temperature $\Delta T=0.1$ or smaller. This are the data you will use to estimate the standard deviation in the next part of the project.
|
||||
You should keep a file for the different temperatures as you will need to compute the standard deviation for each temperature.
|
||||
You can use the Ising model data from the article of Mehta *et al.*, 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$.
|
||||
|
||||
=== Part b): Estimating the coupling constant of the one-dimensional Ising model ===
|
||||
|
||||
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 "Mehta *et al.*":"https://physics.bu.edu/~pankajm/ML-Notebooks/HTML/NB_CVI-linreg_ising.html". Discuss the methods and how they perform in computing the coupling constant $J$. Give a critical analysis and discuss how to evaluate the *cost function*. You should feel free to write your own code, see also
|
||||
the lecture notes of "FYS-STK4155":"https://compphysics.github.io/MachineLearning/doc/web/course.html", 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.
|
||||
|
||||
=== Part c): Determine the phase of the two-dimensional Ising model ===
|
||||
|
||||
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 "Mehta *et al.*":"https://physics.bu.edu/~pankajm/ML-Notebooks/HTML/NB_CVII-logreg_ising.html". Discuss the methods and how they perform. Give a critical analysis and discuss how to evaluate the *cost function*. You should feel free to write your own code. Use thereafter the *random forests* algorithm to classify the same phases as done with logistic regression and discuss the pros and cons of these methods. For *random forests* you can use "notebook 9":"https://physics.bu.edu/~pankajm/ML-Notebooks/HTML/NB_CVIII-randomforests_ising.html" of Mehta *et al.*
|
||||
|
||||
You can use scikit-learn to perform these analyses. See below for instruction on how to install scikit-learn.
|
||||
|
||||
=== Part d): Classifying the Ising model phase using neural networks ===
|
||||
We end the classification problem of the phases of the Ising model by emplpying feed-forward deep neural networks (see section 9 of Mehta *et al.*). The method is described in "notebook 12":"https://physics.bu.edu/~pankajm/ML-Notebooks/HTML/NB_CIX-DNN_ising_TFlow.html".
|
||||
|
||||
You can use tensorflow to perform these analyses. See below for instruction on how to install tensorflow.
|
||||
|
||||
|
||||
=== Part b): Estimating the standard deviation ===
|
||||
|
||||
|
||||
=== Part c): Fitting the data using regression analysis and other methods ===
|
||||
|
||||
With the data from part b), with a proper determination of the standard deviation, the task here is to find a fit to the data using regression methods. Here we will focus on the least square method with a straight line fit first and thereafter using singular value decomposition to fit a function that reproduces the data.
|
||||
|
||||
Since obtaining these data points may not be trivial, we want to use these data to fit a function which can allow us to make predictions for values of $y$ which are not in the present set. The perhaps simplest approach is to assume we can parametrize our function in terms of a polynomial of degree $n-1$ with $n$ points, that is
|
||||
!bt
|
||||
\[
|
||||
y=y(x) \rightarrow y(x_i)=\tilde{y}_i+\epsilon_i=\sum_{j=0}^{n-1} \beta_i x_i^j+\epsilon_i,
|
||||
\]
|
||||
!et
|
||||
where $\epsilon_i$ is the error in our approximation.
|
||||
|
||||
In order to find the optimal parameters $\beta_i$ instead of solving the above linear algebra problem, we define a function which gives a measure of the spread between the values $y_i$ (which represent hopefully the exact values) and the parametrized values $\tilde{y}_i$, namely
|
||||
!bt
|
||||
\[
|
||||
Q(\hat{\beta})=\sum_{i=0}^{n-1}\left(y_i-\tilde{y}_i\right)^2=\left(\hat{y}-\hat{\tilde{y}}\right)^T\left(\hat{y}-\hat{\tilde{y}}\right),
|
||||
\]
|
||||
!et
|
||||
or using the matrix $\hat{X}$ as
|
||||
!bt
|
||||
\[
|
||||
Q(\hat{\beta})=\left(\hat{y}-\hat{X}\hat{\beta}\right)^T\left(\hat{y}-\hat{X}\hat{\beta}\right).
|
||||
\]
|
||||
!et
|
||||
|
||||
The function
|
||||
!bt
|
||||
\[
|
||||
Q(\hat{\beta})=\left(\hat{y}-\hat{X}\hat{\beta}\right)^T\left(\hat{y}-\hat{X}\hat{\beta}\right),
|
||||
\]
|
||||
!et
|
||||
can be linked to the variance of the quantity $y_i$ if we interpret the latter as the mean value of for example a numerical experiment. When linking below with the maximum likelihood approach below, we will indeed interpret $y_i$ as a mean value
|
||||
!bt
|
||||
\[
|
||||
y_{i}=\langle y_i \rangle = \beta_0x_{i,0}+\beta_1x_{i,1}+\beta_2x_{i,2}+\dots+\beta_{n-1}x_{i,n-1}+\epsilon_i,
|
||||
\]
|
||||
!et
|
||||
where $\langle y_i \rangle$ is the mean value. Keep in mind also that till now we have treated $y_i$ as the exact value. Normally, the response (dependent or outcome) variable $y_i$ the outcome of a numerical experiment or another type of experiment and is thus only an approximation to the true value. It is then always accompanied by an error estimate, often limited to a statistical error estimate given by the standard deviation discussed earlier. In the discussion here we will treat $y_i$ as our exact value for the response variable.
|
||||
|
||||
Introducing the standard deviation $\sigma_i$ for each measurement $y_i$, we define now the $\chi^2$ function as
|
||||
!bt
|
||||
\[
|
||||
\chi^2(\hat{\beta})=\sum_{i=0}^{n-1}\frac{\left(y_i-\tilde{y}_i\right)^2}{\sigma_i^2}=\left(\hat{y}-\hat{\tilde{y}}\right)^T\frac{1}{\hat{\Sigma^2}}\left(\hat{y}-\hat{\tilde{y}}\right),
|
||||
\]
|
||||
!et
|
||||
where the matrix $\hat{\Sigma}$ is a diagonal matrix with $\sigma_i$ as matrix elements.
|
||||
|
||||
|
||||
|
||||
|
||||
In order to find the parameters $\beta_i$ we will then minimize the spread of $\chi^2(\hat{\beta})$ by requiring
|
||||
!bt
|
||||
\[
|
||||
\frac{\partial \chi^2(\hat{\beta})}{\partial \beta_j} = \frac{\partial }{\partial \beta_j}\left[ \sum_{i=0}^{n-1}\left(\frac{y_i-\beta_0x_{i,0}-\beta_1x_{i,1}-\beta_2x_{i,2}-\dots-\beta_{n-1}x_{i,n-1}}{\sigma_i}\right)^2\right]=0,
|
||||
\]
|
||||
!et
|
||||
which results in
|
||||
!bt
|
||||
\[
|
||||
\frac{\partial \chi^2(\hat{\beta})}{\partial \beta_j} = -2\left[ \sum_{i=0}^{n-1}\frac{x_{ij}}{\sigma_i}\left(\frac{y_i-\beta_0x_{i,0}-\beta_1x_{i,1}-\beta_2x_{i,2}-\dots-\beta_{n-1}x_{i,n-1}}{\sigma_i}\right)\right]=0,
|
||||
\]
|
||||
!et
|
||||
or in a matrix-vector form as
|
||||
!bt
|
||||
\[
|
||||
\frac{\partial \chi^2(\hat{\beta})}{\partial \hat{\beta}} = 0 = \hat{A}^T\left( \hat{b}-\hat{A}\hat{\beta}\right).
|
||||
\]
|
||||
!et
|
||||
where we have defined the matrix $\hat{A} =\hat{X}/\hat{\Sigma}$ with matrix elements $a_{ij} = x_{ij}/\sigma_i$ and the vector $\hat{b}$ with elements $b_i = y_i/\sigma_i$.
|
||||
|
||||
|
||||
We can rewrite
|
||||
!bt
|
||||
\[
|
||||
\frac{\partial \chi^2(\hat{\beta})}{\partial \hat{\beta}} = 0 = \hat{A}^T\left( \hat{b}-\hat{A}\hat{\beta}\right),
|
||||
\]
|
||||
!et
|
||||
as
|
||||
!bt
|
||||
\[
|
||||
\hat{A}^T\hat{b} = \hat{A}^T\hat{A}\hat{\beta},
|
||||
\]
|
||||
!et
|
||||
and if the matrix $\hat{A}^T\hat{A}$ is invertible we have the solution
|
||||
!bt
|
||||
\[
|
||||
\hat{\beta} =\left(\hat{A}^T\hat{A}\right)^{-1}\hat{A}^T\hat{b}.
|
||||
\]
|
||||
!et
|
||||
If we then introduce the matrix
|
||||
!bt
|
||||
\[
|
||||
\hat{H} = \hat{A}^T\hat{A},
|
||||
\]
|
||||
!et
|
||||
we have then the following expression for the parameters $\beta_j$ (the matrix elements of $\hat{H}$ are $h_{ij}$)
|
||||
!bt
|
||||
\[
|
||||
\beta_j = \sum_{k=0}^{p-1}h_{jk}\sum_{i=0}^{n-1}\frac{y_i}{\sigma_i}\frac{x_{ik}}{\sigma_i} = \sum_{k=0}^{p-1}h_{jk}\sum_{i=0}^{n-1}b_ia_{ik}
|
||||
\]
|
||||
!et
|
||||
We state without proof the expression for the uncertainty in the parameters $\beta_j$ as
|
||||
!bt
|
||||
\[
|
||||
\sigma^2(\beta_j) = \sum_{i=0}^{n-1}\sigma_i^2\left( \frac{\partial \beta_j}{\partial y_i}\right)^2,
|
||||
\]
|
||||
!et
|
||||
resulting in
|
||||
!bt
|
||||
\[
|
||||
\sigma^2(\beta_j) = \left(\sum_{k=0}^{p-1}h_{jk}\sum_{i=0}^{n-1}a_{ik}\right)\left(\sum_{l=0}^{p-1}h_{jl}\sum_{m=0}^{n-1}a_{ml}\right) = h_{jj}!
|
||||
\]
|
||||
!et
|
||||
|
||||
|
||||
The first step here is to approximate the function $y$ with a first-order polynomial, that is we write
|
||||
!bt
|
||||
\[
|
||||
y=y(x) \rightarrow y(x_i) \approx \beta_0+\beta_1 x_i.
|
||||
\]
|
||||
!et
|
||||
By computing the derivatives of $\chi^2$ with respect to $\beta_0$ and $\beta_1$ show that these are given by
|
||||
!bt
|
||||
\[
|
||||
\frac{\partial \chi^2(\hat{\beta})}{\partial \beta_0} = -2\left[ \sum_{i=0}^{1}\left(\frac{y_i-\beta_0-\beta_1x_{i}}{\sigma_i^2}\right)\right]=0,
|
||||
\]
|
||||
!et
|
||||
and
|
||||
!bt
|
||||
\[
|
||||
\frac{\partial \chi^2(\hat{\beta})}{\partial \beta_0} = -2\left[ \sum_{i=0}^{1}x_i\left(\frac{y_i-\beta_0-\beta_1x_{i}}{\sigma_i^2}\right)\right]=0.
|
||||
\]
|
||||
!et
|
||||
Define then
|
||||
!bt
|
||||
\[
|
||||
\gamma = \sum_{i=0}^{1}\frac{1}{\sigma_i^2},
|
||||
\]
|
||||
!et
|
||||
|
||||
!bt
|
||||
\[
|
||||
\gamma_x = \sum_{i=0}^{1}\frac{x_{i}}{\sigma_i^2},
|
||||
\]
|
||||
!et
|
||||
!bt
|
||||
\[
|
||||
\gamma_y = \sum_{i=0}^{1}\left(\frac{y_i}{\sigma_i^2}\right),
|
||||
\]
|
||||
!et
|
||||
!bt
|
||||
\[
|
||||
\gamma_{xx} = \sum_{i=0}^{1}\frac{x_ix_{i}}{\sigma_i^2},
|
||||
\]
|
||||
!et
|
||||
!bt
|
||||
\[
|
||||
\gamma_{xy} = \sum_{i=0}^{1}\frac{y_ix_{i}}{\sigma_i^2},
|
||||
\]
|
||||
!et
|
||||
and show that
|
||||
!bt
|
||||
\[
|
||||
\beta_0 = \frac{\gamma_{xx}\gamma_y-\gamma_x\gamma_y}{\gamma\gamma_{xx}-\gamma_x^2},
|
||||
\]
|
||||
!et
|
||||
!bt
|
||||
\[
|
||||
\beta_1 = \frac{\gamma_{xy}\gamma-\gamma_x\gamma_y}{\gamma\gamma_{xx}-\gamma_x^2}.
|
||||
\]
|
||||
!et
|
||||
Find these parameters for your data set and compare the fitted function $y=y(x) \rightarrow y(x_i) \approx \beta_0+\beta_1 x_i$ and find the error in the parameters $\beta_0$ and $\beta_1$ as well.
|
||||
How does your parametrization compare with the input data $y_i$? Give a critical discussion of the method.
|
||||
|
||||
Develop now a program where you extract the parameters $\beta_i$ and their corresponding errors using the general Least Square method (LSM), with polynomials of degree $p=2$ and $p=3$. Which polyomials gives the best fit to your data? Here you should prepare an input file with the number of data points in your training data set, the corresponding standard deviation $\sigma_i$ as well as the degree $p$ of the polynomial you want to fit.
|
||||
|
||||
The LSM suffers often from both being underdetermined and overdetermined in the unknown coefficients $\beta_i$. A better approach is to use the Singular Value Decomposition (SVD) method discussed in the lecture notes on regression analysis. Here you should use the "SVD programs":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Programs/SVD" and use the same input file you used for the general LSM. In the main functions you should specifiy which function you wish to approximate the date with. The example programs discussed above show you examples on how to use these codes as well as how to write the functional form of the polynomial or fitting function.
|
||||
|
||||
|
||||
=== Part d): Introducing Bayesian statistics ===
|
||||
=== Part e): Summary ===
|
||||
|
||||
You should make a summary of the various methods and their pros and cons. For the final presentation, you should have at least coded one of these methods yourself and discussed the evaluation of the cost function.
|
||||
|
||||
===== Background literature =====
|
||||
|
||||
On Machine Learning we recommend strongly the article of Mehta *et al.*
|
||||
Textbooks on Machine Learning can be found at the "Github address of FYS-STK4155":"https://github.com/CompPhysics/MachineLearning/tree/master/doc/Textbooks", see in particular Marsland's text.
|
||||
|
||||
* "Mehta et al, arXiv 1803.08823":"https://arxiv.org/abs/1803.08823", *A high-bias, low-variance introduction to Machine Learning for physicists*, ArXiv:1803.08823.
|
||||
|
||||
If you wish to read more about the Ising model and statistical physics here are three suggestions.
|
||||
|
||||
* "M. Plischke and B. Bergersen":"http://www.worldscientific.com/worldscibooks/10.1142/5660", *Equilibrium Statistical Physics*, World Scientific, see chapters 5 and 6.
|
||||
@@ -260,10 +133,35 @@ project.
|
||||
* 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.
|
||||
|
||||
|
||||
===== Software and needed installations =====
|
||||
|
||||
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 _pip_ as
|
||||
o pip install numpy scipy matplotlib ipython scikit-learn tensorflow sympy pandas pillow
|
||||
For Python3, replace _pip_ with _pip3_.
|
||||
|
||||
See below for a discussion of _tensorflow_ and _scikit-learn_.
|
||||
|
||||
For OSX users we recommend also, after having installed Xcode, to install _brew_. Brew allows
|
||||
for a seamless installation of additional software via for example
|
||||
o brew install python3
|
||||
|
||||
For Linux users, with its variety of distributions like for example the widely popular Ubuntu distribution
|
||||
you can use _pip_ as well and simply install Python as
|
||||
o sudo apt-get install python3 (or python for python2.7)
|
||||
etc etc.
|
||||
|
||||
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
|
||||
o "Anaconda":"https://docs.anaconda.com/" 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 _conda_
|
||||
o "Enthought canopy":"https://www.enthought.com/product/canopy/" is a Python distribution for scientific and analytic computing distribution and analysis environment, available for free and under a commercial license.
|
||||
|
||||
Popular software packages written in Python for ML are
|
||||
|
||||
* "Scikit-learn":"http://scikit-learn.org/stable/",
|
||||
* "Tensorflow":"https://www.tensorflow.org/",
|
||||
* "PyTorch":"http://pytorch.org/" and
|
||||
* "Keras":"https://keras.io/".
|
||||
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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user