update of lecture notes
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>15. Getting started, our first data and Machine Learning encounters — Applied Machine Learning and Data Analysis</title>
|
||||
<title>2. Getting started, our first data and Machine Learning encounters — Applied Machine Learning and Data Analysis</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css" integrity="sha384-KA6wR/X5RY4zFAHpv/CnoG2UW1uogYfdnP67Uv7eULvTveboZJg0qUpmJZb5VqzN" crossorigin="anonymous">
|
||||
<link href="_static/css/index.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="_static/sphinx-book-theme.css" type="text/css" />
|
||||
@@ -38,7 +38,7 @@
|
||||
<script async="async" src="_static/sphinx-thebe.js"></script>
|
||||
<link rel="index" title="Index" href="genindex.html" />
|
||||
<link rel="search" title="Search" href="search.html" />
|
||||
<link rel="next" title="16. Linear Regression and more Advanced Regression Analysis" href="chapter4.html" />
|
||||
<link rel="next" title="3. Linear Regression and more Advanced Regression Analysis" href="chapter4.html" />
|
||||
<link rel="prev" title="1. Elements of Probability Theory and Statistical Data Analysis" href="chapter2.html" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
@@ -90,99 +90,34 @@
|
||||
1. Elements of Probability Theory and Statistical Data Analysis
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter2.html#random-numbers">
|
||||
2. Random Numbers
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter2.html#random-numbers-better-name-pseudo-random-numbers">
|
||||
3. Random Numbers, better name: pseudo random numbers
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter2.html#random-number-generator-rng">
|
||||
4. Random number generator RNG
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter2.html#random-number-generator-rng-and-periodic-outputs">
|
||||
5. Random number generator RNG and periodic outputs
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter2.html#random-number-generator-rng-and-its-period">
|
||||
6. Random number generator RNG and its period
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter2.html#random-number-generator-rng-other-examples">
|
||||
7. Random number generator RNG, other examples
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter2.html#id9">
|
||||
8. Random number generator RNG, other examples
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter2.html#random-number-generator-rng-ran0">
|
||||
9. Random number generator RNG, RAN0
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter2.html#id10">
|
||||
10. Random number generator RNG, RAN0
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter2.html#id11">
|
||||
11. Random number generator RNG, RAN0
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter2.html#id12">
|
||||
12. Random number generator RNG, RAN0
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter2.html#random-number-generator-rng-ran0-code">
|
||||
13. Random number generator RNG, RAN0 code
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter2.html#which-rng-should-i-use">
|
||||
14. Which RNG should I use?
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1 current active">
|
||||
<a class="current reference internal" href="#">
|
||||
15. Getting started, our first data and Machine Learning encounters
|
||||
2. Getting started, our first data and Machine Learning encounters
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter4.html">
|
||||
16. Linear Regression and more Advanced Regression Analysis
|
||||
3. Linear Regression and more Advanced Regression Analysis
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter5.html">
|
||||
17. Logistic Regression
|
||||
4. Logistic Regression
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter6.html">
|
||||
18. Neural networks, from the simple perceptron to deep learning
|
||||
5. Neural networks, from the simple perceptron to deep learning
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter7.html">
|
||||
19. Support Vector Machines, overarching aims
|
||||
6. Support Vector Machines, overarching aims
|
||||
</a>
|
||||
</li>
|
||||
<li class="toctree-l1">
|
||||
<a class="reference internal" href="chapter8.html">
|
||||
20. Dimensionality Reduction
|
||||
7. Dimensionality Reduction
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -257,89 +192,89 @@
|
||||
<ul class="nav section-nav flex-column">
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#introduction">
|
||||
15.1. Introduction
|
||||
2.1. Introduction
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#what-is-machine-learning">
|
||||
15.2. What is Machine Learning?
|
||||
2.2. What is Machine Learning?
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#types-of-machine-learning">
|
||||
15.3. Types of Machine Learning
|
||||
2.3. Types of Machine Learning
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#software-and-needed-installations">
|
||||
15.4. Software and needed installations
|
||||
2.4. Software and needed installations
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#python-installers">
|
||||
15.5. Python installers
|
||||
2.5. Python installers
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#useful-python-libraries">
|
||||
15.6. Useful Python libraries
|
||||
2.6. Useful Python libraries
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#installing-r-c-cython-or-julia">
|
||||
15.7. Installing R, C++, cython or Julia
|
||||
2.7. Installing R, C++, cython or Julia
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#installing-r-c-cython-numba-etc">
|
||||
15.8. Installing R, C++, cython, Numba etc
|
||||
2.8. Installing R, C++, cython, Numba etc
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#numpy-examples-and-important-matrix-and-vector-handling-packages">
|
||||
15.9. Numpy examples and Important Matrix and vector handling packages
|
||||
2.9. Numpy examples and Important Matrix and vector handling packages
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#basic-matrix-features">
|
||||
15.10. Basic Matrix Features
|
||||
2.10. Basic Matrix Features
|
||||
</a>
|
||||
<ul class="nav section-nav flex-column">
|
||||
<li class="toc-h3 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#some-famous-matrices">
|
||||
15.10.1. Some famous Matrices
|
||||
2.10.1. Some famous Matrices
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h3 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#more-basic-matrix-features">
|
||||
15.10.2. More Basic Matrix Features
|
||||
2.10.2. More Basic Matrix Features
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#numpy-and-arrays">
|
||||
15.11. Numpy and arrays
|
||||
2.11. Numpy and arrays
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#matrices-in-python">
|
||||
15.12. Matrices in Python
|
||||
2.12. Matrices in Python
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#meet-the-pandas">
|
||||
15.13. Meet the Pandas
|
||||
2.13. Meet the Pandas
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#reading-data-and-fitting">
|
||||
15.14. Reading Data and fitting
|
||||
2.14. Reading Data and fitting
|
||||
</a>
|
||||
<ul class="nav section-nav flex-column">
|
||||
<li class="toc-h3 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#simple-linear-regression-model-using-scikit-learn">
|
||||
15.14.1. Simple linear regression model using
|
||||
2.14.1. Simple linear regression model using
|
||||
<strong>
|
||||
scikit-learn
|
||||
</strong>
|
||||
@@ -347,29 +282,29 @@
|
||||
</li>
|
||||
<li class="toc-h3 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#to-our-real-data-nuclear-binding-energies-brief-reminder-on-masses-and-binding-energies">
|
||||
15.14.2. To our real data: nuclear binding energies. Brief reminder on masses and binding energies
|
||||
2.14.2. To our real data: nuclear binding energies. Brief reminder on masses and binding energies
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h3 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#organizing-our-data">
|
||||
15.14.3. Organizing our data
|
||||
2.14.3. Organizing our data
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h3 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#seeing-the-wood-for-the-trees">
|
||||
15.14.4. Seeing the wood for the trees
|
||||
2.14.4. Seeing the wood for the trees
|
||||
</a>
|
||||
</li>
|
||||
<li class="toc-h3 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#and-what-about-using-neural-networks">
|
||||
15.14.5. And what about using neural networks?
|
||||
2.14.5. And what about using neural networks?
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toc-h2 nav-item toc-entry">
|
||||
<a class="reference internal nav-link" href="#a-first-summary">
|
||||
15.15. A first summary
|
||||
2.15. A first summary
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -383,9 +318,9 @@
|
||||
<div>
|
||||
|
||||
<div class="section" id="getting-started-our-first-data-and-machine-learning-encounters">
|
||||
<h1><span class="section-number">15. </span>Getting started, our first data and Machine Learning encounters<a class="headerlink" href="#getting-started-our-first-data-and-machine-learning-encounters" title="Permalink to this headline">¶</a></h1>
|
||||
<h1><span class="section-number">2. </span>Getting started, our first data and Machine Learning encounters<a class="headerlink" href="#getting-started-our-first-data-and-machine-learning-encounters" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="section" id="introduction">
|
||||
<h2><span class="section-number">15.1. </span>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
|
||||
<h2><span class="section-number">2.1. </span>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Our emphasis throughout this series of lectures<br />
|
||||
is on understanding the mathematical aspects of
|
||||
different algorithms used in the fields of data analysis and machine learning.</p>
|
||||
@@ -417,7 +352,7 @@ well as allowing you to set up models and produce your own data and
|
||||
get started with programming.</p>
|
||||
</div>
|
||||
<div class="section" id="what-is-machine-learning">
|
||||
<h2><span class="section-number">15.2. </span>What is Machine Learning?<a class="headerlink" href="#what-is-machine-learning" title="Permalink to this headline">¶</a></h2>
|
||||
<h2><span class="section-number">2.2. </span>What is Machine Learning?<a class="headerlink" href="#what-is-machine-learning" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Statistics, data science and machine learning form important fields of
|
||||
research in modern science. They describe how to learn and make
|
||||
predictions from data, as well as allowing us to extract important
|
||||
@@ -478,7 +413,7 @@ Carlo methods are central elements in a proper understanding of many
|
||||
of algorithms and methods we will discuss.</p>
|
||||
</div>
|
||||
<div class="section" id="types-of-machine-learning">
|
||||
<h2><span class="section-number">15.3. </span>Types of Machine Learning<a class="headerlink" href="#types-of-machine-learning" title="Permalink to this headline">¶</a></h2>
|
||||
<h2><span class="section-number">2.3. </span>Types of Machine Learning<a class="headerlink" href="#types-of-machine-learning" title="Permalink to this headline">¶</a></h2>
|
||||
<p>The approaches to machine learning are many, but are often split into
|
||||
two main categories. In <em>supervised learning</em> we know the answer to a
|
||||
problem, and let the computer deduce the logic behind it. On the other
|
||||
@@ -506,7 +441,7 @@ is in reproducing the data it is supposed to train.<br />
|
||||
At the heart of basically all ML algorithms there are so-called minimization algorithms, often we end up with various variants of <strong>gradient</strong> methods.</p>
|
||||
</div>
|
||||
<div class="section" id="software-and-needed-installations">
|
||||
<h2><span class="section-number">15.4. </span>Software and needed installations<a class="headerlink" href="#software-and-needed-installations" title="Permalink to this headline">¶</a></h2>
|
||||
<h2><span class="section-number">2.4. </span>Software and needed installations<a class="headerlink" href="#software-and-needed-installations" title="Permalink to this headline">¶</a></h2>
|
||||
<p>We will make extensive use of Python as programming language and its
|
||||
myriad of available libraries. You will find
|
||||
Jupyter notebooks invaluable in your work. You can run <strong>R</strong>
|
||||
@@ -535,7 +470,7 @@ you can use <strong>pip</strong> as well and simply install Python as</p>
|
||||
<p>etc etc.</p>
|
||||
</div>
|
||||
<div class="section" id="python-installers">
|
||||
<h2><span class="section-number">15.5. </span>Python installers<a class="headerlink" href="#python-installers" title="Permalink to this headline">¶</a></h2>
|
||||
<h2><span class="section-number">2.5. </span>Python installers<a class="headerlink" href="#python-installers" title="Permalink to this headline">¶</a></h2>
|
||||
<p>If you don’t want to perform these operations separately and venture
|
||||
into the hassle of exploring how to set up dependencies and paths, we
|
||||
recommend two widely used distrubutions which set up all relevant
|
||||
@@ -559,7 +494,7 @@ license.</p>
|
||||
no setup and runs entirely in the cloud. Try it out!</p>
|
||||
</div>
|
||||
<div class="section" id="useful-python-libraries">
|
||||
<h2><span class="section-number">15.6. </span>Useful Python libraries<a class="headerlink" href="#useful-python-libraries" title="Permalink to this headline">¶</a></h2>
|
||||
<h2><span class="section-number">2.6. </span>Useful Python libraries<a class="headerlink" href="#useful-python-libraries" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Here we list several useful Python libraries we strongly recommend (if you use anaconda many of these are already there)</p>
|
||||
<ul class="simple">
|
||||
<li><p><a class="reference external" href="https://www.numpy.org/">NumPy</a> is a highly popular library for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays</p></li>
|
||||
@@ -576,7 +511,7 @@ no setup and runs entirely in the cloud. Try it out!</p>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="installing-r-c-cython-or-julia">
|
||||
<h2><span class="section-number">15.7. </span>Installing R, C++, cython or Julia<a class="headerlink" href="#installing-r-c-cython-or-julia" title="Permalink to this headline">¶</a></h2>
|
||||
<h2><span class="section-number">2.7. </span>Installing R, C++, cython or Julia<a class="headerlink" href="#installing-r-c-cython-or-julia" title="Permalink to this headline">¶</a></h2>
|
||||
<p>You will also find it convenient to utilize <strong>R</strong>. We will mainly
|
||||
use Python during our lectures and in various projects and exercises.
|
||||
Those of you
|
||||
@@ -591,7 +526,7 @@ lectures.</p>
|
||||
<a class="reference external" href="https://mpacer.org/maths/r-kernel-for-ipython-notebook">follow the link here</a></p>
|
||||
</div>
|
||||
<div class="section" id="installing-r-c-cython-numba-etc">
|
||||
<h2><span class="section-number">15.8. </span>Installing R, C++, cython, Numba etc<a class="headerlink" href="#installing-r-c-cython-numba-etc" title="Permalink to this headline">¶</a></h2>
|
||||
<h2><span class="section-number">2.8. </span>Installing R, C++, cython, Numba etc<a class="headerlink" href="#installing-r-c-cython-numba-etc" title="Permalink to this headline">¶</a></h2>
|
||||
<p>For the C++ aficionados, Jupyter/IPython notebook allows you also to
|
||||
install C++ and run codes written in this language interactively in
|
||||
the browser. Since we will emphasize writing many of the algorithms
|
||||
@@ -616,7 +551,7 @@ further processing. For example, convert to latex as</p>
|
||||
formats, ipython notebooks, latex files, pdf files etc with minimal edits. These lectures were generated using <strong>doconce</strong>.</p>
|
||||
</div>
|
||||
<div class="section" id="numpy-examples-and-important-matrix-and-vector-handling-packages">
|
||||
<h2><span class="section-number">15.9. </span>Numpy examples and Important Matrix and vector handling packages<a class="headerlink" href="#numpy-examples-and-important-matrix-and-vector-handling-packages" title="Permalink to this headline">¶</a></h2>
|
||||
<h2><span class="section-number">2.9. </span>Numpy examples and Important Matrix and vector handling packages<a class="headerlink" href="#numpy-examples-and-important-matrix-and-vector-handling-packages" title="Permalink to this headline">¶</a></h2>
|
||||
<p>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 <strong>Numerical Recipes</strong>. 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
|
||||
@@ -628,7 +563,7 @@ developed in the 1970s, namely EISPACK and LINPACK. We describe them shortly he
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="basic-matrix-features">
|
||||
<h2><span class="section-number">15.10. </span>Basic Matrix Features<a class="headerlink" href="#basic-matrix-features" title="Permalink to this headline">¶</a></h2>
|
||||
<h2><span class="section-number">2.10. </span>Basic Matrix Features<a class="headerlink" href="#basic-matrix-features" title="Permalink to this headline">¶</a></h2>
|
||||
<p><strong>Matrix properties reminder.</strong></p>
|
||||
<div class="math notranslate nohighlight">
|
||||
\[\begin{split}
|
||||
@@ -663,7 +598,7 @@ developed in the 1970s, namely EISPACK and LINPACK. We describe them shortly he
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="section" id="some-famous-matrices">
|
||||
<h3><span class="section-number">15.10.1. </span>Some famous Matrices<a class="headerlink" href="#some-famous-matrices" title="Permalink to this headline">¶</a></h3>
|
||||
<h3><span class="section-number">2.10.1. </span>Some famous Matrices<a class="headerlink" href="#some-famous-matrices" title="Permalink to this headline">¶</a></h3>
|
||||
<ul class="simple">
|
||||
<li><p>Diagonal if <span class="math notranslate nohighlight">\(a_{ij}=0\)</span> for <span class="math notranslate nohighlight">\(i\ne j\)</span></p></li>
|
||||
<li><p>Upper triangular if <span class="math notranslate nohighlight">\(a_{ij}=0\)</span> for <span class="math notranslate nohighlight">\(i > j\)</span></p></li>
|
||||
@@ -677,7 +612,7 @@ developed in the 1970s, namely EISPACK and LINPACK. We describe them shortly he
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="more-basic-matrix-features">
|
||||
<h3><span class="section-number">15.10.2. </span>More Basic Matrix Features<a class="headerlink" href="#more-basic-matrix-features" title="Permalink to this headline">¶</a></h3>
|
||||
<h3><span class="section-number">2.10.2. </span>More Basic Matrix Features<a class="headerlink" href="#more-basic-matrix-features" title="Permalink to this headline">¶</a></h3>
|
||||
<p><strong>Some Equivalent Statements.</strong></p>
|
||||
<p>For an <span class="math notranslate nohighlight">\(N\times N\)</span> matrix <span class="math notranslate nohighlight">\(\mathbf{A}\)</span> the following properties are all equivalent</p>
|
||||
<ul class="simple">
|
||||
@@ -691,7 +626,7 @@ developed in the 1970s, namely EISPACK and LINPACK. We describe them shortly he
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="numpy-and-arrays">
|
||||
<h2><span class="section-number">15.11. </span>Numpy and arrays<a class="headerlink" href="#numpy-and-arrays" title="Permalink to this headline">¶</a></h2>
|
||||
<h2><span class="section-number">2.11. </span>Numpy and arrays<a class="headerlink" href="#numpy-and-arrays" title="Permalink to this headline">¶</a></h2>
|
||||
<p><a class="reference external" href="http://www.numpy.org/">Numpy</a> provides an easy way to handle arrays in Python. The standard way to import this library is as</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
@@ -818,7 +753,7 @@ The attentive reader will also notice that the output is <span class="math notra
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="matrices-in-python">
|
||||
<h2><span class="section-number">15.12. </span>Matrices in Python<a class="headerlink" href="#matrices-in-python" title="Permalink to this headline">¶</a></h2>
|
||||
<h2><span class="section-number">2.12. </span>Matrices in Python<a class="headerlink" href="#matrices-in-python" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Having defined vectors, we are now ready to try out matrices. We can
|
||||
define a <span class="math notranslate nohighlight">\(3 \times 3 \)</span> real matrix <span class="math notranslate nohighlight">\(\hat{A}\)</span> as (recall that we user
|
||||
lowercase letters for vectors and uppercase letters for matrices)</p>
|
||||
@@ -963,7 +898,7 @@ covariance matrix through the <strong>np.linalg.eig()</strong> function.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="meet-the-pandas">
|
||||
<h2><span class="section-number">15.13. </span>Meet the Pandas<a class="headerlink" href="#meet-the-pandas" title="Permalink to this headline">¶</a></h2>
|
||||
<h2><span class="section-number">2.13. </span>Meet the Pandas<a class="headerlink" href="#meet-the-pandas" title="Permalink to this headline">¶</a></h2>
|
||||
<!-- dom:FIGURE: [fig/pandas.jpg, width=600 frac=0.8] -->
|
||||
<!-- begin figure -->
|
||||
<p></p>
|
||||
@@ -1091,7 +1026,7 @@ As we will see below it leads also to a very concice code close to the mathemati
|
||||
For multidimensional arrays, we recommend strongly <a class="reference external" href="http://xarray.pydata.org/en/stable/">xarray</a>. <strong>xarray</strong> has much of the same flexibility as <strong>pandas</strong>, but allows for the extension to higher dimensions than two. We will see examples later of the usage of both <strong>pandas</strong> and <strong>xarray</strong>.</p>
|
||||
</div>
|
||||
<div class="section" id="reading-data-and-fitting">
|
||||
<h2><span class="section-number">15.14. </span>Reading Data and fitting<a class="headerlink" href="#reading-data-and-fitting" title="Permalink to this headline">¶</a></h2>
|
||||
<h2><span class="section-number">2.14. </span>Reading Data and fitting<a class="headerlink" href="#reading-data-and-fitting" title="Permalink to this headline">¶</a></h2>
|
||||
<p>In order to study various Machine Learning algorithms, we need to
|
||||
access data. Acccessing data is an essential step in all machine
|
||||
learning algorithms. In particular, setting up the so-called <strong>design
|
||||
@@ -1117,7 +1052,7 @@ you can easily implement other algorithms like decision trees and random forests
|
||||
<p>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!</p>
|
||||
<div class="section" id="simple-linear-regression-model-using-scikit-learn">
|
||||
<h3><span class="section-number">15.14.1. </span>Simple linear regression model using <strong>scikit-learn</strong><a class="headerlink" href="#simple-linear-regression-model-using-scikit-learn" title="Permalink to this headline">¶</a></h3>
|
||||
<h3><span class="section-number">2.14.1. </span>Simple linear regression model using <strong>scikit-learn</strong><a class="headerlink" href="#simple-linear-regression-model-using-scikit-learn" title="Permalink to this headline">¶</a></h3>
|
||||
<p>We start with perhaps our simplest possible example, using <strong>Scikit-Learn</strong> to perform linear regression analysis on a data set produced by us.</p>
|
||||
<p>What follows is a simple Python code where we have defined a function
|
||||
<span class="math notranslate nohighlight">\(y\)</span> in terms of the variable <span class="math notranslate nohighlight">\(x\)</span>. Both are defined as vectors with <span class="math notranslate nohighlight">\(100\)</span> entries.
|
||||
@@ -1400,7 +1335,7 @@ a linear <span class="math notranslate nohighlight">\(x\)</span>-dependence we s
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="to-our-real-data-nuclear-binding-energies-brief-reminder-on-masses-and-binding-energies">
|
||||
<h3><span class="section-number">15.14.2. </span>To our real data: nuclear binding energies. Brief reminder on masses and binding energies<a class="headerlink" href="#to-our-real-data-nuclear-binding-energies-brief-reminder-on-masses-and-binding-energies" title="Permalink to this headline">¶</a></h3>
|
||||
<h3><span class="section-number">2.14.2. </span>To our real data: nuclear binding energies. Brief reminder on masses and binding energies<a class="headerlink" href="#to-our-real-data-nuclear-binding-energies-brief-reminder-on-masses-and-binding-energies" title="Permalink to this headline">¶</a></h3>
|
||||
<p>Let us now dive into nuclear physics and remind ourselves briefly about some basic features about binding
|
||||
energies. A basic quantity which can be measured for the ground
|
||||
states of nuclei is the atomic mass <span class="math notranslate nohighlight">\(M(N, Z)\)</span> of the neutral atom with
|
||||
@@ -1463,7 +1398,7 @@ arises from the tendency of proton pairs and neutron pairs to
|
||||
occur. An even number of particles is more stable than an odd number.</p>
|
||||
</div>
|
||||
<div class="section" id="organizing-our-data">
|
||||
<h3><span class="section-number">15.14.3. </span>Organizing our data<a class="headerlink" href="#organizing-our-data" title="Permalink to this headline">¶</a></h3>
|
||||
<h3><span class="section-number">2.14.3. </span>Organizing our data<a class="headerlink" href="#organizing-our-data" title="Permalink to this headline">¶</a></h3>
|
||||
<p>Let us start with reading and organizing our data.
|
||||
We start with the compilation of masses and binding energies from 2016.
|
||||
After having downloaded this file to our own computer, we are now ready to read the file and start structuring our data.</p>
|
||||
@@ -1650,7 +1585,7 @@ Now we can print measures of how our fit is doing, the coefficients from the fit
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="seeing-the-wood-for-the-trees">
|
||||
<h3><span class="section-number">15.14.4. </span>Seeing the wood for the trees<a class="headerlink" href="#seeing-the-wood-for-the-trees" title="Permalink to this headline">¶</a></h3>
|
||||
<h3><span class="section-number">2.14.4. </span>Seeing the wood for the trees<a class="headerlink" href="#seeing-the-wood-for-the-trees" title="Permalink to this headline">¶</a></h3>
|
||||
<p>As a teaser, let us now see how we can do this with decision trees using <strong>scikit-learn</strong>. Later we will switch to so-called <strong>random forests</strong>!</p>
|
||||
<div class="cell docutils container">
|
||||
<div class="cell_input docutils container">
|
||||
@@ -1689,7 +1624,7 @@ Now we can print measures of how our fit is doing, the coefficients from the fit
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="and-what-about-using-neural-networks">
|
||||
<h3><span class="section-number">15.14.5. </span>And what about using neural networks?<a class="headerlink" href="#and-what-about-using-neural-networks" title="Permalink to this headline">¶</a></h3>
|
||||
<h3><span class="section-number">2.14.5. </span>And what about using neural networks?<a class="headerlink" href="#and-what-about-using-neural-networks" title="Permalink to this headline">¶</a></h3>
|
||||
<p>The <strong>seaborn</strong> package allows us to visualize data in an efficient way. Note that we use <strong>scikit-learn</strong>’s multi-layer perceptron (or feed forward neural network)
|
||||
functionality.</p>
|
||||
<div class="cell docutils container">
|
||||
@@ -1730,7 +1665,7 @@ functionality.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="a-first-summary">
|
||||
<h2><span class="section-number">15.15. </span>A first summary<a class="headerlink" href="#a-first-summary" title="Permalink to this headline">¶</a></h2>
|
||||
<h2><span class="section-number">2.15. </span>A first summary<a class="headerlink" href="#a-first-summary" title="Permalink to this headline">¶</a></h2>
|
||||
<p>The aim behind these introductory words was to present to you various
|
||||
Python libraries and their functionalities, in particular libraries like
|
||||
<strong>numpy</strong>, <strong>pandas</strong>, <strong>xarray</strong> and <strong>matplotlib</strong> and other that make our life much easier
|
||||
@@ -1771,7 +1706,7 @@ Now it is time to dive more into the details of various methods. We will start w
|
||||
<div class='prev-next-bottom'>
|
||||
|
||||
<a class='left-prev' id="prev-link" href="chapter2.html" title="previous page"><span class="section-number">1. </span>Elements of Probability Theory and Statistical Data Analysis</a>
|
||||
<a class='right-next' id="next-link" href="chapter4.html" title="next page"><span class="section-number">16. </span>Linear Regression and more Advanced Regression Analysis</a>
|
||||
<a class='right-next' id="next-link" href="chapter4.html" title="next page"><span class="section-number">3. </span>Linear Regression and more Advanced Regression Analysis</a>
|
||||
|
||||
</div>
|
||||
<footer class="footer mt-5 mt-md-0">
|
||||
|
||||
Reference in New Issue
Block a user