update on getting started
This commit is contained in:
@@ -55,27 +55,25 @@ Automatically generated HTML file from DocOnce source
|
||||
None,
|
||||
'___sec8'),
|
||||
('Basic Matrix Features', 2, None, '___sec9'),
|
||||
('Basic Matrix Features', 2, None, '___sec10'),
|
||||
('Basic Matrix Features', 2, None, '___sec11'),
|
||||
('Some famous Matrices', 2, None, '___sec12'),
|
||||
('Basic Matrix Features', 2, None, '___sec13'),
|
||||
('Numpy and arrays', 2, None, '___sec14'),
|
||||
('Matrices in Python', 2, None, '___sec15'),
|
||||
('Meet the Pandas', 2, None, '___sec16'),
|
||||
('Reading Data and fitting', 2, None, '___sec17'),
|
||||
('Some famous Matrices', 3, None, '___sec10'),
|
||||
('More Basic Matrix Features', 3, None, '___sec11'),
|
||||
('Numpy and arrays', 2, None, '___sec12'),
|
||||
('Matrices in Python', 2, None, '___sec13'),
|
||||
('Meet the Pandas', 2, None, '___sec14'),
|
||||
('Reading Data and fitting', 2, None, '___sec15'),
|
||||
('Simple linear regression model using _scikit-learn_',
|
||||
3,
|
||||
None,
|
||||
'___sec18'),
|
||||
'___sec16'),
|
||||
('To our real data: nuclear binding energies. Brief reminder on '
|
||||
'masses and binding energies',
|
||||
3,
|
||||
None,
|
||||
'___sec19'),
|
||||
('Organizing our data', 3, None, '___sec20'),
|
||||
('Seeing the wood for the trees', 3, None, '___sec21'),
|
||||
('And what about using neural networks?', 3, None, '___sec22'),
|
||||
('A first summary', 2, None, '___sec23')]}
|
||||
'___sec17'),
|
||||
('Organizing our data', 3, None, '___sec18'),
|
||||
('Seeing the wood for the trees', 3, None, '___sec19'),
|
||||
('And what about using neural networks?', 3, None, '___sec20'),
|
||||
('A first summary', 2, None, '___sec21')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -123,20 +121,18 @@ MathJax.Hub.Config({
|
||||
<!-- navigation toc: --> <li><a href="#___sec7" style="font-size: 80%;"><b>Installing R, C++, cython, Numba etc</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec8" style="font-size: 80%;"><b>Numpy examples and Important Matrix and vector handling packages</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec9" style="font-size: 80%;"><b>Basic Matrix Features</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec10" style="font-size: 80%;"><b>Basic Matrix Features</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec11" style="font-size: 80%;"><b>Basic Matrix Features</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec12" style="font-size: 80%;"><b>Some famous Matrices</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec13" style="font-size: 80%;"><b>Basic Matrix Features</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec14" style="font-size: 80%;"><b>Numpy and arrays</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec15" style="font-size: 80%;"><b>Matrices in Python</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec16" style="font-size: 80%;"><b>Meet the Pandas</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec17" style="font-size: 80%;"><b>Reading Data and fitting</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec18" style="font-size: 80%;"> Simple linear regression model using <b>scikit-learn</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec19" style="font-size: 80%;"> To our real data: nuclear binding energies. Brief reminder on masses and binding energies</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec20" style="font-size: 80%;"> Organizing our data</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec21" style="font-size: 80%;"> Seeing the wood for the trees</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec22" style="font-size: 80%;"> And what about using neural networks?</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec23" style="font-size: 80%;"><b>A first summary</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec10" style="font-size: 80%;"> Some famous Matrices</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec11" style="font-size: 80%;"> More Basic Matrix Features</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec12" style="font-size: 80%;"><b>Numpy and arrays</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec13" style="font-size: 80%;"><b>Matrices in Python</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec14" style="font-size: 80%;"><b>Meet the Pandas</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec15" style="font-size: 80%;"><b>Reading Data and fitting</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec16" style="font-size: 80%;"> Simple linear regression model using <b>scikit-learn</b></a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec17" style="font-size: 80%;"> To our real data: nuclear binding energies. Brief reminder on masses and binding energies</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec18" style="font-size: 80%;"> Organizing our data</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec19" style="font-size: 80%;"> Seeing the wood for the trees</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec20" style="font-size: 80%;"> And what about using neural networks?</a></li>
|
||||
<!-- navigation toc: --> <li><a href="#___sec21" style="font-size: 80%;"><b>A first summary</b></a></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
@@ -170,7 +166,7 @@ MathJax.Hub.Config({
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p>
|
||||
<center><h4>Aug 13, 2019</h4></center> <!-- date -->
|
||||
<center><h4>Aug 14, 2019</h4></center> <!-- date -->
|
||||
<br>
|
||||
<p>
|
||||
</div> <!-- end jumbotron -->
|
||||
@@ -194,7 +190,7 @@ polynomials with random noise added. We will use the Python
|
||||
software package <a href="http://scikit-learn.org/stable/" target="_self">Scikit-Learn</a> and
|
||||
introduce various machine learning algorithms to make fits of
|
||||
the data and predictions. We move thereafter to more interesting
|
||||
cases such as nuclear binding energies.
|
||||
cases such as data from say experiments (below we will look at experimental nuclear binding energies as an example).
|
||||
These are examples where we can easily set up the data and
|
||||
then use machine learning algorithms included in for example
|
||||
<b>Scikit-Learn</b>.
|
||||
@@ -204,7 +200,7 @@ These examples will serve us the purpose of getting
|
||||
started. Furthermore, they allow us to catch more than two birds with
|
||||
a stone. They will allow us to bring in some programming specific
|
||||
topics and tools as well as showing the power of various Python
|
||||
packages for machine learning and statistical data analysis.
|
||||
libraries for machine learning and statistical data analysis.
|
||||
|
||||
<p>
|
||||
Here, we will mainly focus on two
|
||||
@@ -411,14 +407,14 @@ Here we list several useful Python libraries we strongly recommend (if you use a
|
||||
|
||||
<p>
|
||||
You will also find it convenient to utilize <b>R</b>. We will mainly
|
||||
use Python during lectures and in various projects and exercises.
|
||||
use Python during our lectures and in various projects and exercises.
|
||||
Those of you
|
||||
already familiar with <b>R</b> should feel free to continue using <b>R</b>, keeping
|
||||
however an eye on the parallel Python set ups. Similarly, if you are a
|
||||
Python afecionado, feel free to explore <b>R</b> as well. Jupyter/Ipython
|
||||
notebook allows you to run <b>R</b> codes interactively in your
|
||||
browser. The software library <b>R</b> is tuned to statistically analysis
|
||||
and allows for an easy usage of the tools we will discuss in these
|
||||
browser. The software library <b>R</b> is really tailored for statistical data analysis
|
||||
and allows for an easy usage of the tools and algorithms we will discuss in these
|
||||
lectures.
|
||||
|
||||
<p>
|
||||
@@ -462,7 +458,7 @@ formats, ipython notebooks, latex files, pdf files etc with minimal edits. These
|
||||
<h2 id="___sec8" class="anchor">Numpy examples and Important Matrix and vector handling packages </h2>
|
||||
|
||||
<p>
|
||||
There are several central software packages for linear algebra and eigenvalue problems. Several of the more
|
||||
There are several central software libraries for linear algebra and eigenvalue problems. Several of the more
|
||||
popular ones have been wrapped into ofter software packages like those from the widely used text <b>Numerical Recipes</b>. The original source codes in many of the available packages are often taken from the widely used
|
||||
software package LAPACK, which follows two other popular packages
|
||||
developed in the 1970s, namely EISPACK and LINPACK. We describe them shortly here.
|
||||
@@ -493,14 +489,6 @@ $$
|
||||
0 & 0 & 0 & 1
|
||||
\end{bmatrix}
|
||||
$$
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<h2 id="___sec10" class="anchor">Basic Matrix Features </h2>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
|
||||
<p>
|
||||
The inverse of a matrix is defined by
|
||||
@@ -508,16 +496,6 @@ The inverse of a matrix is defined by
|
||||
$$
|
||||
\mathbf{A}^{-1} \cdot \mathbf{A} = I
|
||||
$$
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<h2 id="___sec11" class="anchor">Basic Matrix Features </h2>
|
||||
|
||||
<p>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p> <!-- subsequent paragraphs come in larger fonts, so start with a paragraph -->
|
||||
|
||||
<p>
|
||||
|
||||
@@ -542,7 +520,7 @@ $$
|
||||
</div>
|
||||
|
||||
|
||||
<h2 id="___sec12" class="anchor">Some famous Matrices </h2>
|
||||
<h3 id="___sec10" class="anchor">Some famous Matrices </h3>
|
||||
|
||||
<ul>
|
||||
<li> Diagonal if \( a_{ij}=0 \) for \( i\ne j \)</li>
|
||||
@@ -556,7 +534,7 @@ $$
|
||||
<li> Banded, block upper triangular, block lower triangular....</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="___sec13" class="anchor">Basic Matrix Features </h2>
|
||||
<h3 id="___sec11" class="anchor">More Basic Matrix Features </h3>
|
||||
|
||||
<p>
|
||||
<div class="panel panel-default">
|
||||
@@ -576,7 +554,7 @@ For an \( N\times N \) matrix \( \mathbf{A} \) the following properties are all
|
||||
</div>
|
||||
|
||||
|
||||
<h2 id="___sec14" class="anchor">Numpy and arrays </h2>
|
||||
<h2 id="___sec12" class="anchor">Numpy and arrays </h2>
|
||||
<a href="http://www.numpy.org/" target="_self">Numpy</a> provides an easy way to handle arrays in Python. The standard way to import this library is as
|
||||
|
||||
<p>
|
||||
@@ -661,7 +639,7 @@ x <span style="color: #666666">=</span> np<span style="color: #666666">.</span>l
|
||||
<span style="color: #008000; font-weight: bold">print</span>(x<span style="color: #666666">.</span>itemsize)
|
||||
</pre></div>
|
||||
|
||||
<h2 id="___sec15" class="anchor">Matrices in Python </h2>
|
||||
<h2 id="___sec13" class="anchor">Matrices in Python </h2>
|
||||
|
||||
<p>
|
||||
Having defined vectors, we are now ready to try out matrices. We can
|
||||
@@ -798,7 +776,7 @@ plt<span style="color: #666666">.</span>plot(x,y,marker<span style="color: #6666
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
|
||||
<h2 id="___sec16" class="anchor">Meet the Pandas </h2>
|
||||
<h2 id="___sec14" class="anchor">Meet the Pandas </h2>
|
||||
|
||||
<p>
|
||||
<br /><br /><center><p><img src="fig/pandas.jpg" align="bottom" width=600></p></center><br /><br />
|
||||
@@ -923,7 +901,7 @@ most operations are vectorized, achieving thereby a high performance when dealin
|
||||
As we will see below it leads also to a very concice code close to the mathematical operations we may be interested in.
|
||||
For multidimensional arrays, we recommend strongly <a href="http://xarray.pydata.org/en/stable/" target="_self">xarray</a>. <b>xarray</b> has much of the same flexibility as <b>pandas</b>, but allows for the extension to higher dimensions than two. We will see examples later of the usage of both <b>pandas</b> and <b>xarray</b>.
|
||||
|
||||
<h2 id="___sec17" class="anchor">Reading Data and fitting </h2>
|
||||
<h2 id="___sec15" class="anchor">Reading Data and fitting </h2>
|
||||
|
||||
<p>
|
||||
In order to study various Machine Learning algorithms, we need to
|
||||
@@ -959,7 +937,7 @@ you can easily implement other algorithms like decision trees and random forests
|
||||
But before we really start with nuclear physics data, let's just look at some simpler polynomial fitting cases, such as,
|
||||
(don't be offended) fitting straight lines!
|
||||
|
||||
<h3 id="___sec18" class="anchor">Simple linear regression model using <b>scikit-learn</b> </h3>
|
||||
<h3 id="___sec16" class="anchor">Simple linear regression model using <b>scikit-learn</b> </h3>
|
||||
|
||||
<p>
|
||||
We start with perhaps our simplest possible example, using <b>Scikit-Learn</b> to perform linear regression analysis on a data set produced by us.
|
||||
@@ -1253,7 +1231,7 @@ plt<span style="color: #666666">.</span>show()
|
||||
<span style="color: #008000; font-weight: bold">print</span> (error(y))
|
||||
</pre></div>
|
||||
|
||||
<h3 id="___sec19" class="anchor">To our real data: nuclear binding energies. Brief reminder on masses and binding energies </h3>
|
||||
<h3 id="___sec17" class="anchor">To our real data: nuclear binding energies. Brief reminder on masses and binding energies </h3>
|
||||
|
||||
<p>
|
||||
Let us now dive into nuclear physics and remind ourselves briefly about some basic features about binding
|
||||
@@ -1331,7 +1309,7 @@ We could also add a so-called pairing term, which is a correction term that
|
||||
arises from the tendency of proton pairs and neutron pairs to
|
||||
occur. An even number of particles is more stable than an odd number.
|
||||
|
||||
<h3 id="___sec20" class="anchor">Organizing our data </h3>
|
||||
<h3 id="___sec18" class="anchor">Organizing our data </h3>
|
||||
|
||||
<p>
|
||||
Let us start with reading and organizing our data.
|
||||
@@ -1517,7 +1495,7 @@ save_fig(<span style="color: #BA2121">"Masses2016"</span>)
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
|
||||
<h3 id="___sec21" class="anchor">Seeing the wood for the trees </h3>
|
||||
<h3 id="___sec19" class="anchor">Seeing the wood for the trees </h3>
|
||||
|
||||
<p>
|
||||
As a teaser, let us now see how we can do this with decision trees using <b>scikit-learn</b>. Later we will switch to so-called <b>random forests</b>!
|
||||
@@ -1556,7 +1534,7 @@ plt<span style="color: #666666">.</span>show()
|
||||
<span style="color: #008000; font-weight: bold">print</span>(np<span style="color: #666666">.</span>mean( (Energies<span style="color: #666666">-</span>y_1)<span style="color: #666666">**2</span>))
|
||||
</pre></div>
|
||||
|
||||
<h3 id="___sec22" class="anchor">And what about using neural networks? </h3>
|
||||
<h3 id="___sec20" class="anchor">And what about using neural networks? </h3>
|
||||
|
||||
The <b>seaborn</b> package allows us to visualize data in an efficient way. Note that we use <b>scikit-learn</b>'s multi-layer perceptron (or feed forward neural network)
|
||||
functionality.
|
||||
@@ -1594,7 +1572,7 @@ ax<span style="color: #666666">.</span>set_xlabel(<span style="color: #BA2121">&
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
|
||||
<h2 id="___sec23" class="anchor">A first summary </h2>
|
||||
<h2 id="___sec21" class="anchor">A first summary </h2>
|
||||
|
||||
<p>
|
||||
The aim behind these introductory words was to present to you various
|
||||
|
||||
@@ -148,7 +148,7 @@ MathJax.Hub.Config({
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p> <br>
|
||||
<center><h4>Aug 13, 2019</h4></center> <!-- date -->
|
||||
<center><h4>Aug 14, 2019</h4></center> <!-- date -->
|
||||
<br>
|
||||
|
||||
<h2 id="___sec0">Introduction </h2>
|
||||
@@ -170,7 +170,7 @@ polynomials with random noise added. We will use the Python
|
||||
software package <a href="http://scikit-learn.org/stable/" target="_blank">Scikit-Learn</a> and
|
||||
introduce various machine learning algorithms to make fits of
|
||||
the data and predictions. We move thereafter to more interesting
|
||||
cases such as nuclear binding energies.
|
||||
cases such as data from say experiments (below we will look at experimental nuclear binding energies as an example).
|
||||
These are examples where we can easily set up the data and
|
||||
then use machine learning algorithms included in for example
|
||||
<b>Scikit-Learn</b>.
|
||||
@@ -180,7 +180,7 @@ These examples will serve us the purpose of getting
|
||||
started. Furthermore, they allow us to catch more than two birds with
|
||||
a stone. They will allow us to bring in some programming specific
|
||||
topics and tools as well as showing the power of various Python
|
||||
packages for machine learning and statistical data analysis.
|
||||
libraries for machine learning and statistical data analysis.
|
||||
|
||||
<p>
|
||||
Here, we will mainly focus on two
|
||||
@@ -396,14 +396,14 @@ Here we list several useful Python libraries we strongly recommend (if you use a
|
||||
|
||||
<p>
|
||||
You will also find it convenient to utilize <b>R</b>. We will mainly
|
||||
use Python during lectures and in various projects and exercises.
|
||||
use Python during our lectures and in various projects and exercises.
|
||||
Those of you
|
||||
already familiar with <b>R</b> should feel free to continue using <b>R</b>, keeping
|
||||
however an eye on the parallel Python set ups. Similarly, if you are a
|
||||
Python afecionado, feel free to explore <b>R</b> as well. Jupyter/Ipython
|
||||
notebook allows you to run <b>R</b> codes interactively in your
|
||||
browser. The software library <b>R</b> is tuned to statistically analysis
|
||||
and allows for an easy usage of the tools we will discuss in these
|
||||
browser. The software library <b>R</b> is really tailored for statistical data analysis
|
||||
and allows for an easy usage of the tools and algorithms we will discuss in these
|
||||
lectures.
|
||||
|
||||
<p>
|
||||
@@ -447,7 +447,7 @@ formats, ipython notebooks, latex files, pdf files etc with minimal edits. These
|
||||
<h2 id="___sec8">Numpy examples and Important Matrix and vector handling packages </h2>
|
||||
|
||||
<p>
|
||||
There are several central software packages for linear algebra and eigenvalue problems. Several of the more
|
||||
There are several central software libraries for linear algebra and eigenvalue problems. Several of the more
|
||||
popular ones have been wrapped into ofter software packages like those from the widely used text <b>Numerical Recipes</b>. The original source codes in many of the available packages are often taken from the widely used
|
||||
software package LAPACK, which follows two other popular packages
|
||||
developed in the 1970s, namely EISPACK and LINPACK. We describe them shortly here.
|
||||
@@ -482,11 +482,7 @@ $$
|
||||
\end{bmatrix}
|
||||
$$
|
||||
<p> <br>
|
||||
</div>
|
||||
|
||||
<h2 id="___sec10">Basic Matrix Features </h2>
|
||||
<div class="alert alert-block alert-block alert-text-normal">
|
||||
<b></b>
|
||||
<p>
|
||||
The inverse of a matrix is defined by
|
||||
|
||||
@@ -495,13 +491,7 @@ $$
|
||||
\mathbf{A}^{-1} \cdot \mathbf{A} = I
|
||||
$$
|
||||
<p> <br>
|
||||
</div>
|
||||
|
||||
<h2 id="___sec11">Basic Matrix Features </h2>
|
||||
|
||||
<p>
|
||||
<div class="alert alert-block alert-block alert-text-normal">
|
||||
<b>Matrix Properties Reminder.</b>
|
||||
<p>
|
||||
<table border="1">
|
||||
<thead>
|
||||
@@ -518,7 +508,7 @@ $$
|
||||
|
||||
</div>
|
||||
|
||||
<h2 id="___sec12">Some famous Matrices </h2>
|
||||
<h3 id="___sec10">Some famous Matrices </h3>
|
||||
|
||||
<ul>
|
||||
|
||||
@@ -541,7 +531,7 @@ $$
|
||||
<p><li> Banded, block upper triangular, block lower triangular....</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="___sec13">Basic Matrix Features </h2>
|
||||
<h3 id="___sec11">More Basic Matrix Features </h3>
|
||||
|
||||
<p>
|
||||
<div class="alert alert-block alert-block alert-text-normal">
|
||||
@@ -565,7 +555,7 @@ For an \( N\times N \) matrix \( \mathbf{A} \) the following properties are all
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<h2 id="___sec14">Numpy and arrays </h2>
|
||||
<h2 id="___sec12">Numpy and arrays </h2>
|
||||
<a href="http://www.numpy.org/" target="_blank">Numpy</a> provides an easy way to handle arrays in Python. The standard way to import this library is as
|
||||
|
||||
<p>
|
||||
@@ -650,7 +640,7 @@ x = np.log(np.array([<span style="color: #B452CD">4.0</span>, <span style="color
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(x.itemsize)
|
||||
</pre></div>
|
||||
|
||||
<h2 id="___sec15">Matrices in Python </h2>
|
||||
<h2 id="___sec13">Matrices in Python </h2>
|
||||
|
||||
<p>
|
||||
Having defined vectors, we are now ready to try out matrices. We can
|
||||
@@ -793,7 +783,7 @@ plt.plot(x,y,marker=<span style="color: #CD5555">'x'</span>)
|
||||
plt.show()
|
||||
</pre></div>
|
||||
|
||||
<h2 id="___sec16">Meet the Pandas </h2>
|
||||
<h2 id="___sec14">Meet the Pandas </h2>
|
||||
|
||||
<p>
|
||||
<br /><br /><center><p><img src="fig/pandas.jpg" align="bottom" width=600></p></center><br /><br />
|
||||
@@ -918,7 +908,7 @@ most operations are vectorized, achieving thereby a high performance when dealin
|
||||
As we will see below it leads also to a very concice code close to the mathematical operations we may be interested in.
|
||||
For multidimensional arrays, we recommend strongly <a href="http://xarray.pydata.org/en/stable/" target="_blank">xarray</a>. <b>xarray</b> has much of the same flexibility as <b>pandas</b>, but allows for the extension to higher dimensions than two. We will see examples later of the usage of both <b>pandas</b> and <b>xarray</b>.
|
||||
|
||||
<h2 id="___sec17">Reading Data and fitting </h2>
|
||||
<h2 id="___sec15">Reading Data and fitting </h2>
|
||||
|
||||
<p>
|
||||
In order to study various Machine Learning algorithms, we need to
|
||||
@@ -954,7 +944,7 @@ you can easily implement other algorithms like decision trees and random forests
|
||||
But before we really start with nuclear physics data, let's just look at some simpler polynomial fitting cases, such as,
|
||||
(don't be offended) fitting straight lines!
|
||||
|
||||
<h3 id="___sec18">Simple linear regression model using <b>scikit-learn</b> </h3>
|
||||
<h3 id="___sec16">Simple linear regression model using <b>scikit-learn</b> </h3>
|
||||
|
||||
<p>
|
||||
We start with perhaps our simplest possible example, using <b>Scikit-Learn</b> to perform linear regression analysis on a data set produced by us.
|
||||
@@ -1266,7 +1256,7 @@ plt.show()
|
||||
<span style="color: #8B008B; font-weight: bold">print</span> (error(y))
|
||||
</pre></div>
|
||||
|
||||
<h3 id="___sec19">To our real data: nuclear binding energies. Brief reminder on masses and binding energies </h3>
|
||||
<h3 id="___sec17">To our real data: nuclear binding energies. Brief reminder on masses and binding energies </h3>
|
||||
|
||||
<p>
|
||||
Let us now dive into nuclear physics and remind ourselves briefly about some basic features about binding
|
||||
@@ -1360,7 +1350,7 @@ We could also add a so-called pairing term, which is a correction term that
|
||||
arises from the tendency of proton pairs and neutron pairs to
|
||||
occur. An even number of particles is more stable than an odd number.
|
||||
|
||||
<h3 id="___sec20">Organizing our data </h3>
|
||||
<h3 id="___sec18">Organizing our data </h3>
|
||||
|
||||
<p>
|
||||
Let us start with reading and organizing our data.
|
||||
@@ -1546,7 +1536,7 @@ save_fig(<span style="color: #CD5555">"Masses2016"</span>)
|
||||
plt.show()
|
||||
</pre></div>
|
||||
|
||||
<h3 id="___sec21">Seeing the wood for the trees </h3>
|
||||
<h3 id="___sec19">Seeing the wood for the trees </h3>
|
||||
|
||||
<p>
|
||||
As a teaser, let us now see how we can do this with decision trees using <b>scikit-learn</b>. Later we will switch to so-called <b>random forests</b>!
|
||||
@@ -1585,7 +1575,7 @@ plt.show()
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(np.mean( (Energies-y_1)**<span style="color: #B452CD">2</span>))
|
||||
</pre></div>
|
||||
|
||||
<h3 id="___sec22">And what about using neural networks? </h3>
|
||||
<h3 id="___sec20">And what about using neural networks? </h3>
|
||||
|
||||
The <b>seaborn</b> package allows us to visualize data in an efficient way. Note that we use <b>scikit-learn</b>'s multi-layer perceptron (or feed forward neural network)
|
||||
functionality.
|
||||
@@ -1623,7 +1613,7 @@ ax.set_xlabel(<span style="color: #CD5555">"$\lambda$"</span>)
|
||||
plt.show()
|
||||
</pre></div>
|
||||
|
||||
<h2 id="___sec23">A first summary </h2>
|
||||
<h2 id="___sec21">A first summary </h2>
|
||||
|
||||
<p>
|
||||
The aim behind these introductory words was to present to you various
|
||||
|
||||
@@ -75,27 +75,25 @@ div { text-align: justify; text-justify: inter-word; }
|
||||
None,
|
||||
'___sec8'),
|
||||
('Basic Matrix Features', 2, None, '___sec9'),
|
||||
('Basic Matrix Features', 2, None, '___sec10'),
|
||||
('Basic Matrix Features', 2, None, '___sec11'),
|
||||
('Some famous Matrices', 2, None, '___sec12'),
|
||||
('Basic Matrix Features', 2, None, '___sec13'),
|
||||
('Numpy and arrays', 2, None, '___sec14'),
|
||||
('Matrices in Python', 2, None, '___sec15'),
|
||||
('Meet the Pandas', 2, None, '___sec16'),
|
||||
('Reading Data and fitting', 2, None, '___sec17'),
|
||||
('Some famous Matrices', 3, None, '___sec10'),
|
||||
('More Basic Matrix Features', 3, None, '___sec11'),
|
||||
('Numpy and arrays', 2, None, '___sec12'),
|
||||
('Matrices in Python', 2, None, '___sec13'),
|
||||
('Meet the Pandas', 2, None, '___sec14'),
|
||||
('Reading Data and fitting', 2, None, '___sec15'),
|
||||
('Simple linear regression model using _scikit-learn_',
|
||||
3,
|
||||
None,
|
||||
'___sec18'),
|
||||
'___sec16'),
|
||||
('To our real data: nuclear binding energies. Brief reminder on '
|
||||
'masses and binding energies',
|
||||
3,
|
||||
None,
|
||||
'___sec19'),
|
||||
('Organizing our data', 3, None, '___sec20'),
|
||||
('Seeing the wood for the trees', 3, None, '___sec21'),
|
||||
('And what about using neural networks?', 3, None, '___sec22'),
|
||||
('A first summary', 2, None, '___sec23')]}
|
||||
'___sec17'),
|
||||
('Organizing our data', 3, None, '___sec18'),
|
||||
('Seeing the wood for the trees', 3, None, '___sec19'),
|
||||
('And what about using neural networks?', 3, None, '___sec20'),
|
||||
('A first summary', 2, None, '___sec21')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -137,7 +135,7 @@ MathJax.Hub.Config({
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p>
|
||||
<center><h4>Aug 13, 2019</h4></center> <!-- date -->
|
||||
<center><h4>Aug 14, 2019</h4></center> <!-- date -->
|
||||
<br>
|
||||
|
||||
<h2 id="___sec0">Introduction </h2>
|
||||
@@ -159,7 +157,7 @@ polynomials with random noise added. We will use the Python
|
||||
software package <a href="http://scikit-learn.org/stable/" target="_blank">Scikit-Learn</a> and
|
||||
introduce various machine learning algorithms to make fits of
|
||||
the data and predictions. We move thereafter to more interesting
|
||||
cases such as nuclear binding energies.
|
||||
cases such as data from say experiments (below we will look at experimental nuclear binding energies as an example).
|
||||
These are examples where we can easily set up the data and
|
||||
then use machine learning algorithms included in for example
|
||||
<b>Scikit-Learn</b>.
|
||||
@@ -169,7 +167,7 @@ These examples will serve us the purpose of getting
|
||||
started. Furthermore, they allow us to catch more than two birds with
|
||||
a stone. They will allow us to bring in some programming specific
|
||||
topics and tools as well as showing the power of various Python
|
||||
packages for machine learning and statistical data analysis.
|
||||
libraries for machine learning and statistical data analysis.
|
||||
|
||||
<p>
|
||||
Here, we will mainly focus on two
|
||||
@@ -376,14 +374,14 @@ Here we list several useful Python libraries we strongly recommend (if you use a
|
||||
|
||||
<p>
|
||||
You will also find it convenient to utilize <b>R</b>. We will mainly
|
||||
use Python during lectures and in various projects and exercises.
|
||||
use Python during our lectures and in various projects and exercises.
|
||||
Those of you
|
||||
already familiar with <b>R</b> should feel free to continue using <b>R</b>, keeping
|
||||
however an eye on the parallel Python set ups. Similarly, if you are a
|
||||
Python afecionado, feel free to explore <b>R</b> as well. Jupyter/Ipython
|
||||
notebook allows you to run <b>R</b> codes interactively in your
|
||||
browser. The software library <b>R</b> is tuned to statistically analysis
|
||||
and allows for an easy usage of the tools we will discuss in these
|
||||
browser. The software library <b>R</b> is really tailored for statistical data analysis
|
||||
and allows for an easy usage of the tools and algorithms we will discuss in these
|
||||
lectures.
|
||||
|
||||
<p>
|
||||
@@ -427,7 +425,7 @@ formats, ipython notebooks, latex files, pdf files etc with minimal edits. These
|
||||
<h2 id="___sec8">Numpy examples and Important Matrix and vector handling packages </h2>
|
||||
|
||||
<p>
|
||||
There are several central software packages for linear algebra and eigenvalue problems. Several of the more
|
||||
There are several central software libraries for linear algebra and eigenvalue problems. Several of the more
|
||||
popular ones have been wrapped into ofter software packages like those from the widely used text <b>Numerical Recipes</b>. The original source codes in many of the available packages are often taken from the widely used
|
||||
software package LAPACK, which follows two other popular packages
|
||||
developed in the 1970s, namely EISPACK and LINPACK. We describe them shortly here.
|
||||
@@ -458,13 +456,6 @@ $$
|
||||
0 & 0 & 0 & 1
|
||||
\end{bmatrix}
|
||||
$$
|
||||
</div>
|
||||
|
||||
|
||||
<h2 id="___sec10">Basic Matrix Features </h2>
|
||||
<div class="alert alert-block alert-block alert-text-normal">
|
||||
<b></b>
|
||||
<p>
|
||||
|
||||
<p>
|
||||
The inverse of a matrix is defined by
|
||||
@@ -472,15 +463,6 @@ The inverse of a matrix is defined by
|
||||
$$
|
||||
\mathbf{A}^{-1} \cdot \mathbf{A} = I
|
||||
$$
|
||||
</div>
|
||||
|
||||
|
||||
<h2 id="___sec11">Basic Matrix Features </h2>
|
||||
|
||||
<p>
|
||||
<div class="alert alert-block alert-block alert-text-normal">
|
||||
<b>Matrix Properties Reminder.</b>
|
||||
<p>
|
||||
|
||||
<p>
|
||||
<table border="1">
|
||||
@@ -499,7 +481,7 @@ $$
|
||||
</div>
|
||||
|
||||
|
||||
<h2 id="___sec12">Some famous Matrices </h2>
|
||||
<h3 id="___sec10">Some famous Matrices </h3>
|
||||
|
||||
<ul>
|
||||
<li> Diagonal if \( a_{ij}=0 \) for \( i\ne j \)</li>
|
||||
@@ -513,7 +495,7 @@ $$
|
||||
<li> Banded, block upper triangular, block lower triangular....</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="___sec13">Basic Matrix Features </h2>
|
||||
<h3 id="___sec11">More Basic Matrix Features </h3>
|
||||
|
||||
<p>
|
||||
<div class="alert alert-block alert-block alert-text-normal">
|
||||
@@ -532,7 +514,7 @@ For an \( N\times N \) matrix \( \mathbf{A} \) the following properties are all
|
||||
</div>
|
||||
|
||||
|
||||
<h2 id="___sec14">Numpy and arrays </h2>
|
||||
<h2 id="___sec12">Numpy and arrays </h2>
|
||||
<a href="http://www.numpy.org/" target="_blank">Numpy</a> provides an easy way to handle arrays in Python. The standard way to import this library is as
|
||||
|
||||
<p>
|
||||
@@ -617,7 +599,7 @@ x = np.log(np.array([<span style="color: #B452CD">4.0</span>, <span style="color
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(x.itemsize)
|
||||
</pre></div>
|
||||
|
||||
<h2 id="___sec15">Matrices in Python </h2>
|
||||
<h2 id="___sec13">Matrices in Python </h2>
|
||||
|
||||
<p>
|
||||
Having defined vectors, we are now ready to try out matrices. We can
|
||||
@@ -754,7 +736,7 @@ plt.plot(x,y,marker=<span style="color: #CD5555">'x'</span>)
|
||||
plt.show()
|
||||
</pre></div>
|
||||
|
||||
<h2 id="___sec16">Meet the Pandas </h2>
|
||||
<h2 id="___sec14">Meet the Pandas </h2>
|
||||
|
||||
<p>
|
||||
<br /><br /><center><p><img src="fig/pandas.jpg" align="bottom" width=600></p></center><br /><br />
|
||||
@@ -879,7 +861,7 @@ most operations are vectorized, achieving thereby a high performance when dealin
|
||||
As we will see below it leads also to a very concice code close to the mathematical operations we may be interested in.
|
||||
For multidimensional arrays, we recommend strongly <a href="http://xarray.pydata.org/en/stable/" target="_blank">xarray</a>. <b>xarray</b> has much of the same flexibility as <b>pandas</b>, but allows for the extension to higher dimensions than two. We will see examples later of the usage of both <b>pandas</b> and <b>xarray</b>.
|
||||
|
||||
<h2 id="___sec17">Reading Data and fitting </h2>
|
||||
<h2 id="___sec15">Reading Data and fitting </h2>
|
||||
|
||||
<p>
|
||||
In order to study various Machine Learning algorithms, we need to
|
||||
@@ -915,7 +897,7 @@ you can easily implement other algorithms like decision trees and random forests
|
||||
But before we really start with nuclear physics data, let's just look at some simpler polynomial fitting cases, such as,
|
||||
(don't be offended) fitting straight lines!
|
||||
|
||||
<h3 id="___sec18">Simple linear regression model using <b>scikit-learn</b> </h3>
|
||||
<h3 id="___sec16">Simple linear regression model using <b>scikit-learn</b> </h3>
|
||||
|
||||
<p>
|
||||
We start with perhaps our simplest possible example, using <b>Scikit-Learn</b> to perform linear regression analysis on a data set produced by us.
|
||||
@@ -1209,7 +1191,7 @@ plt.show()
|
||||
<span style="color: #8B008B; font-weight: bold">print</span> (error(y))
|
||||
</pre></div>
|
||||
|
||||
<h3 id="___sec19">To our real data: nuclear binding energies. Brief reminder on masses and binding energies </h3>
|
||||
<h3 id="___sec17">To our real data: nuclear binding energies. Brief reminder on masses and binding energies </h3>
|
||||
|
||||
<p>
|
||||
Let us now dive into nuclear physics and remind ourselves briefly about some basic features about binding
|
||||
@@ -1287,7 +1269,7 @@ We could also add a so-called pairing term, which is a correction term that
|
||||
arises from the tendency of proton pairs and neutron pairs to
|
||||
occur. An even number of particles is more stable than an odd number.
|
||||
|
||||
<h3 id="___sec20">Organizing our data </h3>
|
||||
<h3 id="___sec18">Organizing our data </h3>
|
||||
|
||||
<p>
|
||||
Let us start with reading and organizing our data.
|
||||
@@ -1473,7 +1455,7 @@ save_fig(<span style="color: #CD5555">"Masses2016"</span>)
|
||||
plt.show()
|
||||
</pre></div>
|
||||
|
||||
<h3 id="___sec21">Seeing the wood for the trees </h3>
|
||||
<h3 id="___sec19">Seeing the wood for the trees </h3>
|
||||
|
||||
<p>
|
||||
As a teaser, let us now see how we can do this with decision trees using <b>scikit-learn</b>. Later we will switch to so-called <b>random forests</b>!
|
||||
@@ -1512,7 +1494,7 @@ plt.show()
|
||||
<span style="color: #8B008B; font-weight: bold">print</span>(np.mean( (Energies-y_1)**<span style="color: #B452CD">2</span>))
|
||||
</pre></div>
|
||||
|
||||
<h3 id="___sec22">And what about using neural networks? </h3>
|
||||
<h3 id="___sec20">And what about using neural networks? </h3>
|
||||
|
||||
The <b>seaborn</b> package allows us to visualize data in an efficient way. Note that we use <b>scikit-learn</b>'s multi-layer perceptron (or feed forward neural network)
|
||||
functionality.
|
||||
@@ -1550,7 +1532,7 @@ ax.set_xlabel(<span style="color: #CD5555">"$\lambda$"</span>)
|
||||
plt.show()
|
||||
</pre></div>
|
||||
|
||||
<h2 id="___sec23">A first summary </h2>
|
||||
<h2 id="___sec21">A first summary </h2>
|
||||
|
||||
<p>
|
||||
The aim behind these introductory words was to present to you various
|
||||
|
||||
@@ -80,27 +80,25 @@ div { text-align: justify; text-justify: inter-word; }
|
||||
None,
|
||||
'___sec8'),
|
||||
('Basic Matrix Features', 2, None, '___sec9'),
|
||||
('Basic Matrix Features', 2, None, '___sec10'),
|
||||
('Basic Matrix Features', 2, None, '___sec11'),
|
||||
('Some famous Matrices', 2, None, '___sec12'),
|
||||
('Basic Matrix Features', 2, None, '___sec13'),
|
||||
('Numpy and arrays', 2, None, '___sec14'),
|
||||
('Matrices in Python', 2, None, '___sec15'),
|
||||
('Meet the Pandas', 2, None, '___sec16'),
|
||||
('Reading Data and fitting', 2, None, '___sec17'),
|
||||
('Some famous Matrices', 3, None, '___sec10'),
|
||||
('More Basic Matrix Features', 3, None, '___sec11'),
|
||||
('Numpy and arrays', 2, None, '___sec12'),
|
||||
('Matrices in Python', 2, None, '___sec13'),
|
||||
('Meet the Pandas', 2, None, '___sec14'),
|
||||
('Reading Data and fitting', 2, None, '___sec15'),
|
||||
('Simple linear regression model using _scikit-learn_',
|
||||
3,
|
||||
None,
|
||||
'___sec18'),
|
||||
'___sec16'),
|
||||
('To our real data: nuclear binding energies. Brief reminder on '
|
||||
'masses and binding energies',
|
||||
3,
|
||||
None,
|
||||
'___sec19'),
|
||||
('Organizing our data', 3, None, '___sec20'),
|
||||
('Seeing the wood for the trees', 3, None, '___sec21'),
|
||||
('And what about using neural networks?', 3, None, '___sec22'),
|
||||
('A first summary', 2, None, '___sec23')]}
|
||||
'___sec17'),
|
||||
('Organizing our data', 3, None, '___sec18'),
|
||||
('Seeing the wood for the trees', 3, None, '___sec19'),
|
||||
('And what about using neural networks?', 3, None, '___sec20'),
|
||||
('A first summary', 2, None, '___sec21')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -142,7 +140,7 @@ MathJax.Hub.Config({
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p>
|
||||
<center><h4>Aug 13, 2019</h4></center> <!-- date -->
|
||||
<center><h4>Aug 14, 2019</h4></center> <!-- date -->
|
||||
<br>
|
||||
|
||||
<h2 id="___sec0">Introduction </h2>
|
||||
@@ -164,7 +162,7 @@ polynomials with random noise added. We will use the Python
|
||||
software package <a href="http://scikit-learn.org/stable/" target="_blank">Scikit-Learn</a> and
|
||||
introduce various machine learning algorithms to make fits of
|
||||
the data and predictions. We move thereafter to more interesting
|
||||
cases such as nuclear binding energies.
|
||||
cases such as data from say experiments (below we will look at experimental nuclear binding energies as an example).
|
||||
These are examples where we can easily set up the data and
|
||||
then use machine learning algorithms included in for example
|
||||
<b>Scikit-Learn</b>.
|
||||
@@ -174,7 +172,7 @@ These examples will serve us the purpose of getting
|
||||
started. Furthermore, they allow us to catch more than two birds with
|
||||
a stone. They will allow us to bring in some programming specific
|
||||
topics and tools as well as showing the power of various Python
|
||||
packages for machine learning and statistical data analysis.
|
||||
libraries for machine learning and statistical data analysis.
|
||||
|
||||
<p>
|
||||
Here, we will mainly focus on two
|
||||
@@ -381,14 +379,14 @@ Here we list several useful Python libraries we strongly recommend (if you use a
|
||||
|
||||
<p>
|
||||
You will also find it convenient to utilize <b>R</b>. We will mainly
|
||||
use Python during lectures and in various projects and exercises.
|
||||
use Python during our lectures and in various projects and exercises.
|
||||
Those of you
|
||||
already familiar with <b>R</b> should feel free to continue using <b>R</b>, keeping
|
||||
however an eye on the parallel Python set ups. Similarly, if you are a
|
||||
Python afecionado, feel free to explore <b>R</b> as well. Jupyter/Ipython
|
||||
notebook allows you to run <b>R</b> codes interactively in your
|
||||
browser. The software library <b>R</b> is tuned to statistically analysis
|
||||
and allows for an easy usage of the tools we will discuss in these
|
||||
browser. The software library <b>R</b> is really tailored for statistical data analysis
|
||||
and allows for an easy usage of the tools and algorithms we will discuss in these
|
||||
lectures.
|
||||
|
||||
<p>
|
||||
@@ -432,7 +430,7 @@ formats, ipython notebooks, latex files, pdf files etc with minimal edits. These
|
||||
<h2 id="___sec8">Numpy examples and Important Matrix and vector handling packages </h2>
|
||||
|
||||
<p>
|
||||
There are several central software packages for linear algebra and eigenvalue problems. Several of the more
|
||||
There are several central software libraries for linear algebra and eigenvalue problems. Several of the more
|
||||
popular ones have been wrapped into ofter software packages like those from the widely used text <b>Numerical Recipes</b>. The original source codes in many of the available packages are often taken from the widely used
|
||||
software package LAPACK, which follows two other popular packages
|
||||
developed in the 1970s, namely EISPACK and LINPACK. We describe them shortly here.
|
||||
@@ -463,13 +461,6 @@ $$
|
||||
0 & 0 & 0 & 1
|
||||
\end{bmatrix}
|
||||
$$
|
||||
</div>
|
||||
|
||||
|
||||
<h2 id="___sec10">Basic Matrix Features </h2>
|
||||
<div class="alert alert-block alert-block alert-text-normal">
|
||||
<b></b>
|
||||
<p>
|
||||
|
||||
<p>
|
||||
The inverse of a matrix is defined by
|
||||
@@ -477,15 +468,6 @@ The inverse of a matrix is defined by
|
||||
$$
|
||||
\mathbf{A}^{-1} \cdot \mathbf{A} = I
|
||||
$$
|
||||
</div>
|
||||
|
||||
|
||||
<h2 id="___sec11">Basic Matrix Features </h2>
|
||||
|
||||
<p>
|
||||
<div class="alert alert-block alert-block alert-text-normal">
|
||||
<b>Matrix Properties Reminder.</b>
|
||||
<p>
|
||||
|
||||
<p>
|
||||
<table border="1">
|
||||
@@ -504,7 +486,7 @@ $$
|
||||
</div>
|
||||
|
||||
|
||||
<h2 id="___sec12">Some famous Matrices </h2>
|
||||
<h3 id="___sec10">Some famous Matrices </h3>
|
||||
|
||||
<ul>
|
||||
<li> Diagonal if \( a_{ij}=0 \) for \( i\ne j \)</li>
|
||||
@@ -518,7 +500,7 @@ $$
|
||||
<li> Banded, block upper triangular, block lower triangular....</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="___sec13">Basic Matrix Features </h2>
|
||||
<h3 id="___sec11">More Basic Matrix Features </h3>
|
||||
|
||||
<p>
|
||||
<div class="alert alert-block alert-block alert-text-normal">
|
||||
@@ -537,7 +519,7 @@ For an \( N\times N \) matrix \( \mathbf{A} \) the following properties are all
|
||||
</div>
|
||||
|
||||
|
||||
<h2 id="___sec14">Numpy and arrays </h2>
|
||||
<h2 id="___sec12">Numpy and arrays </h2>
|
||||
<a href="http://www.numpy.org/" target="_blank">Numpy</a> provides an easy way to handle arrays in Python. The standard way to import this library is as
|
||||
|
||||
<p>
|
||||
@@ -622,7 +604,7 @@ x <span style="color: #666666">=</span> np<span style="color: #666666">.</span>l
|
||||
<span style="color: #008000; font-weight: bold">print</span>(x<span style="color: #666666">.</span>itemsize)
|
||||
</pre></div>
|
||||
|
||||
<h2 id="___sec15">Matrices in Python </h2>
|
||||
<h2 id="___sec13">Matrices in Python </h2>
|
||||
|
||||
<p>
|
||||
Having defined vectors, we are now ready to try out matrices. We can
|
||||
@@ -759,7 +741,7 @@ plt<span style="color: #666666">.</span>plot(x,y,marker<span style="color: #6666
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
|
||||
<h2 id="___sec16">Meet the Pandas </h2>
|
||||
<h2 id="___sec14">Meet the Pandas </h2>
|
||||
|
||||
<p>
|
||||
<br /><br /><center><p><img src="fig/pandas.jpg" align="bottom" width=600></p></center><br /><br />
|
||||
@@ -884,7 +866,7 @@ most operations are vectorized, achieving thereby a high performance when dealin
|
||||
As we will see below it leads also to a very concice code close to the mathematical operations we may be interested in.
|
||||
For multidimensional arrays, we recommend strongly <a href="http://xarray.pydata.org/en/stable/" target="_blank">xarray</a>. <b>xarray</b> has much of the same flexibility as <b>pandas</b>, but allows for the extension to higher dimensions than two. We will see examples later of the usage of both <b>pandas</b> and <b>xarray</b>.
|
||||
|
||||
<h2 id="___sec17">Reading Data and fitting </h2>
|
||||
<h2 id="___sec15">Reading Data and fitting </h2>
|
||||
|
||||
<p>
|
||||
In order to study various Machine Learning algorithms, we need to
|
||||
@@ -920,7 +902,7 @@ you can easily implement other algorithms like decision trees and random forests
|
||||
But before we really start with nuclear physics data, let's just look at some simpler polynomial fitting cases, such as,
|
||||
(don't be offended) fitting straight lines!
|
||||
|
||||
<h3 id="___sec18">Simple linear regression model using <b>scikit-learn</b> </h3>
|
||||
<h3 id="___sec16">Simple linear regression model using <b>scikit-learn</b> </h3>
|
||||
|
||||
<p>
|
||||
We start with perhaps our simplest possible example, using <b>Scikit-Learn</b> to perform linear regression analysis on a data set produced by us.
|
||||
@@ -1214,7 +1196,7 @@ plt<span style="color: #666666">.</span>show()
|
||||
<span style="color: #008000; font-weight: bold">print</span> (error(y))
|
||||
</pre></div>
|
||||
|
||||
<h3 id="___sec19">To our real data: nuclear binding energies. Brief reminder on masses and binding energies </h3>
|
||||
<h3 id="___sec17">To our real data: nuclear binding energies. Brief reminder on masses and binding energies </h3>
|
||||
|
||||
<p>
|
||||
Let us now dive into nuclear physics and remind ourselves briefly about some basic features about binding
|
||||
@@ -1292,7 +1274,7 @@ We could also add a so-called pairing term, which is a correction term that
|
||||
arises from the tendency of proton pairs and neutron pairs to
|
||||
occur. An even number of particles is more stable than an odd number.
|
||||
|
||||
<h3 id="___sec20">Organizing our data </h3>
|
||||
<h3 id="___sec18">Organizing our data </h3>
|
||||
|
||||
<p>
|
||||
Let us start with reading and organizing our data.
|
||||
@@ -1478,7 +1460,7 @@ save_fig(<span style="color: #BA2121">"Masses2016"</span>)
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
|
||||
<h3 id="___sec21">Seeing the wood for the trees </h3>
|
||||
<h3 id="___sec19">Seeing the wood for the trees </h3>
|
||||
|
||||
<p>
|
||||
As a teaser, let us now see how we can do this with decision trees using <b>scikit-learn</b>. Later we will switch to so-called <b>random forests</b>!
|
||||
@@ -1517,7 +1499,7 @@ plt<span style="color: #666666">.</span>show()
|
||||
<span style="color: #008000; font-weight: bold">print</span>(np<span style="color: #666666">.</span>mean( (Energies<span style="color: #666666">-</span>y_1)<span style="color: #666666">**2</span>))
|
||||
</pre></div>
|
||||
|
||||
<h3 id="___sec22">And what about using neural networks? </h3>
|
||||
<h3 id="___sec20">And what about using neural networks? </h3>
|
||||
|
||||
The <b>seaborn</b> package allows us to visualize data in an efficient way. Note that we use <b>scikit-learn</b>'s multi-layer perceptron (or feed forward neural network)
|
||||
functionality.
|
||||
@@ -1555,7 +1537,7 @@ ax<span style="color: #666666">.</span>set_xlabel(<span style="color: #BA2121">&
|
||||
plt<span style="color: #666666">.</span>show()
|
||||
</pre></div>
|
||||
|
||||
<h2 id="___sec23">A first summary </h2>
|
||||
<h2 id="___sec21">A first summary </h2>
|
||||
|
||||
<p>
|
||||
The aim behind these introductory words was to present to you various
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"<!-- Author: --> \n",
|
||||
"**Morten Hjorth-Jensen**, Department of Physics, University of Oslo and Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University\n",
|
||||
"\n",
|
||||
"Date: **Aug 13, 2019**\n",
|
||||
"Date: **Aug 14, 2019**\n",
|
||||
"\n",
|
||||
"Copyright 1999-2019, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license\n",
|
||||
"\n",
|
||||
@@ -36,7 +36,7 @@
|
||||
"software package [Scikit-Learn](http://scikit-learn.org/stable/) and\n",
|
||||
"introduce various machine learning algorithms to make fits of\n",
|
||||
"the data and predictions. We move thereafter to more interesting\n",
|
||||
"cases such as nuclear binding energies.\n",
|
||||
"cases such as data from say experiments (below we will look at experimental nuclear binding energies as an example).\n",
|
||||
"These are examples where we can easily set up the data and\n",
|
||||
"then use machine learning algorithms included in for example\n",
|
||||
"**Scikit-Learn**. \n",
|
||||
@@ -45,7 +45,7 @@
|
||||
"started. Furthermore, they allow us to catch more than two birds with\n",
|
||||
"a stone. They will allow us to bring in some programming specific\n",
|
||||
"topics and tools as well as showing the power of various Python \n",
|
||||
"packages for machine learning and statistical data analysis. \n",
|
||||
"libraries for machine learning and statistical data analysis. \n",
|
||||
"\n",
|
||||
"Here, we will mainly focus on two\n",
|
||||
"specific Python packages for Machine Learning, Scikit-Learn and\n",
|
||||
@@ -249,14 +249,14 @@
|
||||
"## Installing R, C++, cython or Julia\n",
|
||||
"\n",
|
||||
"You will also find it convenient to utilize **R**. We will mainly\n",
|
||||
"use Python during lectures and in various projects and exercises.\n",
|
||||
"use Python during our lectures and in various projects and exercises.\n",
|
||||
"Those of you\n",
|
||||
"already familiar with **R** should feel free to continue using **R**, keeping\n",
|
||||
"however an eye on the parallel Python set ups. Similarly, if you are a\n",
|
||||
"Python afecionado, feel free to explore **R** as well. Jupyter/Ipython\n",
|
||||
"notebook allows you to run **R** codes interactively in your\n",
|
||||
"browser. The software library **R** is tuned to statistically analysis\n",
|
||||
"and allows for an easy usage of the tools we will discuss in these\n",
|
||||
"browser. The software library **R** is really tailored for statistical data analysis\n",
|
||||
"and allows for an easy usage of the tools and algorithms we will discuss in these\n",
|
||||
"lectures.\n",
|
||||
"\n",
|
||||
"To install **R** with Jupyter notebook \n",
|
||||
@@ -307,7 +307,7 @@
|
||||
"\n",
|
||||
"## Numpy examples and Important Matrix and vector handling packages\n",
|
||||
"\n",
|
||||
"There are several central software packages for linear algebra and eigenvalue problems. Several of the more\n",
|
||||
"There are several central software libraries for linear algebra and eigenvalue problems. Several of the more\n",
|
||||
"popular ones have been wrapped into ofter software packages like those from the widely used text **Numerical Recipes**. The original source codes in many of the available packages are often taken from the widely used\n",
|
||||
"software package LAPACK, which follows two other popular packages\n",
|
||||
"developed in the 1970s, namely EISPACK and LINPACK. We describe them shortly here.\n",
|
||||
@@ -347,8 +347,6 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Basic Matrix Features\n",
|
||||
"\n",
|
||||
"The inverse of a matrix is defined by"
|
||||
]
|
||||
},
|
||||
@@ -365,11 +363,6 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Basic Matrix Features\n",
|
||||
"\n",
|
||||
"**Matrix Properties Reminder.**\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"<table border=\"1\">\n",
|
||||
"<thead>\n",
|
||||
"<tr><th align=\"center\"> Relations </th> <th align=\"center\"> Name </th> <th align=\"center\"> matrix elements </th> </tr>\n",
|
||||
@@ -386,7 +379,7 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"## Some famous Matrices\n",
|
||||
"### Some famous Matrices\n",
|
||||
"\n",
|
||||
" * Diagonal if $a_{ij}=0$ for $i\\ne j$\n",
|
||||
"\n",
|
||||
@@ -406,7 +399,7 @@
|
||||
"\n",
|
||||
" * Banded, block upper triangular, block lower triangular....\n",
|
||||
"\n",
|
||||
"## Basic Matrix Features\n",
|
||||
"### More Basic Matrix Features\n",
|
||||
"\n",
|
||||
"**Some Equivalent Statements.**\n",
|
||||
"\n",
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -22,7 +22,7 @@ polynomials with random noise added. We will use the Python
|
||||
software package "Scikit-Learn":"http://scikit-learn.org/stable/" and
|
||||
introduce various machine learning algorithms to make fits of
|
||||
the data and predictions. We move thereafter to more interesting
|
||||
cases such as nuclear binding energies.
|
||||
cases such as data from say experiments (below we will look at experimental nuclear binding energies as an example).
|
||||
These are examples where we can easily set up the data and
|
||||
then use machine learning algorithms included in for example
|
||||
_Scikit-Learn_.
|
||||
@@ -31,7 +31,7 @@ These examples will serve us the purpose of getting
|
||||
started. Furthermore, they allow us to catch more than two birds with
|
||||
a stone. They will allow us to bring in some programming specific
|
||||
topics and tools as well as showing the power of various Python
|
||||
packages for machine learning and statistical data analysis.
|
||||
libraries for machine learning and statistical data analysis.
|
||||
|
||||
Here, we will mainly focus on two
|
||||
specific Python packages for Machine Learning, Scikit-Learn and
|
||||
@@ -226,14 +226,14 @@ Here we list several useful Python libraries we strongly recommend (if you use a
|
||||
===== Installing R, C++, cython or Julia =====
|
||||
|
||||
You will also find it convenient to utilize _R_. We will mainly
|
||||
use Python during lectures and in various projects and exercises.
|
||||
use Python during our lectures and in various projects and exercises.
|
||||
Those of you
|
||||
already familiar with _R_ should feel free to continue using _R_, keeping
|
||||
however an eye on the parallel Python set ups. Similarly, if you are a
|
||||
Python afecionado, feel free to explore _R_ as well. Jupyter/Ipython
|
||||
notebook allows you to run _R_ codes interactively in your
|
||||
browser. The software library _R_ is tuned to statistically analysis
|
||||
and allows for an easy usage of the tools we will discuss in these
|
||||
browser. The software library _R_ is really tailored for statistical data analysis
|
||||
and allows for an easy usage of the tools and algorithms we will discuss in these
|
||||
lectures.
|
||||
|
||||
To install _R_ with Jupyter notebook
|
||||
@@ -276,7 +276,7 @@ formats, ipython notebooks, latex files, pdf files etc with minimal edits. These
|
||||
|
||||
===== Numpy examples and Important Matrix and vector handling packages =====
|
||||
|
||||
There are several central software packages for linear algebra and eigenvalue problems. Several of the more
|
||||
There are several central software libraries for linear algebra and eigenvalue problems. Several of the more
|
||||
popular ones have been wrapped into ofter software packages like those from the widely used text _Numerical Recipes_. The original source codes in many of the available packages are often taken from the widely used
|
||||
software package LAPACK, which follows two other popular packages
|
||||
developed in the 1970s, namely EISPACK and LINPACK. We describe them shortly here.
|
||||
@@ -305,10 +305,8 @@ developed in the 1970s, namely EISPACK and LINPACK. We describe them shortly he
|
||||
\end{bmatrix}
|
||||
\]
|
||||
!et
|
||||
!eblock
|
||||
|
||||
===== Basic Matrix Features =====
|
||||
!bblock
|
||||
|
||||
|
||||
The inverse of a matrix is defined by
|
||||
|
||||
@@ -317,13 +315,8 @@ The inverse of a matrix is defined by
|
||||
\mathbf{A}^{-1} \cdot \mathbf{A} = I
|
||||
\]
|
||||
!et
|
||||
!eblock
|
||||
|
||||
|
||||
===== Basic Matrix Features =====
|
||||
|
||||
!bblock Matrix Properties Reminder
|
||||
|
||||
|----------------------------------------------------------------------|
|
||||
| Relations | Name | matrix elements |
|
||||
|----------------------------------------------------------------------|
|
||||
@@ -337,7 +330,7 @@ The inverse of a matrix is defined by
|
||||
!eblock
|
||||
|
||||
|
||||
===== Some famous Matrices =====
|
||||
=== Some famous Matrices ===
|
||||
|
||||
* Diagonal if $a_{ij}=0$ for $i\ne j$
|
||||
* Upper triangular if $a_{ij}=0$ for $i > j$
|
||||
@@ -350,7 +343,7 @@ The inverse of a matrix is defined by
|
||||
* Banded, block upper triangular, block lower triangular....
|
||||
|
||||
|
||||
===== Basic Matrix Features =====
|
||||
=== More Basic Matrix Features ===
|
||||
|
||||
!bblock Some Equivalent Statements
|
||||
For an $N\times N$ matrix $\mathbf{A}$ the following properties are all equivalent
|
||||
|
||||
Reference in New Issue
Block a user