project 2 ready, typos may be corrected later

This commit is contained in:
mhjensen
2018-10-09 13:54:35 +02:00
parent b76c473f1c
commit 623299924f
7 changed files with 1038 additions and 308 deletions
+6 -12
View File
@@ -2,11 +2,6 @@ TITLE: Project 2 on Machine Learning, deadline November 5
AUTHOR: "Data Analysis and Machine Learning FYS-STK3155/FYS4155":"http://www.uio.no/studier/emner/matnat/fys/FYS3155/index-eng.html" {copyright, 1999-present|CC BY-NC} at Department of Physics, University of Oslo, Norway
DATE: today
o add note to nielsen's text
o add about ising model
o link to where we have the data
o explain how to fit the model
o link to mehta's article
===== Classification and Regression, from linear and logistic regression to neural networks =====
@@ -88,14 +83,12 @@ system as
!bt
\begin{equation*}
E=-J\sum_{<kl>}^{N}s_ks_l-{\cal B}\sum_k^Ns_k,
E=-J\sum_{<kl>}^{N}s_ks_l,
\end{equation*}
!et
with $s_k=\pm 1$, $N$ is the total number of spins,
$J$ is a coupling constant expressing the strength of the interaction
between neighboring spins and
${\cal B}$ is an external magnetic field interacting with the magnetic
moment set up by the spins. We will discard the magnetic field part.
between neighboring spins.
The symbol $<kl>$ indicates that we sum over nearest
neighbors only.
@@ -119,6 +112,7 @@ Consider the 1D Ising model with nearest-neighbor interactions
E[\hat{s}]=-J\sum_{j=1}^{N}s_{j}s_{j+1},
\end{equation*}
!et
on a chain of length $N$ with so-called periodic boundary conditions and $S_j=\pm 1$ Ising spin variables.
In one dimension, this model has no phase transition at finite temperature.
@@ -136,7 +130,6 @@ import numpy as np
import scipy.sparse as sp
np.random.seed(12)
import warnings
#Comment this to turn on warnings
warnings.filterwarnings('ignore')
@@ -172,17 +165,18 @@ In the absence of any prior knowledge, one sensible choice is the all-to-all Isi
E_\mathrm{model}[\boldsymbol{s}^i] = - \sum_{j=1}^N \sum_{k=1}^N J_{j,k}s_{j}^is_{k}^i.
\]
!et
Here $i$ represents a particular spin configuration (one of the possible $n$ configurations we generated with the code above).
This model is uniquely defined by the non-local coupling strengths $J_{jk}$ which we want to learn.
The model is linear in ${\mathbf J}$ which makes it possible to use linear regression.
The model is linear in $\mathbf{J}$ which makes it possible to use linear regression.
To apply linear regression, we recast this model in the form
!bt
\[
E_\mathrm{model}^i \equiv \mathbf{X}^i \cdot \mathbf{J},
\]
!ec
!et
where the vectors $\mathbf{X}^i$ represent all two-body interactions
$\{s_{j}^is_{k}^i \}_{j,k=1}^N$, and the index $i$ runs over the