updated book chapter

This commit is contained in:
Morten Hjorth-Jensen
2021-09-10 16:11:46 +02:00
parent 8f9ffb4fd7
commit b3f74565d8
23 changed files with 23336 additions and 9877 deletions
+1 -3
View File
@@ -1,7 +1,5 @@
======= Linear Regression =======
"Video of Lecture":"https://www.uio.no/studier/emner/matnat/fys/FYS-STK3155/h20/forelesningsvideoer/LectureAug21.mp4?vrtx=view-as-webpage"
===== Introduction =====
@@ -9,7 +7,7 @@
Our emphasis throughout this series of lectures (small change)
Our emphasis throughout this series of lectures
is on understanding the mathematical aspects of
different algorithms used in the fields of data analysis and machine learning.
File diff suppressed because it is too large Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -142,12 +142,12 @@
</li>
<li class="toctree-l1">
<a class="reference internal" href="chapter2.html">
4. Resampling Methods
4. Ridge and Lasso Regression
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="chapter3.html">
5. Ridge and Lasso Regression
5. Resampling Methods
</a>
</li>
<li class="toctree-l1">
+2 -2
View File
@@ -143,12 +143,12 @@
</li>
<li class="toctree-l1">
<a class="reference internal" href="chapter2.html">
4. Resampling Methods
4. Ridge and Lasso Regression
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="chapter3.html">
5. Ridge and Lasso Regression
5. Resampling Methods
</a>
</li>
<li class="toctree-l1">
Binary file not shown.
@@ -17,88 +17,21 @@ Traceback (most recent call last):
raise CellExecutionError.from_cell_and_msg(cell, exec_reply['content'])
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
------------------
%matplotlib inline
from numpy import *
from numpy.random import randint, randn
from time import time
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
# Returns mean of bootstrap samples
def stat(data):
return mean(data)
# Bootstrap algorithm
def bootstrap(data, statistic, R):
t = zeros(R); n = len(data); inds = arange(n); t0 = time()
# non-parametric bootstrap
for i in range(R):
t[i] = statistic(data[randint(0,n,n)])
# analysis
print("Runtime: %g sec" % (time()-t0)); print("Bootstrap Statistics :")
print("original bias std. error")
print("%8g %8g %14g %15g" % (statistic(data), std(data),mean(t),std(t)))
return t
mu, sigma = 100, 15
datapoints = 10000
x = mu + sigma*random.randn(datapoints)
# bootstrap returns the data sample
t = bootstrap(x, stat, datapoints)
# the histogram of the bootstrapped data
n, binsboot, patches = plt.hist(t, 50, normed=1, facecolor='red', alpha=0.75)
# add a 'best fit' line
y = mlab.normpdf( binsboot, mean(t), std(t))
lt = plt.plot(binsboot, y, 'r--', linewidth=1)
plt.xlabel('Smarts')
plt.ylabel('Probability')
plt.axis([99.5, 100.6, 0, 3.0])
plt.grid(True)
plt.show()
Ainv = np.linlag.pinv(A)
------------------
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-772b904ae9cb> in <module>
 31 t = bootstrap(x, stat, datapoints)
 32 # the histogram of the bootstrapped data
---> 33 n, binsboot, patches = plt.hist(t, 50, normed=1, facecolor='red', alpha=0.75)
 34 
 35 # add a 'best fit' line
<ipython-input-6-52d2c51caad1> in <module>
----> 1 Ainv = np.linlag.pinv(A)

~/opt/anaconda3/lib/python3.8/site-packages/numpy/__init__.py in __getattr__(attr)
 212 return Tester
 213 else:
--> 214 raise AttributeError("module {!r} has no attribute "
 215 "{!r}".format(__name__, attr))
 216 
~/opt/anaconda3/lib/python3.8/site-packages/matplotlib/pyplot.py in hist(x, bins, range, density, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, data, **kwargs)
 2683 orientation='vertical', rwidth=None, log=False, color=None,
 2684 label=None, stacked=False, *, data=None, **kwargs):
-> 2685 return gca().hist(
 2686 x, bins=bins, range=range, density=density, weights=weights,
 2687 cumulative=cumulative, bottom=bottom, histtype=histtype,
~/opt/anaconda3/lib/python3.8/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs)
 1445 def inner(ax, *args, data=None, **kwargs):
 1446 if data is None:
-> 1447 return func(ax, *map(sanitize_sequence, args), **kwargs)
 1448 
 1449 bound = new_sig.bind(ax, *args, **kwargs)
~/opt/anaconda3/lib/python3.8/site-packages/matplotlib/axes/_axes.py in hist(self, x, bins, range, density, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, **kwargs)
 6813 if patch:
 6814 p = patch[0]
-> 6815 p.update(kwargs)
 6816 if lbl is not None:
 6817 p.set_label(lbl)
~/opt/anaconda3/lib/python3.8/site-packages/matplotlib/artist.py in update(self, props)
 994 func = getattr(self, f"set_{k}", None)
 995 if not callable(func):
--> 996 raise AttributeError(f"{type(self).__name__!r} object "
 997 f"has no property {k!r}")
 998 ret.append(func(v))
AttributeError: 'Rectangle' object has no property 'normed'
AttributeError: 'Rectangle' object has no property 'normed'
AttributeError: module 'numpy' has no attribute 'linlag'
AttributeError: module 'numpy' has no attribute 'linlag'
+2 -2
View File
@@ -147,12 +147,12 @@
</li>
<li class="toctree-l1">
<a class="reference internal" href="chapter2.html">
4. Resampling Methods
4. Ridge and Lasso Regression
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="chapter3.html">
5. Ridge and Lasso Regression
5. Resampling Methods
</a>
</li>
<li class="toctree-l1">
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff