minor update
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,90 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
# Importing various packages
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from sklearn.linear_model import LinearRegression
|
||||
|
||||
x = np.random.rand(100,1)
|
||||
y = 2*x+np.random.randn(100,1)
|
||||
linreg = LinearRegression()
|
||||
linreg.fit(x,y)
|
||||
# This is our new x-array to which we test our model
|
||||
xnew = np.array([[0],[1]])
|
||||
ypredict = linreg.predict(xnew)
|
||||
|
||||
plt.plot(xnew, ypredict, "r-")
|
||||
plt.plot(x, y ,'ro')
|
||||
plt.axis([0,1.0,0, 5.0])
|
||||
plt.xlabel(r'$x$')
|
||||
plt.ylabel(r'$y$')
|
||||
plt.title(r'Simple Linear Regression')
|
||||
plt.show()
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[1], line 1[0m
|
||||
[0;32m----> 1[0m [43mget_ipython[49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43mrun_line_magic[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mmatplotlib[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43minline[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 3[0m [38;5;66;03m# Importing various packages[39;00m
|
||||
[1;32m 4[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2432[0m, in [0;36mInteractiveShell.run_line_magic[0;34m(self, magic_name, line, _stack_depth)[0m
|
||||
[1;32m 2430[0m kwargs[[38;5;124m'[39m[38;5;124mlocal_ns[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mget_local_scope(stack_depth)
|
||||
[1;32m 2431[0m [38;5;28;01mwith[39;00m [38;5;28mself[39m[38;5;241m.[39mbuiltin_trap:
|
||||
[0;32m-> 2432[0m result [38;5;241m=[39m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
[1;32m 2434[0m [38;5;66;03m# The code below prevents the output from being displayed[39;00m
|
||||
[1;32m 2435[0m [38;5;66;03m# when using magics with decorator @output_can_be_silenced[39;00m
|
||||
[1;32m 2436[0m [38;5;66;03m# when the last Python token in the expression is a ';'.[39;00m
|
||||
[1;32m 2437[0m [38;5;28;01mif[39;00m [38;5;28mgetattr[39m(fn, magic[38;5;241m.[39mMAGIC_OUTPUT_CAN_BE_SILENCED, [38;5;28;01mFalse[39;00m):
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99[0m, in [0;36mPylabMagics.matplotlib[0;34m(self, line)[0m
|
||||
[1;32m 97[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mAvailable matplotlib backends: [39m[38;5;132;01m%s[39;00m[38;5;124m"[39m [38;5;241m%[39m backends_list)
|
||||
[1;32m 98[0m [38;5;28;01melse[39;00m:
|
||||
[0;32m---> 99[0m gui, backend [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mshell[49m[38;5;241;43m.[39;49m[43menable_matplotlib[49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[38;5;241;43m.[39;49m[43mlower[49m[43m([49m[43m)[49m[43m [49m[38;5;28;43;01mif[39;49;00m[43m [49m[38;5;28;43misinstance[39;49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m,[49m[43m [49m[38;5;28;43mstr[39;49m[43m)[49m[43m [49m[38;5;28;43;01melse[39;49;00m[43m [49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m)[49m
|
||||
[1;32m 100[0m [38;5;28mself[39m[38;5;241m.[39m_show_matplotlib_backend(args[38;5;241m.[39mgui, backend)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3606[0m, in [0;36mInteractiveShell.enable_matplotlib[0;34m(self, gui)[0m
|
||||
[1;32m 3585[0m [38;5;28;01mdef[39;00m [38;5;21menable_matplotlib[39m([38;5;28mself[39m, gui[38;5;241m=[39m[38;5;28;01mNone[39;00m):
|
||||
[1;32m 3586[0m [38;5;250m [39m[38;5;124;03m"""Enable interactive matplotlib and inline figure support.[39;00m
|
||||
[1;32m 3587[0m
|
||||
[1;32m 3588[0m [38;5;124;03m This takes the following steps:[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 3604[0m [38;5;124;03m display figures inline.[39;00m
|
||||
[1;32m 3605[0m [38;5;124;03m """[39;00m
|
||||
[0;32m-> 3606[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib_inline[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackend_inline[39;00m [38;5;28;01mimport[39;00m configure_inline_support
|
||||
[1;32m 3608[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcore[39;00m [38;5;28;01mimport[39;00m pylabtools [38;5;28;01mas[39;00m pt
|
||||
[1;32m 3609[0m gui, backend [38;5;241m=[39m pt[38;5;241m.[39mfind_gui_and_backend(gui, [38;5;28mself[39m[38;5;241m.[39mpylab_gui_select)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/__init__.py:1[0m
|
||||
[0;32m----> 1[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m backend_inline, config [38;5;66;03m# noqa[39;00m
|
||||
[1;32m 2[0m __version__ [38;5;241m=[39m [38;5;124m"[39m[38;5;124m0.1.6[39m[38;5;124m"[39m [38;5;66;03m# noqa[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:6[0m
|
||||
[1;32m 1[0m [38;5;124;03m"""A matplotlib backend for publishing figures via display_data"""[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Copyright (c) IPython Development Team.[39;00m
|
||||
[1;32m 4[0m [38;5;66;03m# Distributed under the terms of the BSD 3-Clause License.[39;00m
|
||||
[0;32m----> 6[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m
|
||||
[1;32m 7[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m colors
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackends[39;00m [38;5;28;01mimport[39;00m backend_agg
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'matplotlib'
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
# Read the experimental data with Pandas
|
||||
Masses = pd.read_fwf(infile, usecols=(2,3,4,6,11),
|
||||
names=('N', 'Z', 'A', 'Element', 'Ebinding'),
|
||||
widths=(1,3,5,5,5,1,3,4,1,13,11,11,9,1,2,11,9,1,3,1,12,11,1),
|
||||
header=39,
|
||||
index_col=False)
|
||||
|
||||
# Extrapolated values are indicated by '#' in place of the decimal place, so
|
||||
# the Ebinding column won't be numeric. Coerce to float and drop these entries.
|
||||
Masses['Ebinding'] = pd.to_numeric(Masses['Ebinding'], errors='coerce')
|
||||
Masses = Masses.dropna()
|
||||
# Convert from keV to MeV.
|
||||
Masses['Ebinding'] /= 1000
|
||||
|
||||
# Group the DataFrame by nucleon number, A.
|
||||
Masses = Masses.groupby('A')
|
||||
# Find the rows of the grouped DataFrame with the maximum binding energy.
|
||||
Masses = Masses.apply(lambda t: t[t.Ebinding==t.Ebinding.max()])
|
||||
------------------
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mValueError[0m Traceback (most recent call last)
|
||||
Input [0;32mIn [8][0m, in [0;36m<cell line: 2>[0;34m()[0m
|
||||
[1;32m 1[0m [38;5;66;03m# Read the experimental data with Pandas[39;00m
|
||||
[0;32m----> 2[0m Masses [38;5;241m=[39m [43mpd[49m[38;5;241;43m.[39;49m[43mread_fwf[49m[43m([49m[43minfile[49m[43m,[49m[43m [49m[43musecols[49m[38;5;241;43m=[39;49m[43m([49m[38;5;241;43m2[39;49m[43m,[49m[38;5;241;43m3[39;49m[43m,[49m[38;5;241;43m4[39;49m[43m,[49m[38;5;241;43m6[39;49m[43m,[49m[38;5;241;43m11[39;49m[43m)[49m[43m,[49m
|
||||
[1;32m 3[0m [43m [49m[43mnames[49m[38;5;241;43m=[39;49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mN[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43mZ[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43mA[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43mElement[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43mEbinding[39;49m[38;5;124;43m'[39;49m[43m)[49m[43m,[49m
|
||||
[1;32m 4[0m [43m [49m[43mwidths[49m[38;5;241;43m=[39;49m[43m([49m[38;5;241;43m1[39;49m[43m,[49m[38;5;241;43m3[39;49m[43m,[49m[38;5;241;43m5[39;49m[43m,[49m[38;5;241;43m5[39;49m[43m,[49m[38;5;241;43m5[39;49m[43m,[49m[38;5;241;43m1[39;49m[43m,[49m[38;5;241;43m3[39;49m[43m,[49m[38;5;241;43m4[39;49m[43m,[49m[38;5;241;43m1[39;49m[43m,[49m[38;5;241;43m13[39;49m[43m,[49m[38;5;241;43m11[39;49m[43m,[49m[38;5;241;43m11[39;49m[43m,[49m[38;5;241;43m9[39;49m[43m,[49m[38;5;241;43m1[39;49m[43m,[49m[38;5;241;43m2[39;49m[43m,[49m[38;5;241;43m11[39;49m[43m,[49m[38;5;241;43m9[39;49m[43m,[49m[38;5;241;43m1[39;49m[43m,[49m[38;5;241;43m3[39;49m[43m,[49m[38;5;241;43m1[39;49m[43m,[49m[38;5;241;43m12[39;49m[43m,[49m[38;5;241;43m11[39;49m[43m,[49m[38;5;241;43m1[39;49m[43m)[49m[43m,[49m
|
||||
[1;32m 5[0m [43m [49m[43mheader[49m[38;5;241;43m=[39;49m[38;5;241;43m39[39;49m[43m,[49m
|
||||
[1;32m 6[0m [43m [49m[43mindex_col[49m[38;5;241;43m=[39;49m[38;5;28;43;01mFalse[39;49;00m[43m)[49m
|
||||
[1;32m 8[0m [38;5;66;03m# Extrapolated values are indicated by '#' in place of the decimal place, so[39;00m
|
||||
[1;32m 9[0m [38;5;66;03m# the Ebinding column won't be numeric. Coerce to float and drop these entries.[39;00m
|
||||
[1;32m 10[0m Masses[[38;5;124m'[39m[38;5;124mEbinding[39m[38;5;124m'[39m] [38;5;241m=[39m pd[38;5;241m.[39mto_numeric(Masses[[38;5;124m'[39m[38;5;124mEbinding[39m[38;5;124m'[39m], errors[38;5;241m=[39m[38;5;124m'[39m[38;5;124mcoerce[39m[38;5;124m'[39m)
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/pandas/util/_decorators.py:311[0m, in [0;36mdeprecate_nonkeyword_arguments.<locals>.decorate.<locals>.wrapper[0;34m(*args, **kwargs)[0m
|
||||
[1;32m 305[0m [38;5;28;01mif[39;00m [38;5;28mlen[39m(args) [38;5;241m>[39m num_allow_args:
|
||||
[1;32m 306[0m warnings[38;5;241m.[39mwarn(
|
||||
[1;32m 307[0m msg[38;5;241m.[39mformat(arguments[38;5;241m=[39marguments),
|
||||
[1;32m 308[0m [38;5;167;01mFutureWarning[39;00m,
|
||||
[1;32m 309[0m stacklevel[38;5;241m=[39mstacklevel,
|
||||
[1;32m 310[0m )
|
||||
[0;32m--> 311[0m [38;5;28;01mreturn[39;00m [43mfunc[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/pandas/io/parsers/readers.py:871[0m, in [0;36mread_fwf[0;34m(filepath_or_buffer, colspecs, widths, infer_nrows, **kwds)[0m
|
||||
[1;32m 869[0m len_index [38;5;241m=[39m [38;5;28mlen[39m(index_col)
|
||||
[1;32m 870[0m [38;5;28;01mif[39;00m [38;5;28mlen[39m(names) [38;5;241m+[39m len_index [38;5;241m!=[39m [38;5;28mlen[39m(colspecs):
|
||||
[0;32m--> 871[0m [38;5;28;01mraise[39;00m [38;5;167;01mValueError[39;00m([38;5;124m"[39m[38;5;124mLength of colspecs must match length of names[39m[38;5;124m"[39m)
|
||||
[1;32m 873[0m kwds[[38;5;124m"[39m[38;5;124mcolspecs[39m[38;5;124m"[39m] [38;5;241m=[39m colspecs
|
||||
[1;32m 874[0m kwds[[38;5;124m"[39m[38;5;124minfer_nrows[39m[38;5;124m"[39m] [38;5;241m=[39m infer_nrows
|
||||
|
||||
[0;31mValueError[0m: Length of colspecs must match length of names
|
||||
ValueError: Length of colspecs must match length of names
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
# import necessary packages
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from sklearn import datasets
|
||||
|
||||
|
||||
# ensure the same random numbers appear every time
|
||||
np.random.seed(0)
|
||||
|
||||
# display images in notebook
|
||||
%matplotlib inline
|
||||
plt.rcParams['figure.figsize'] = (12,12)
|
||||
|
||||
|
||||
# download MNIST dataset
|
||||
digits = datasets.load_digits()
|
||||
|
||||
# define inputs and labels
|
||||
inputs = digits.images
|
||||
labels = digits.target
|
||||
|
||||
print("inputs = (n_inputs, pixel_width, pixel_height) = " + str(inputs.shape))
|
||||
print("labels = (n_inputs) = " + str(labels.shape))
|
||||
|
||||
|
||||
# flatten the image
|
||||
# the value -1 means dimension is inferred from the remaining dimensions: 8x8 = 64
|
||||
n_inputs = len(inputs)
|
||||
inputs = inputs.reshape(n_inputs, -1)
|
||||
print("X = (n_inputs, n_features) = " + str(inputs.shape))
|
||||
|
||||
|
||||
# choose some random images to display
|
||||
indices = np.arange(n_inputs)
|
||||
random_indices = np.random.choice(indices, size=5)
|
||||
|
||||
for i, image in enumerate(digits.images[random_indices]):
|
||||
plt.subplot(1, 5, i+1)
|
||||
plt.axis('off')
|
||||
plt.imshow(image, cmap=plt.cm.gray_r, interpolation='nearest')
|
||||
plt.title("Label: %d" % digits.target[random_indices[i]])
|
||||
plt.show()
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[1], line 1[0m
|
||||
[0;32m----> 1[0m [43mget_ipython[49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43mrun_line_magic[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mmatplotlib[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43minline[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 3[0m [38;5;66;03m# import necessary packages[39;00m
|
||||
[1;32m 4[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2432[0m, in [0;36mInteractiveShell.run_line_magic[0;34m(self, magic_name, line, _stack_depth)[0m
|
||||
[1;32m 2430[0m kwargs[[38;5;124m'[39m[38;5;124mlocal_ns[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mget_local_scope(stack_depth)
|
||||
[1;32m 2431[0m [38;5;28;01mwith[39;00m [38;5;28mself[39m[38;5;241m.[39mbuiltin_trap:
|
||||
[0;32m-> 2432[0m result [38;5;241m=[39m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
[1;32m 2434[0m [38;5;66;03m# The code below prevents the output from being displayed[39;00m
|
||||
[1;32m 2435[0m [38;5;66;03m# when using magics with decorator @output_can_be_silenced[39;00m
|
||||
[1;32m 2436[0m [38;5;66;03m# when the last Python token in the expression is a ';'.[39;00m
|
||||
[1;32m 2437[0m [38;5;28;01mif[39;00m [38;5;28mgetattr[39m(fn, magic[38;5;241m.[39mMAGIC_OUTPUT_CAN_BE_SILENCED, [38;5;28;01mFalse[39;00m):
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99[0m, in [0;36mPylabMagics.matplotlib[0;34m(self, line)[0m
|
||||
[1;32m 97[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mAvailable matplotlib backends: [39m[38;5;132;01m%s[39;00m[38;5;124m"[39m [38;5;241m%[39m backends_list)
|
||||
[1;32m 98[0m [38;5;28;01melse[39;00m:
|
||||
[0;32m---> 99[0m gui, backend [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mshell[49m[38;5;241;43m.[39;49m[43menable_matplotlib[49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[38;5;241;43m.[39;49m[43mlower[49m[43m([49m[43m)[49m[43m [49m[38;5;28;43;01mif[39;49;00m[43m [49m[38;5;28;43misinstance[39;49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m,[49m[43m [49m[38;5;28;43mstr[39;49m[43m)[49m[43m [49m[38;5;28;43;01melse[39;49;00m[43m [49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m)[49m
|
||||
[1;32m 100[0m [38;5;28mself[39m[38;5;241m.[39m_show_matplotlib_backend(args[38;5;241m.[39mgui, backend)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3606[0m, in [0;36mInteractiveShell.enable_matplotlib[0;34m(self, gui)[0m
|
||||
[1;32m 3585[0m [38;5;28;01mdef[39;00m [38;5;21menable_matplotlib[39m([38;5;28mself[39m, gui[38;5;241m=[39m[38;5;28;01mNone[39;00m):
|
||||
[1;32m 3586[0m [38;5;250m [39m[38;5;124;03m"""Enable interactive matplotlib and inline figure support.[39;00m
|
||||
[1;32m 3587[0m
|
||||
[1;32m 3588[0m [38;5;124;03m This takes the following steps:[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 3604[0m [38;5;124;03m display figures inline.[39;00m
|
||||
[1;32m 3605[0m [38;5;124;03m """[39;00m
|
||||
[0;32m-> 3606[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib_inline[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackend_inline[39;00m [38;5;28;01mimport[39;00m configure_inline_support
|
||||
[1;32m 3608[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcore[39;00m [38;5;28;01mimport[39;00m pylabtools [38;5;28;01mas[39;00m pt
|
||||
[1;32m 3609[0m gui, backend [38;5;241m=[39m pt[38;5;241m.[39mfind_gui_and_backend(gui, [38;5;28mself[39m[38;5;241m.[39mpylab_gui_select)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/__init__.py:1[0m
|
||||
[0;32m----> 1[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m backend_inline, config [38;5;66;03m# noqa[39;00m
|
||||
[1;32m 2[0m __version__ [38;5;241m=[39m [38;5;124m"[39m[38;5;124m0.1.6[39m[38;5;124m"[39m [38;5;66;03m# noqa[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:6[0m
|
||||
[1;32m 1[0m [38;5;124;03m"""A matplotlib backend for publishing figures via display_data"""[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Copyright (c) IPython Development Team.[39;00m
|
||||
[1;32m 4[0m [38;5;66;03m# Distributed under the terms of the BSD 3-Clause License.[39;00m
|
||||
[0;32m----> 6[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m
|
||||
[1;32m 7[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m colors
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackends[39;00m [38;5;28;01mimport[39;00m backend_agg
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'matplotlib'
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
conda create -n tf tensorflow
|
||||
conda activate tf
|
||||
------------------
|
||||
|
||||
[0;36m Input [0;32mIn [12][0;36m[0m
|
||||
[0;31m conda create -n tf tensorflow[0m
|
||||
[0m ^[0m
|
||||
[0;31mSyntaxError[0m[0;31m:[0m invalid syntax
|
||||
|
||||
SyntaxError: invalid syntax (2259440937.py, line 1)
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
import autograd.numpy as np
|
||||
from autograd import grad, elementwise_grad
|
||||
import autograd.numpy.random as npr
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
def sigmoid(z):
|
||||
return 1/(1 + np.exp(-z))
|
||||
|
||||
# Assuming one input, hidden, and output layer
|
||||
def neural_network(params, x):
|
||||
|
||||
# Find the weights (including and biases) for the hidden and output layer.
|
||||
# Assume that params is a list of parameters for each layer.
|
||||
# The biases are the first element for each array in params,
|
||||
# and the weights are the remaning elements in each array in params.
|
||||
|
||||
w_hidden = params[0]
|
||||
w_output = params[1]
|
||||
|
||||
# Assumes input x being an one-dimensional array
|
||||
num_values = np.size(x)
|
||||
x = x.reshape(-1, num_values)
|
||||
|
||||
# Assume that the input layer does nothing to the input x
|
||||
x_input = x
|
||||
|
||||
## Hidden layer:
|
||||
|
||||
# Add a row of ones to include bias
|
||||
x_input = np.concatenate((np.ones((1,num_values)), x_input ), axis = 0)
|
||||
|
||||
z_hidden = np.matmul(w_hidden, x_input)
|
||||
x_hidden = sigmoid(z_hidden)
|
||||
|
||||
## Output layer:
|
||||
|
||||
# Include bias:
|
||||
x_hidden = np.concatenate((np.ones((1,num_values)), x_hidden ), axis = 0)
|
||||
|
||||
z_output = np.matmul(w_output, x_hidden)
|
||||
x_output = z_output
|
||||
|
||||
return x_output
|
||||
|
||||
# The trial solution using the deep neural network:
|
||||
def g_trial(x,params, g0 = 10):
|
||||
return g0 + x*neural_network(params,x)
|
||||
|
||||
# The right side of the ODE:
|
||||
def g(x, g_trial, gamma = 2):
|
||||
return -gamma*g_trial
|
||||
|
||||
# The cost function:
|
||||
def cost_function(P, x):
|
||||
|
||||
# Evaluate the trial function with the current parameters P
|
||||
g_t = g_trial(x,P)
|
||||
|
||||
# Find the derivative w.r.t x of the neural network
|
||||
d_net_out = elementwise_grad(neural_network,1)(P,x)
|
||||
|
||||
# Find the derivative w.r.t x of the trial function
|
||||
d_g_t = elementwise_grad(g_trial,0)(x,P)
|
||||
|
||||
# The right side of the ODE
|
||||
func = g(x, g_t)
|
||||
|
||||
err_sqr = (d_g_t - func)**2
|
||||
cost_sum = np.sum(err_sqr)
|
||||
|
||||
return cost_sum / np.size(err_sqr)
|
||||
|
||||
# Solve the exponential decay ODE using neural network with one input, hidden, and output layer
|
||||
def solve_ode_neural_network(x, num_neurons_hidden, num_iter, lmb):
|
||||
## Set up initial weights and biases
|
||||
|
||||
# For the hidden layer
|
||||
p0 = npr.randn(num_neurons_hidden, 2 )
|
||||
|
||||
# For the output layer
|
||||
p1 = npr.randn(1, num_neurons_hidden + 1 ) # +1 since bias is included
|
||||
|
||||
P = [p0, p1]
|
||||
|
||||
print('Initial cost: %g'%cost_function(P, x))
|
||||
|
||||
## Start finding the optimal weights using gradient descent
|
||||
|
||||
# Find the Python function that represents the gradient of the cost function
|
||||
# w.r.t the 0-th input argument -- that is the weights and biases in the hidden and output layer
|
||||
cost_function_grad = grad(cost_function,0)
|
||||
|
||||
# Let the update be done num_iter times
|
||||
for i in range(num_iter):
|
||||
# Evaluate the gradient at the current weights and biases in P.
|
||||
# The cost_grad consist now of two arrays;
|
||||
# one for the gradient w.r.t P_hidden and
|
||||
# one for the gradient w.r.t P_output
|
||||
cost_grad = cost_function_grad(P, x)
|
||||
|
||||
P[0] = P[0] - lmb * cost_grad[0]
|
||||
P[1] = P[1] - lmb * cost_grad[1]
|
||||
|
||||
print('Final cost: %g'%cost_function(P, x))
|
||||
|
||||
return P
|
||||
|
||||
def g_analytic(x, gamma = 2, g0 = 10):
|
||||
return g0*np.exp(-gamma*x)
|
||||
|
||||
# Solve the given problem
|
||||
if __name__ == '__main__':
|
||||
# Set seed such that the weight are initialized
|
||||
# with same weights and biases for every run.
|
||||
npr.seed(15)
|
||||
|
||||
## Decide the vales of arguments to the function to solve
|
||||
N = 10
|
||||
x = np.linspace(0, 1, N)
|
||||
|
||||
## Set up the initial parameters
|
||||
num_hidden_neurons = 10
|
||||
num_iter = 10000
|
||||
lmb = 0.001
|
||||
|
||||
# Use the network
|
||||
P = solve_ode_neural_network(x, num_hidden_neurons, num_iter, lmb)
|
||||
|
||||
# Print the deviation from the trial solution and true solution
|
||||
res = g_trial(x,P)
|
||||
res_analytical = g_analytic(x)
|
||||
|
||||
print('Max absolute difference: %g'%np.max(np.abs(res - res_analytical)))
|
||||
|
||||
# Plot the results
|
||||
plt.figure(figsize=(10,10))
|
||||
|
||||
plt.title('Performance of neural network solving an ODE compared to the analytical solution')
|
||||
plt.plot(x, res_analytical)
|
||||
plt.plot(x, res[0,:])
|
||||
plt.legend(['analytical','nn'])
|
||||
plt.xlabel('x')
|
||||
plt.ylabel('g(x)')
|
||||
plt.show()
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[1], line 1[0m
|
||||
[0;32m----> 1[0m [43mget_ipython[49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43mrun_line_magic[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mmatplotlib[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43minline[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 3[0m [38;5;28;01mimport[39;00m [38;5;21;01mautograd[39;00m[38;5;21;01m.[39;00m[38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
[1;32m 4[0m [38;5;28;01mfrom[39;00m [38;5;21;01mautograd[39;00m [38;5;28;01mimport[39;00m grad, elementwise_grad
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2432[0m, in [0;36mInteractiveShell.run_line_magic[0;34m(self, magic_name, line, _stack_depth)[0m
|
||||
[1;32m 2430[0m kwargs[[38;5;124m'[39m[38;5;124mlocal_ns[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mget_local_scope(stack_depth)
|
||||
[1;32m 2431[0m [38;5;28;01mwith[39;00m [38;5;28mself[39m[38;5;241m.[39mbuiltin_trap:
|
||||
[0;32m-> 2432[0m result [38;5;241m=[39m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
[1;32m 2434[0m [38;5;66;03m# The code below prevents the output from being displayed[39;00m
|
||||
[1;32m 2435[0m [38;5;66;03m# when using magics with decorator @output_can_be_silenced[39;00m
|
||||
[1;32m 2436[0m [38;5;66;03m# when the last Python token in the expression is a ';'.[39;00m
|
||||
[1;32m 2437[0m [38;5;28;01mif[39;00m [38;5;28mgetattr[39m(fn, magic[38;5;241m.[39mMAGIC_OUTPUT_CAN_BE_SILENCED, [38;5;28;01mFalse[39;00m):
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99[0m, in [0;36mPylabMagics.matplotlib[0;34m(self, line)[0m
|
||||
[1;32m 97[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mAvailable matplotlib backends: [39m[38;5;132;01m%s[39;00m[38;5;124m"[39m [38;5;241m%[39m backends_list)
|
||||
[1;32m 98[0m [38;5;28;01melse[39;00m:
|
||||
[0;32m---> 99[0m gui, backend [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mshell[49m[38;5;241;43m.[39;49m[43menable_matplotlib[49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[38;5;241;43m.[39;49m[43mlower[49m[43m([49m[43m)[49m[43m [49m[38;5;28;43;01mif[39;49;00m[43m [49m[38;5;28;43misinstance[39;49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m,[49m[43m [49m[38;5;28;43mstr[39;49m[43m)[49m[43m [49m[38;5;28;43;01melse[39;49;00m[43m [49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m)[49m
|
||||
[1;32m 100[0m [38;5;28mself[39m[38;5;241m.[39m_show_matplotlib_backend(args[38;5;241m.[39mgui, backend)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3606[0m, in [0;36mInteractiveShell.enable_matplotlib[0;34m(self, gui)[0m
|
||||
[1;32m 3585[0m [38;5;28;01mdef[39;00m [38;5;21menable_matplotlib[39m([38;5;28mself[39m, gui[38;5;241m=[39m[38;5;28;01mNone[39;00m):
|
||||
[1;32m 3586[0m [38;5;250m [39m[38;5;124;03m"""Enable interactive matplotlib and inline figure support.[39;00m
|
||||
[1;32m 3587[0m
|
||||
[1;32m 3588[0m [38;5;124;03m This takes the following steps:[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 3604[0m [38;5;124;03m display figures inline.[39;00m
|
||||
[1;32m 3605[0m [38;5;124;03m """[39;00m
|
||||
[0;32m-> 3606[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib_inline[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackend_inline[39;00m [38;5;28;01mimport[39;00m configure_inline_support
|
||||
[1;32m 3608[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcore[39;00m [38;5;28;01mimport[39;00m pylabtools [38;5;28;01mas[39;00m pt
|
||||
[1;32m 3609[0m gui, backend [38;5;241m=[39m pt[38;5;241m.[39mfind_gui_and_backend(gui, [38;5;28mself[39m[38;5;241m.[39mpylab_gui_select)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/__init__.py:1[0m
|
||||
[0;32m----> 1[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m backend_inline, config [38;5;66;03m# noqa[39;00m
|
||||
[1;32m 2[0m __version__ [38;5;241m=[39m [38;5;124m"[39m[38;5;124m0.1.6[39m[38;5;124m"[39m [38;5;66;03m# noqa[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:6[0m
|
||||
[1;32m 1[0m [38;5;124;03m"""A matplotlib backend for publishing figures via display_data"""[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Copyright (c) IPython Development Team.[39;00m
|
||||
[1;32m 4[0m [38;5;66;03m# Distributed under the terms of the BSD 3-Clause License.[39;00m
|
||||
[0;32m----> 6[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m
|
||||
[1;32m 7[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m colors
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackends[39;00m [38;5;28;01mimport[39;00m backend_agg
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'matplotlib'
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 730, in _async_poll_for_reply
|
||||
msg = await ensure_async(self.kc.shell_channel.get_msg(timeout=new_timeout))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 96, in ensure_async
|
||||
result = await obj
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_client/channels.py", line 230, in get_msg
|
||||
raise Empty
|
||||
_queue.Empty
|
||||
|
||||
During handling of the above exception, another exception occurred:
|
||||
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 949, in async_execute_cell
|
||||
exec_reply = await self.task_poll_for_reply
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 754, in _async_poll_for_reply
|
||||
await self._async_handle_timeout(timeout, cell)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 801, in _async_handle_timeout
|
||||
raise CellTimeoutError.error_from_timeout_and_cell(
|
||||
nbclient.exceptions.CellTimeoutError: A cell timed out while it was being executed, after 30 seconds.
|
||||
The message was: Cell execution timed out.
|
||||
Here is a preview of the cell contents:
|
||||
-------------------
|
||||
['import autograd.numpy as np', 'from autograd import jacobian,hessian,grad', 'import autograd.numpy.random as npr', 'from matplotlib import cm', 'from matplotlib import pyplot as plt']
|
||||
...
|
||||
[' plt.plot(x, res3)', ' plt.plot(x,res_analytical3)', " plt.legend(['dnn','analytical'])", '', ' plt.show()']
|
||||
-------------------
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
import numpy as np
|
||||
import math
|
||||
from scipy import signal
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# number of points
|
||||
n = 500
|
||||
# start and final times
|
||||
t0 = 0.0
|
||||
tn = 1.0
|
||||
# Period
|
||||
t = np.linspace(t0, tn, n, endpoint=False)
|
||||
SqrSignal = np.zeros(n)
|
||||
SqrSignal = 1.0+signal.square(2*np.pi*5*t)
|
||||
plt.plot(t, SqrSignal)
|
||||
plt.ylim(-0.5, 2.5)
|
||||
plt.show()
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[1], line 1[0m
|
||||
[0;32m----> 1[0m [43mget_ipython[49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43mrun_line_magic[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mmatplotlib[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43minline[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 3[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
[1;32m 4[0m [38;5;28;01mimport[39;00m [38;5;21;01mmath[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2432[0m, in [0;36mInteractiveShell.run_line_magic[0;34m(self, magic_name, line, _stack_depth)[0m
|
||||
[1;32m 2430[0m kwargs[[38;5;124m'[39m[38;5;124mlocal_ns[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mget_local_scope(stack_depth)
|
||||
[1;32m 2431[0m [38;5;28;01mwith[39;00m [38;5;28mself[39m[38;5;241m.[39mbuiltin_trap:
|
||||
[0;32m-> 2432[0m result [38;5;241m=[39m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
[1;32m 2434[0m [38;5;66;03m# The code below prevents the output from being displayed[39;00m
|
||||
[1;32m 2435[0m [38;5;66;03m# when using magics with decorator @output_can_be_silenced[39;00m
|
||||
[1;32m 2436[0m [38;5;66;03m# when the last Python token in the expression is a ';'.[39;00m
|
||||
[1;32m 2437[0m [38;5;28;01mif[39;00m [38;5;28mgetattr[39m(fn, magic[38;5;241m.[39mMAGIC_OUTPUT_CAN_BE_SILENCED, [38;5;28;01mFalse[39;00m):
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99[0m, in [0;36mPylabMagics.matplotlib[0;34m(self, line)[0m
|
||||
[1;32m 97[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mAvailable matplotlib backends: [39m[38;5;132;01m%s[39;00m[38;5;124m"[39m [38;5;241m%[39m backends_list)
|
||||
[1;32m 98[0m [38;5;28;01melse[39;00m:
|
||||
[0;32m---> 99[0m gui, backend [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mshell[49m[38;5;241;43m.[39;49m[43menable_matplotlib[49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[38;5;241;43m.[39;49m[43mlower[49m[43m([49m[43m)[49m[43m [49m[38;5;28;43;01mif[39;49;00m[43m [49m[38;5;28;43misinstance[39;49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m,[49m[43m [49m[38;5;28;43mstr[39;49m[43m)[49m[43m [49m[38;5;28;43;01melse[39;49;00m[43m [49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m)[49m
|
||||
[1;32m 100[0m [38;5;28mself[39m[38;5;241m.[39m_show_matplotlib_backend(args[38;5;241m.[39mgui, backend)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3606[0m, in [0;36mInteractiveShell.enable_matplotlib[0;34m(self, gui)[0m
|
||||
[1;32m 3585[0m [38;5;28;01mdef[39;00m [38;5;21menable_matplotlib[39m([38;5;28mself[39m, gui[38;5;241m=[39m[38;5;28;01mNone[39;00m):
|
||||
[1;32m 3586[0m [38;5;250m [39m[38;5;124;03m"""Enable interactive matplotlib and inline figure support.[39;00m
|
||||
[1;32m 3587[0m
|
||||
[1;32m 3588[0m [38;5;124;03m This takes the following steps:[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 3604[0m [38;5;124;03m display figures inline.[39;00m
|
||||
[1;32m 3605[0m [38;5;124;03m """[39;00m
|
||||
[0;32m-> 3606[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib_inline[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackend_inline[39;00m [38;5;28;01mimport[39;00m configure_inline_support
|
||||
[1;32m 3608[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcore[39;00m [38;5;28;01mimport[39;00m pylabtools [38;5;28;01mas[39;00m pt
|
||||
[1;32m 3609[0m gui, backend [38;5;241m=[39m pt[38;5;241m.[39mfind_gui_and_backend(gui, [38;5;28mself[39m[38;5;241m.[39mpylab_gui_select)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/__init__.py:1[0m
|
||||
[0;32m----> 1[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m backend_inline, config [38;5;66;03m# noqa[39;00m
|
||||
[1;32m 2[0m __version__ [38;5;241m=[39m [38;5;124m"[39m[38;5;124m0.1.6[39m[38;5;124m"[39m [38;5;66;03m# noqa[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:6[0m
|
||||
[1;32m 1[0m [38;5;124;03m"""A matplotlib backend for publishing figures via display_data"""[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Copyright (c) IPython Development Team.[39;00m
|
||||
[1;32m 4[0m [38;5;66;03m# Distributed under the terms of the BSD 3-Clause License.[39;00m
|
||||
[0;32m----> 6[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m
|
||||
[1;32m 7[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m colors
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackends[39;00m [38;5;28;01mimport[39;00m backend_agg
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'matplotlib'
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 730, in _async_poll_for_reply
|
||||
msg = await ensure_async(self.kc.shell_channel.get_msg(timeout=new_timeout))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 96, in ensure_async
|
||||
result = await obj
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_client/channels.py", line 230, in get_msg
|
||||
raise Empty
|
||||
_queue.Empty
|
||||
|
||||
During handling of the above exception, another exception occurred:
|
||||
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 949, in async_execute_cell
|
||||
exec_reply = await self.task_poll_for_reply
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 754, in _async_poll_for_reply
|
||||
await self._async_handle_timeout(timeout, cell)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 801, in _async_handle_timeout
|
||||
raise CellTimeoutError.error_from_timeout_and_cell(
|
||||
nbclient.exceptions.CellTimeoutError: A cell timed out while it was being executed, after 30 seconds.
|
||||
The message was: Cell execution timed out.
|
||||
Here is a preview of the cell contents:
|
||||
-------------------
|
||||
['CNN_keras = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)', ' ', 'for i, eta in enumerate(eta_vals):', ' for j, lmbd in enumerate(lmbd_vals):', ' CNN = create_convolutional_neural_network_keras(input_shape, receptive_field,']
|
||||
...
|
||||
[' ', ' print("Learning rate = ", eta)', ' print("Lambda = ", lmbd)', ' print("Test accuracy: %.3f" % scores[1])', ' print()']
|
||||
-------------------
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
# Start importing packages
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import tensorflow as tf
|
||||
from tensorflow.keras import datasets, layers, models
|
||||
from tensorflow.keras.layers import Input
|
||||
from tensorflow.keras.models import Model, Sequential
|
||||
from tensorflow.keras.layers import Dense, SimpleRNN, LSTM, GRU
|
||||
from tensorflow.keras import optimizers
|
||||
from tensorflow.keras import regularizers
|
||||
from tensorflow.keras.utils import to_categorical
|
||||
|
||||
|
||||
|
||||
# convert into dataset matrix
|
||||
def convertToMatrix(data, step):
|
||||
X, Y =[], []
|
||||
for i in range(len(data)-step):
|
||||
d=i+step
|
||||
X.append(data[i:d,])
|
||||
Y.append(data[d,])
|
||||
return np.array(X), np.array(Y)
|
||||
|
||||
step = 4
|
||||
N = 1000
|
||||
Tp = 800
|
||||
|
||||
t=np.arange(0,N)
|
||||
x=np.sin(0.02*t)+2*np.random.rand(N)
|
||||
df = pd.DataFrame(x)
|
||||
df.head()
|
||||
|
||||
plt.plot(df)
|
||||
plt.show()
|
||||
|
||||
values=df.values
|
||||
train,test = values[0:Tp,:], values[Tp:N,:]
|
||||
|
||||
# add step elements into train and test
|
||||
test = np.append(test,np.repeat(test[-1,],step))
|
||||
train = np.append(train,np.repeat(train[-1,],step))
|
||||
|
||||
trainX,trainY =convertToMatrix(train,step)
|
||||
testX,testY =convertToMatrix(test,step)
|
||||
trainX = np.reshape(trainX, (trainX.shape[0], 1, trainX.shape[1]))
|
||||
testX = np.reshape(testX, (testX.shape[0], 1, testX.shape[1]))
|
||||
|
||||
model = Sequential()
|
||||
model.add(SimpleRNN(units=32, input_shape=(1,step), activation="relu"))
|
||||
model.add(Dense(8, activation="relu"))
|
||||
model.add(Dense(1))
|
||||
model.compile(loss='mean_squared_error', optimizer='rmsprop')
|
||||
model.summary()
|
||||
|
||||
model.fit(trainX,trainY, epochs=100, batch_size=16, verbose=2)
|
||||
trainPredict = model.predict(trainX)
|
||||
testPredict= model.predict(testX)
|
||||
predicted=np.concatenate((trainPredict,testPredict),axis=0)
|
||||
|
||||
trainScore = model.evaluate(trainX, trainY, verbose=0)
|
||||
print(trainScore)
|
||||
|
||||
index = df.index.values
|
||||
plt.plot(index,df)
|
||||
plt.plot(index,predicted)
|
||||
plt.axvline(df.index[Tp], c="r")
|
||||
plt.show()
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[1], line 1[0m
|
||||
[0;32m----> 1[0m [43mget_ipython[49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43mrun_line_magic[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mmatplotlib[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43minline[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 3[0m [38;5;66;03m# Start importing packages[39;00m
|
||||
[1;32m 4[0m [38;5;28;01mimport[39;00m [38;5;21;01mpandas[39;00m [38;5;28;01mas[39;00m [38;5;21;01mpd[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2432[0m, in [0;36mInteractiveShell.run_line_magic[0;34m(self, magic_name, line, _stack_depth)[0m
|
||||
[1;32m 2430[0m kwargs[[38;5;124m'[39m[38;5;124mlocal_ns[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mget_local_scope(stack_depth)
|
||||
[1;32m 2431[0m [38;5;28;01mwith[39;00m [38;5;28mself[39m[38;5;241m.[39mbuiltin_trap:
|
||||
[0;32m-> 2432[0m result [38;5;241m=[39m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
[1;32m 2434[0m [38;5;66;03m# The code below prevents the output from being displayed[39;00m
|
||||
[1;32m 2435[0m [38;5;66;03m# when using magics with decorator @output_can_be_silenced[39;00m
|
||||
[1;32m 2436[0m [38;5;66;03m# when the last Python token in the expression is a ';'.[39;00m
|
||||
[1;32m 2437[0m [38;5;28;01mif[39;00m [38;5;28mgetattr[39m(fn, magic[38;5;241m.[39mMAGIC_OUTPUT_CAN_BE_SILENCED, [38;5;28;01mFalse[39;00m):
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99[0m, in [0;36mPylabMagics.matplotlib[0;34m(self, line)[0m
|
||||
[1;32m 97[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mAvailable matplotlib backends: [39m[38;5;132;01m%s[39;00m[38;5;124m"[39m [38;5;241m%[39m backends_list)
|
||||
[1;32m 98[0m [38;5;28;01melse[39;00m:
|
||||
[0;32m---> 99[0m gui, backend [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mshell[49m[38;5;241;43m.[39;49m[43menable_matplotlib[49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[38;5;241;43m.[39;49m[43mlower[49m[43m([49m[43m)[49m[43m [49m[38;5;28;43;01mif[39;49;00m[43m [49m[38;5;28;43misinstance[39;49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m,[49m[43m [49m[38;5;28;43mstr[39;49m[43m)[49m[43m [49m[38;5;28;43;01melse[39;49;00m[43m [49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m)[49m
|
||||
[1;32m 100[0m [38;5;28mself[39m[38;5;241m.[39m_show_matplotlib_backend(args[38;5;241m.[39mgui, backend)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3606[0m, in [0;36mInteractiveShell.enable_matplotlib[0;34m(self, gui)[0m
|
||||
[1;32m 3585[0m [38;5;28;01mdef[39;00m [38;5;21menable_matplotlib[39m([38;5;28mself[39m, gui[38;5;241m=[39m[38;5;28;01mNone[39;00m):
|
||||
[1;32m 3586[0m [38;5;250m [39m[38;5;124;03m"""Enable interactive matplotlib and inline figure support.[39;00m
|
||||
[1;32m 3587[0m
|
||||
[1;32m 3588[0m [38;5;124;03m This takes the following steps:[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 3604[0m [38;5;124;03m display figures inline.[39;00m
|
||||
[1;32m 3605[0m [38;5;124;03m """[39;00m
|
||||
[0;32m-> 3606[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib_inline[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackend_inline[39;00m [38;5;28;01mimport[39;00m configure_inline_support
|
||||
[1;32m 3608[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcore[39;00m [38;5;28;01mimport[39;00m pylabtools [38;5;28;01mas[39;00m pt
|
||||
[1;32m 3609[0m gui, backend [38;5;241m=[39m pt[38;5;241m.[39mfind_gui_and_backend(gui, [38;5;28mself[39m[38;5;241m.[39mpylab_gui_select)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/__init__.py:1[0m
|
||||
[0;32m----> 1[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m backend_inline, config [38;5;66;03m# noqa[39;00m
|
||||
[1;32m 2[0m __version__ [38;5;241m=[39m [38;5;124m"[39m[38;5;124m0.1.6[39m[38;5;124m"[39m [38;5;66;03m# noqa[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:6[0m
|
||||
[1;32m 1[0m [38;5;124;03m"""A matplotlib backend for publishing figures via display_data"""[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Copyright (c) IPython Development Team.[39;00m
|
||||
[1;32m 4[0m [38;5;66;03m# Distributed under the terms of the BSD 3-Clause License.[39;00m
|
||||
[0;32m----> 6[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m
|
||||
[1;32m 7[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m colors
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackends[39;00m [38;5;28;01mimport[39;00m backend_agg
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'matplotlib'
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 730, in _async_poll_for_reply
|
||||
msg = await ensure_async(self.kc.shell_channel.get_msg(timeout=new_timeout))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 96, in ensure_async
|
||||
result = await obj
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_client/channels.py", line 230, in get_msg
|
||||
raise Empty
|
||||
_queue.Empty
|
||||
|
||||
During handling of the above exception, another exception occurred:
|
||||
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 949, in async_execute_cell
|
||||
exec_reply = await self.task_poll_for_reply
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 754, in _async_poll_for_reply
|
||||
await self._async_handle_timeout(timeout, cell)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 801, in _async_handle_timeout
|
||||
raise CellTimeoutError.error_from_timeout_and_cell(
|
||||
nbclient.exceptions.CellTimeoutError: A cell timed out while it was being executed, after 30 seconds.
|
||||
The message was: Cell execution timed out.
|
||||
Here is a preview of the cell contents:
|
||||
-------------------
|
||||
['%matplotlib inline', '', '# Start importing packages', 'import pandas as pd', 'import numpy as np']
|
||||
...
|
||||
['index = df.index.values', 'plt.plot(index,df)', 'plt.plot(index,predicted)', 'plt.axvline(df.index[Tp], c="r")', 'plt.show()']
|
||||
-------------------
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
n = 10
|
||||
x = np.random.normal(size=n)
|
||||
x = x - np.mean(x)
|
||||
y = 4+3*x+np.random.normal(size=n)
|
||||
y = y - np.mean(y)
|
||||
# Note that we transpose the matrix in order to stay with our ordering n x p
|
||||
X = (np.vstack((x, y))).T
|
||||
print(X)
|
||||
Xpd = pd.DataFrame(X)
|
||||
print(Xpd)
|
||||
correlation_matrix = Xpd.corr()
|
||||
print(correlation_matrix)
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[7], line 2[0m
|
||||
[1;32m 1[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
[0;32m----> 2[0m [38;5;28;01mimport[39;00m [38;5;21;01mpandas[39;00m [38;5;28;01mas[39;00m [38;5;21;01mpd[39;00m
|
||||
[1;32m 3[0m n [38;5;241m=[39m [38;5;241m10[39m
|
||||
[1;32m 4[0m x [38;5;241m=[39m np[38;5;241m.[39mrandom[38;5;241m.[39mnormal(size[38;5;241m=[39mn)
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'pandas'
|
||||
|
||||
@@ -0,0 +1,290 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
from cvxopt import matrix, spdiag, mul, div, sqrt, normal, setseed
|
||||
from cvxopt import blas, lapack, solvers, sparse, spmatrix
|
||||
import math
|
||||
|
||||
try:
|
||||
import mosek
|
||||
import sys
|
||||
__MOSEK = True
|
||||
except: __MOSEK = False
|
||||
|
||||
if __MOSEK:
|
||||
|
||||
def l1regls_mosek(A, b):
|
||||
"""
|
||||
|
||||
Returns the solution of l1-norm regularized least-squares problem
|
||||
|
||||
minimize || A*x - b ||_2^2 + e'*u
|
||||
|
||||
subject to -u <= x <= u
|
||||
|
||||
"""
|
||||
|
||||
m, n = A.size
|
||||
|
||||
env = mosek.Env()
|
||||
task = env.Task(0,0)
|
||||
task.set_Stream(mosek.streamtype.log, lambda x: sys.stdout.write(x))
|
||||
|
||||
task.appendvars( 2*n) # number of variables
|
||||
task.appendcons( 2*n) # number of constraints
|
||||
|
||||
# input quadratic objective
|
||||
Q = matrix(0.0, (n,n))
|
||||
blas.syrk(A, Q, alpha = 2.0, trans='T')
|
||||
|
||||
I = []
|
||||
for i in range(n):
|
||||
I.extend(range(i,n))
|
||||
|
||||
J = []
|
||||
for i in range(n):
|
||||
J.extend((n-i)*[i])
|
||||
|
||||
task.putqobj(I, J, list(Q[matrix(I) + matrix(J)*n]))
|
||||
task.putclist(range(2*n), list(-2*A.T*b) + n*[1.0]) # setup linear objective
|
||||
|
||||
# input constraint matrix row by row
|
||||
for i in range(n):
|
||||
task.putarow( i, [i, n+i], [1.0, -1.0])
|
||||
task.putarow( n+i, [i, n+i], [1.0, 1.0])
|
||||
|
||||
# setup bounds on constraints
|
||||
task.putboundslice(mosek.accmode.con,
|
||||
0, n, n*[mosek.boundkey.up], n*[0.0], n*[0.0])
|
||||
task.putboundslice(mosek.accmode.con,
|
||||
n, 2*n, n*[mosek.boundkey.lo], n*[0.0], n*[0.0])
|
||||
|
||||
# setup variable bounds
|
||||
task.putboundslice(mosek.accmode.var,
|
||||
0, 2*n, 2*n*[mosek.boundkey.fr], 2*n*[0.0], 2*n*[0.0])
|
||||
|
||||
# optimize the task
|
||||
task.putobjsense(mosek.objsense.minimize)
|
||||
task.optimize()
|
||||
task.solutionsummary(mosek.streamtype.log)
|
||||
x = n*[0.0]
|
||||
task.getsolutionslice(mosek.soltype.itr, mosek.solitem.xx, 0, n, x)
|
||||
|
||||
return matrix(x)
|
||||
|
||||
def l1regls_mosek2(A, b):
|
||||
"""
|
||||
|
||||
Returns the solution of l1-norm regularized least-squares problem
|
||||
|
||||
minimize w'*w + e'*u
|
||||
|
||||
subject to -u <= x <= u
|
||||
|
||||
A*x - w = b
|
||||
|
||||
"""
|
||||
|
||||
m, n = A.size
|
||||
|
||||
env = mosek.Env()
|
||||
task = env.Task(0,0)
|
||||
task.set_Stream(mosek.streamtype.log, lambda x: sys.stdout.write(x))
|
||||
|
||||
task.appendvars(2*n + m) # number of variables
|
||||
task.appendcons(2*n + m) # number of constraints
|
||||
|
||||
# input quadratic objective
|
||||
task.putqobj(range(2*n,2*n+m), range(2*n,2*n+m), m*[2.0])
|
||||
|
||||
task.putclist(range(2*n+m), n*[0.0] + n*[1.0] + m*[0.0]) # setup linear objective
|
||||
|
||||
# input constraint matrix row by row
|
||||
for i in range(n):
|
||||
task.putarow( i, [i, n+i], [1.0, -1.0])
|
||||
task.putarow( n+i, [i, n+i], [1.0, 1.0])
|
||||
|
||||
for i in range(m):
|
||||
task.putarow( 2*n+i, range(n) + [2*n+i], list(A[i,:]) + [-1.0])
|
||||
|
||||
# setup bounds on constraints
|
||||
task.putboundslice(mosek.accmode.con,
|
||||
0, n, n*[mosek.boundkey.up], n*[0.0], n*[0.0])
|
||||
task.putboundslice(mosek.accmode.con,
|
||||
n, 2*n, n*[mosek.boundkey.lo], n*[0.0], n*[0.0])
|
||||
task.putboundslice(mosek.accmode.con,
|
||||
2*n, 2*n+m, m*[mosek.boundkey.fx], list(b), list(b))
|
||||
|
||||
# setup variable bounds
|
||||
task.putboundslice(mosek.accmode.var, 0, 2*n+m, (2*n+m)*[mosek.boundkey.fr],
|
||||
(2*n+m)*[0.0], (2*n+m)*[0.0])
|
||||
|
||||
# optimize the task
|
||||
task.putobjsense(mosek.objsense.minimize)
|
||||
task.optimize()
|
||||
task.solutionsummary(mosek.streamtype.log)
|
||||
x = n*[0.0]
|
||||
task.getsolutionslice(mosek.soltype.itr, mosek.solitem.xx, 0, n, x)
|
||||
|
||||
return matrix(x)
|
||||
|
||||
def l1regls(A, b):
|
||||
"""
|
||||
|
||||
Returns the solution of l1-norm regularized least-squares problem
|
||||
|
||||
minimize || A*x - b ||_2^2 + || x ||_1.
|
||||
|
||||
"""
|
||||
|
||||
m, n = A.size
|
||||
q = matrix(1.0, (2*n,1))
|
||||
q[:n] = -2.0 * A.T * b
|
||||
|
||||
def P(u, v, alpha = 1.0, beta = 0.0 ):
|
||||
"""
|
||||
v := alpha * 2.0 * [ A'*A, 0; 0, 0 ] * u + beta * v
|
||||
"""
|
||||
v *= beta
|
||||
v[:n] += alpha * 2.0 * A.T * (A * u[:n])
|
||||
|
||||
|
||||
def G(u, v, alpha=1.0, beta=0.0, trans='N'):
|
||||
"""
|
||||
v := alpha*[I, -I; -I, -I] * u + beta * v (trans = 'N' or 'T')
|
||||
"""
|
||||
|
||||
v *= beta
|
||||
v[:n] += alpha*(u[:n] - u[n:])
|
||||
v[n:] += alpha*(-u[:n] - u[n:])
|
||||
|
||||
h = matrix(0.0, (2*n,1))
|
||||
|
||||
|
||||
# Customized solver for the KKT system
|
||||
#
|
||||
# [ 2.0*A'*A 0 I -I ] [x[:n] ] [bx[:n] ]
|
||||
# [ 0 0 -I -I ] [x[n:] ] = [bx[n:] ].
|
||||
# [ I -I -D1^-1 0 ] [zl[:n]] [bzl[:n]]
|
||||
# [ -I -I 0 -D2^-1 ] [zl[n:]] [bzl[n:]]
|
||||
#
|
||||
# where D1 = W['di'][:n]**2, D2 = W['di'][:n]**2.
|
||||
#
|
||||
# We first eliminate zl and x[n:]:
|
||||
#
|
||||
# ( 2*A'*A + 4*D1*D2*(D1+D2)^-1 ) * x[:n] =
|
||||
# bx[:n] - (D2-D1)*(D1+D2)^-1 * bx[n:] +
|
||||
# D1 * ( I + (D2-D1)*(D1+D2)^-1 ) * bzl[:n] -
|
||||
# D2 * ( I - (D2-D1)*(D1+D2)^-1 ) * bzl[n:]
|
||||
#
|
||||
# x[n:] = (D1+D2)^-1 * ( bx[n:] - D1*bzl[:n] - D2*bzl[n:] )
|
||||
# - (D2-D1)*(D1+D2)^-1 * x[:n]
|
||||
#
|
||||
# zl[:n] = D1 * ( x[:n] - x[n:] - bzl[:n] )
|
||||
# zl[n:] = D2 * (-x[:n] - x[n:] - bzl[n:] ).
|
||||
#
|
||||
# The first equation has the form
|
||||
#
|
||||
# (A'*A + D)*x[:n] = rhs
|
||||
#
|
||||
# and is equivalent to
|
||||
#
|
||||
# [ D A' ] [ x:n] ] = [ rhs ]
|
||||
# [ A -I ] [ v ] [ 0 ].
|
||||
#
|
||||
# It can be solved as
|
||||
#
|
||||
# ( A*D^-1*A' + I ) * v = A * D^-1 * rhs
|
||||
# x[:n] = D^-1 * ( rhs - A'*v ).
|
||||
|
||||
S = matrix(0.0, (m,m))
|
||||
Asc = matrix(0.0, (m,n))
|
||||
v = matrix(0.0, (m,1))
|
||||
|
||||
def Fkkt(W):
|
||||
|
||||
# Factor
|
||||
#
|
||||
# S = A*D^-1*A' + I
|
||||
#
|
||||
# where D = 2*D1*D2*(D1+D2)^-1, D1 = d[:n]**-2, D2 = d[n:]**-2.
|
||||
|
||||
d1, d2 = W['di'][:n]**2, W['di'][n:]**2
|
||||
|
||||
# ds is square root of diagonal of D
|
||||
ds = math.sqrt(2.0) * div( mul( W['di'][:n], W['di'][n:]),
|
||||
sqrt(d1+d2) )
|
||||
d3 = div(d2 - d1, d1 + d2)
|
||||
|
||||
# Asc = A*diag(d)^-1/2
|
||||
Asc = A * spdiag(ds**-1)
|
||||
|
||||
# S = I + A * D^-1 * A'
|
||||
blas.syrk(Asc, S)
|
||||
S[::m+1] += 1.0
|
||||
lapack.potrf(S)
|
||||
|
||||
def g(x, y, z):
|
||||
|
||||
x[:n] = 0.5 * ( x[:n] - mul(d3, x[n:]) +
|
||||
mul(d1, z[:n] + mul(d3, z[:n])) - mul(d2, z[n:] -
|
||||
mul(d3, z[n:])) )
|
||||
x[:n] = div( x[:n], ds)
|
||||
|
||||
# Solve
|
||||
#
|
||||
# S * v = 0.5 * A * D^-1 * ( bx[:n] -
|
||||
# (D2-D1)*(D1+D2)^-1 * bx[n:] +
|
||||
# D1 * ( I + (D2-D1)*(D1+D2)^-1 ) * bzl[:n] -
|
||||
# D2 * ( I - (D2-D1)*(D1+D2)^-1 ) * bzl[n:] )
|
||||
|
||||
blas.gemv(Asc, x, v)
|
||||
lapack.potrs(S, v)
|
||||
|
||||
# x[:n] = D^-1 * ( rhs - A'*v ).
|
||||
blas.gemv(Asc, v, x, alpha=-1.0, beta=1.0, trans='T')
|
||||
x[:n] = div(x[:n], ds)
|
||||
|
||||
# x[n:] = (D1+D2)^-1 * ( bx[n:] - D1*bzl[:n] - D2*bzl[n:] )
|
||||
# - (D2-D1)*(D1+D2)^-1 * x[:n]
|
||||
x[n:] = div( x[n:] - mul(d1, z[:n]) - mul(d2, z[n:]), d1+d2 )\
|
||||
- mul( d3, x[:n] )
|
||||
|
||||
# zl[:n] = D1^1/2 * ( x[:n] - x[n:] - bzl[:n] )
|
||||
# zl[n:] = D2^1/2 * ( -x[:n] - x[n:] - bzl[n:] ).
|
||||
z[:n] = mul( W['di'][:n], x[:n] - x[n:] - z[:n] )
|
||||
z[n:] = mul( W['di'][n:], -x[:n] - x[n:] - z[n:] )
|
||||
|
||||
return g
|
||||
|
||||
return solvers.coneqp(P, q, G, h, kktsolver = Fkkt)['x'][:n]
|
||||
------------------
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
[0;32m<ipython-input-12-d670a873ab0c>[0m in [0;36m<module>[0;34m[0m
|
||||
[0;32m----> 1[0;31m [0;32mfrom[0m [0mcvxopt[0m [0;32mimport[0m [0mmatrix[0m[0;34m,[0m [0mspdiag[0m[0;34m,[0m [0mmul[0m[0;34m,[0m [0mdiv[0m[0;34m,[0m [0msqrt[0m[0;34m,[0m [0mnormal[0m[0;34m,[0m [0msetseed[0m[0;34m[0m[0;34m[0m[0m
|
||||
[0m[1;32m 2[0m [0;32mfrom[0m [0mcvxopt[0m [0;32mimport[0m [0mblas[0m[0;34m,[0m [0mlapack[0m[0;34m,[0m [0msolvers[0m[0;34m,[0m [0msparse[0m[0;34m,[0m [0mspmatrix[0m[0;34m[0m[0;34m[0m[0m
|
||||
[1;32m 3[0m [0;32mimport[0m [0mmath[0m[0;34m[0m[0;34m[0m[0m
|
||||
[1;32m 4[0m [0;34m[0m[0m
|
||||
[1;32m 5[0m [0;32mtry[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'cvxopt'
|
||||
ModuleNotFoundError: No module named 'cvxopt'
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
import numpy as np
|
||||
from time import time
|
||||
from scipy.stats import norm
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# Returns mean of bootstrap samples
|
||||
# Bootstrap algorithm
|
||||
def bootstrap(data, datapoints):
|
||||
t = np.zeros(datapoints)
|
||||
n = len(data)
|
||||
# non-parametric bootstrap
|
||||
for i in range(datapoints):
|
||||
t[i] = np.mean(data[np.random.randint(0,n,n)])
|
||||
# analysis
|
||||
print("Bootstrap Statistics :")
|
||||
print("original bias std. error")
|
||||
print("%8g %8g %14g %15g" % (np.mean(data), np.std(data),np.mean(t),np.std(t)))
|
||||
return t
|
||||
|
||||
# We set the mean value to 100 and the standard deviation to 15
|
||||
mu, sigma = 100, 15
|
||||
datapoints = 10000
|
||||
# We generate random numbers according to the normal distribution
|
||||
x = mu + sigma*np.random.randn(datapoints)
|
||||
# bootstrap returns the data sample
|
||||
t = bootstrap(x, datapoints)
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[2], line 1[0m
|
||||
[0;32m----> 1[0m [43mget_ipython[49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43mrun_line_magic[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mmatplotlib[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43minline[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 3[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
[1;32m 4[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtime[39;00m [38;5;28;01mimport[39;00m time
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2432[0m, in [0;36mInteractiveShell.run_line_magic[0;34m(self, magic_name, line, _stack_depth)[0m
|
||||
[1;32m 2430[0m kwargs[[38;5;124m'[39m[38;5;124mlocal_ns[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mget_local_scope(stack_depth)
|
||||
[1;32m 2431[0m [38;5;28;01mwith[39;00m [38;5;28mself[39m[38;5;241m.[39mbuiltin_trap:
|
||||
[0;32m-> 2432[0m result [38;5;241m=[39m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
[1;32m 2434[0m [38;5;66;03m# The code below prevents the output from being displayed[39;00m
|
||||
[1;32m 2435[0m [38;5;66;03m# when using magics with decorator @output_can_be_silenced[39;00m
|
||||
[1;32m 2436[0m [38;5;66;03m# when the last Python token in the expression is a ';'.[39;00m
|
||||
[1;32m 2437[0m [38;5;28;01mif[39;00m [38;5;28mgetattr[39m(fn, magic[38;5;241m.[39mMAGIC_OUTPUT_CAN_BE_SILENCED, [38;5;28;01mFalse[39;00m):
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99[0m, in [0;36mPylabMagics.matplotlib[0;34m(self, line)[0m
|
||||
[1;32m 97[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mAvailable matplotlib backends: [39m[38;5;132;01m%s[39;00m[38;5;124m"[39m [38;5;241m%[39m backends_list)
|
||||
[1;32m 98[0m [38;5;28;01melse[39;00m:
|
||||
[0;32m---> 99[0m gui, backend [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mshell[49m[38;5;241;43m.[39;49m[43menable_matplotlib[49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[38;5;241;43m.[39;49m[43mlower[49m[43m([49m[43m)[49m[43m [49m[38;5;28;43;01mif[39;49;00m[43m [49m[38;5;28;43misinstance[39;49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m,[49m[43m [49m[38;5;28;43mstr[39;49m[43m)[49m[43m [49m[38;5;28;43;01melse[39;49;00m[43m [49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m)[49m
|
||||
[1;32m 100[0m [38;5;28mself[39m[38;5;241m.[39m_show_matplotlib_backend(args[38;5;241m.[39mgui, backend)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3606[0m, in [0;36mInteractiveShell.enable_matplotlib[0;34m(self, gui)[0m
|
||||
[1;32m 3585[0m [38;5;28;01mdef[39;00m [38;5;21menable_matplotlib[39m([38;5;28mself[39m, gui[38;5;241m=[39m[38;5;28;01mNone[39;00m):
|
||||
[1;32m 3586[0m [38;5;250m [39m[38;5;124;03m"""Enable interactive matplotlib and inline figure support.[39;00m
|
||||
[1;32m 3587[0m
|
||||
[1;32m 3588[0m [38;5;124;03m This takes the following steps:[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 3604[0m [38;5;124;03m display figures inline.[39;00m
|
||||
[1;32m 3605[0m [38;5;124;03m """[39;00m
|
||||
[0;32m-> 3606[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib_inline[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackend_inline[39;00m [38;5;28;01mimport[39;00m configure_inline_support
|
||||
[1;32m 3608[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcore[39;00m [38;5;28;01mimport[39;00m pylabtools [38;5;28;01mas[39;00m pt
|
||||
[1;32m 3609[0m gui, backend [38;5;241m=[39m pt[38;5;241m.[39mfind_gui_and_backend(gui, [38;5;28mself[39m[38;5;241m.[39mpylab_gui_select)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/__init__.py:1[0m
|
||||
[0;32m----> 1[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m backend_inline, config [38;5;66;03m# noqa[39;00m
|
||||
[1;32m 2[0m __version__ [38;5;241m=[39m [38;5;124m"[39m[38;5;124m0.1.6[39m[38;5;124m"[39m [38;5;66;03m# noqa[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:6[0m
|
||||
[1;32m 1[0m [38;5;124;03m"""A matplotlib backend for publishing figures via display_data"""[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Copyright (c) IPython Development Team.[39;00m
|
||||
[1;32m 4[0m [38;5;66;03m# Distributed under the terms of the BSD 3-Clause License.[39;00m
|
||||
[0;32m----> 6[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m
|
||||
[1;32m 7[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m colors
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackends[39;00m [38;5;28;01mimport[39;00m backend_agg
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'matplotlib'
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
scipy.misc.imread
|
||||
------------------
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mNameError[0m Traceback (most recent call last)
|
||||
Input [0;32mIn [31][0m, in [0;36m<cell line: 1>[0;34m()[0m
|
||||
[0;32m----> 1[0m [43mscipy[49m[38;5;241m.[39mmisc[38;5;241m.[39mimread
|
||||
|
||||
[0;31mNameError[0m: name 'scipy' is not defined
|
||||
NameError: name 'scipy' is not defined
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
# Common imports
|
||||
import os
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import matplotlib.pyplot as plt
|
||||
from sklearn.linear_model import LinearRegression, Ridge, Lasso
|
||||
from sklearn.model_selection import train_test_split
|
||||
from sklearn.utils import resample
|
||||
from sklearn.metrics import mean_squared_error
|
||||
from IPython.display import display
|
||||
from pylab import plt, mpl
|
||||
plt.style.use('seaborn')
|
||||
mpl.rcParams['font.family'] = 'serif'
|
||||
|
||||
# Where to save the figures and data files
|
||||
PROJECT_ROOT_DIR = "Results"
|
||||
FIGURE_ID = "Results/FigureFiles"
|
||||
DATA_ID = "DataFiles/"
|
||||
|
||||
if not os.path.exists(PROJECT_ROOT_DIR):
|
||||
os.mkdir(PROJECT_ROOT_DIR)
|
||||
|
||||
if not os.path.exists(FIGURE_ID):
|
||||
os.makedirs(FIGURE_ID)
|
||||
|
||||
if not os.path.exists(DATA_ID):
|
||||
os.makedirs(DATA_ID)
|
||||
|
||||
def image_path(fig_id):
|
||||
return os.path.join(FIGURE_ID, fig_id)
|
||||
|
||||
def data_path(dat_id):
|
||||
return os.path.join(DATA_ID, dat_id)
|
||||
|
||||
def save_fig(fig_id):
|
||||
plt.savefig(image_path(fig_id) + ".png", format='png')
|
||||
|
||||
infile = open(data_path("chddata.csv"),'r')
|
||||
|
||||
# Read the chd data as csv file and organize the data into arrays with age group, age, and chd
|
||||
chd = pd.read_csv(infile, names=('ID', 'Age', 'Agegroup', 'CHD'))
|
||||
chd.columns = ['ID', 'Age', 'Agegroup', 'CHD']
|
||||
output = chd['CHD']
|
||||
age = chd['Age']
|
||||
agegroup = chd['Agegroup']
|
||||
numberID = chd['ID']
|
||||
display(chd)
|
||||
|
||||
plt.scatter(age, output, marker='o')
|
||||
plt.axis([18,70.0,-0.1, 1.2])
|
||||
plt.xlabel(r'Age')
|
||||
plt.ylabel(r'CHD')
|
||||
plt.title(r'Age distribution and Coronary heart disease')
|
||||
plt.show()
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[1], line 1[0m
|
||||
[0;32m----> 1[0m [43mget_ipython[49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43mrun_line_magic[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mmatplotlib[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43minline[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 3[0m [38;5;66;03m# Common imports[39;00m
|
||||
[1;32m 4[0m [38;5;28;01mimport[39;00m [38;5;21;01mos[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2432[0m, in [0;36mInteractiveShell.run_line_magic[0;34m(self, magic_name, line, _stack_depth)[0m
|
||||
[1;32m 2430[0m kwargs[[38;5;124m'[39m[38;5;124mlocal_ns[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mget_local_scope(stack_depth)
|
||||
[1;32m 2431[0m [38;5;28;01mwith[39;00m [38;5;28mself[39m[38;5;241m.[39mbuiltin_trap:
|
||||
[0;32m-> 2432[0m result [38;5;241m=[39m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
[1;32m 2434[0m [38;5;66;03m# The code below prevents the output from being displayed[39;00m
|
||||
[1;32m 2435[0m [38;5;66;03m# when using magics with decorator @output_can_be_silenced[39;00m
|
||||
[1;32m 2436[0m [38;5;66;03m# when the last Python token in the expression is a ';'.[39;00m
|
||||
[1;32m 2437[0m [38;5;28;01mif[39;00m [38;5;28mgetattr[39m(fn, magic[38;5;241m.[39mMAGIC_OUTPUT_CAN_BE_SILENCED, [38;5;28;01mFalse[39;00m):
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99[0m, in [0;36mPylabMagics.matplotlib[0;34m(self, line)[0m
|
||||
[1;32m 97[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mAvailable matplotlib backends: [39m[38;5;132;01m%s[39;00m[38;5;124m"[39m [38;5;241m%[39m backends_list)
|
||||
[1;32m 98[0m [38;5;28;01melse[39;00m:
|
||||
[0;32m---> 99[0m gui, backend [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mshell[49m[38;5;241;43m.[39;49m[43menable_matplotlib[49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[38;5;241;43m.[39;49m[43mlower[49m[43m([49m[43m)[49m[43m [49m[38;5;28;43;01mif[39;49;00m[43m [49m[38;5;28;43misinstance[39;49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m,[49m[43m [49m[38;5;28;43mstr[39;49m[43m)[49m[43m [49m[38;5;28;43;01melse[39;49;00m[43m [49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m)[49m
|
||||
[1;32m 100[0m [38;5;28mself[39m[38;5;241m.[39m_show_matplotlib_backend(args[38;5;241m.[39mgui, backend)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3606[0m, in [0;36mInteractiveShell.enable_matplotlib[0;34m(self, gui)[0m
|
||||
[1;32m 3585[0m [38;5;28;01mdef[39;00m [38;5;21menable_matplotlib[39m([38;5;28mself[39m, gui[38;5;241m=[39m[38;5;28;01mNone[39;00m):
|
||||
[1;32m 3586[0m [38;5;250m [39m[38;5;124;03m"""Enable interactive matplotlib and inline figure support.[39;00m
|
||||
[1;32m 3587[0m
|
||||
[1;32m 3588[0m [38;5;124;03m This takes the following steps:[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 3604[0m [38;5;124;03m display figures inline.[39;00m
|
||||
[1;32m 3605[0m [38;5;124;03m """[39;00m
|
||||
[0;32m-> 3606[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib_inline[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackend_inline[39;00m [38;5;28;01mimport[39;00m configure_inline_support
|
||||
[1;32m 3608[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcore[39;00m [38;5;28;01mimport[39;00m pylabtools [38;5;28;01mas[39;00m pt
|
||||
[1;32m 3609[0m gui, backend [38;5;241m=[39m pt[38;5;241m.[39mfind_gui_and_backend(gui, [38;5;28mself[39m[38;5;241m.[39mpylab_gui_select)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/__init__.py:1[0m
|
||||
[0;32m----> 1[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m backend_inline, config [38;5;66;03m# noqa[39;00m
|
||||
[1;32m 2[0m __version__ [38;5;241m=[39m [38;5;124m"[39m[38;5;124m0.1.6[39m[38;5;124m"[39m [38;5;66;03m# noqa[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:6[0m
|
||||
[1;32m 1[0m [38;5;124;03m"""A matplotlib backend for publishing figures via display_data"""[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Copyright (c) IPython Development Team.[39;00m
|
||||
[1;32m 4[0m [38;5;66;03m# Distributed under the terms of the BSD 3-Clause License.[39;00m
|
||||
[0;32m----> 6[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m
|
||||
[1;32m 7[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m colors
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackends[39;00m [38;5;28;01mimport[39;00m backend_agg
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'matplotlib'
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
from sklearn.model_selection import train_test_split
|
||||
from sklearn.datasets import load_breast_cancer
|
||||
from sklearn.linear_model import LogisticRegression
|
||||
|
||||
# Load the data
|
||||
cancer = load_breast_cancer()
|
||||
|
||||
X_train, X_test, y_train, y_test = train_test_split(cancer.data,cancer.target,random_state=0)
|
||||
print(X_train.shape)
|
||||
print(X_test.shape)
|
||||
# Logistic Regression
|
||||
logreg = LogisticRegression(solver='lbfgs')
|
||||
logreg.fit(X_train, y_train)
|
||||
print("Test set accuracy with Logistic Regression: {:.2f}".format(logreg.score(X_test,y_test)))
|
||||
#now scale the data
|
||||
from sklearn.preprocessing import StandardScaler
|
||||
scaler = StandardScaler()
|
||||
scaler.fit(X_train)
|
||||
X_train_scaled = scaler.transform(X_train)
|
||||
X_test_scaled = scaler.transform(X_test)
|
||||
# Logistic Regression
|
||||
logreg.fit(X_train_scaled, y_train)
|
||||
print("Test set accuracy Logistic Regression with scaled data: {:.2f}".format(logreg.score(X_test_scaled,y_test)))
|
||||
|
||||
|
||||
from sklearn.preprocessing import LabelEncoder
|
||||
from sklearn.model_selection import cross_validate
|
||||
#Cross validation
|
||||
accuracy = cross_validate(logreg,X_test_scaled,y_test,cv=10)['test_score']
|
||||
print(accuracy)
|
||||
print("Test set accuracy with Logistic Regression and scaled data: {:.2f}".format(logreg.score(X_test_scaled,y_test)))
|
||||
|
||||
|
||||
import scikitplot as skplt
|
||||
y_pred = logreg.predict(X_test_scaled)
|
||||
skplt.metrics.plot_confusion_matrix(y_test, y_pred, normalize=True)
|
||||
plt.show()
|
||||
y_probas = logreg.predict_proba(X_test_scaled)
|
||||
skplt.metrics.plot_roc(y_test, y_probas)
|
||||
plt.show()
|
||||
skplt.metrics.plot_cumulative_gain(y_test, y_probas)
|
||||
plt.show()
|
||||
------------------
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Input [0;32mIn [8][0m, in [0;36m<cell line: 36>[0;34m()[0m
|
||||
[1;32m 32[0m [38;5;28mprint[39m(accuracy)
|
||||
[1;32m 33[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mTest set accuracy with Logistic Regression and scaled data: [39m[38;5;132;01m{:.2f}[39;00m[38;5;124m"[39m[38;5;241m.[39mformat(logreg[38;5;241m.[39mscore(X_test_scaled,y_test)))
|
||||
[0;32m---> 36[0m [38;5;28;01mimport[39;00m [38;5;21;01mscikitplot[39;00m [38;5;28;01mas[39;00m [38;5;21;01mskplt[39;00m
|
||||
[1;32m 37[0m y_pred [38;5;241m=[39m logreg[38;5;241m.[39mpredict(X_test_scaled)
|
||||
[1;32m 38[0m skplt[38;5;241m.[39mmetrics[38;5;241m.[39mplot_confusion_matrix(y_test, y_pred, normalize[38;5;241m=[39m[38;5;28;01mTrue[39;00m)
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'scikitplot'
|
||||
ModuleNotFoundError: No module named 'scikitplot'
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
from sklearn import datasets
|
||||
from sklearn.svm import SVC, LinearSVC
|
||||
from sklearn.linear_model import SGDClassifier
|
||||
from sklearn.preprocessing import StandardScaler
|
||||
import matplotlib
|
||||
import matplotlib.pyplot as plt
|
||||
plt.rcParams['axes.labelsize'] = 14
|
||||
plt.rcParams['xtick.labelsize'] = 12
|
||||
plt.rcParams['ytick.labelsize'] = 12
|
||||
|
||||
|
||||
iris = datasets.load_iris()
|
||||
X = iris["data"][:, (2, 3)] # petal length, petal width
|
||||
y = iris["target"]
|
||||
|
||||
setosa_or_versicolor = (y == 0) | (y == 1)
|
||||
X = X[setosa_or_versicolor]
|
||||
y = y[setosa_or_versicolor]
|
||||
|
||||
|
||||
|
||||
C = 5
|
||||
alpha = 1 / (C * len(X))
|
||||
|
||||
lin_clf = LinearSVC(loss="hinge", C=C, random_state=42)
|
||||
svm_clf = SVC(kernel="linear", C=C)
|
||||
sgd_clf = SGDClassifier(loss="hinge", learning_rate="constant", eta0=0.001, alpha=alpha,
|
||||
max_iter=100000, random_state=42)
|
||||
|
||||
scaler = StandardScaler()
|
||||
X_scaled = scaler.fit_transform(X)
|
||||
|
||||
lin_clf.fit(X_scaled, y)
|
||||
svm_clf.fit(X_scaled, y)
|
||||
sgd_clf.fit(X_scaled, y)
|
||||
|
||||
print("LinearSVC: ", lin_clf.intercept_, lin_clf.coef_)
|
||||
print("SVC: ", svm_clf.intercept_, svm_clf.coef_)
|
||||
print("SGDClassifier(alpha={:.5f}):".format(sgd_clf.alpha), sgd_clf.intercept_, sgd_clf.coef_)
|
||||
|
||||
# Compute the slope and bias of each decision boundary
|
||||
w1 = -lin_clf.coef_[0, 0]/lin_clf.coef_[0, 1]
|
||||
b1 = -lin_clf.intercept_[0]/lin_clf.coef_[0, 1]
|
||||
w2 = -svm_clf.coef_[0, 0]/svm_clf.coef_[0, 1]
|
||||
b2 = -svm_clf.intercept_[0]/svm_clf.coef_[0, 1]
|
||||
w3 = -sgd_clf.coef_[0, 0]/sgd_clf.coef_[0, 1]
|
||||
b3 = -sgd_clf.intercept_[0]/sgd_clf.coef_[0, 1]
|
||||
|
||||
# Transform the decision boundary lines back to the original scale
|
||||
line1 = scaler.inverse_transform([[-10, -10 * w1 + b1], [10, 10 * w1 + b1]])
|
||||
line2 = scaler.inverse_transform([[-10, -10 * w2 + b2], [10, 10 * w2 + b2]])
|
||||
line3 = scaler.inverse_transform([[-10, -10 * w3 + b3], [10, 10 * w3 + b3]])
|
||||
|
||||
# Plot all three decision boundaries
|
||||
plt.figure(figsize=(11, 4))
|
||||
plt.plot(line1[:, 0], line1[:, 1], "k:", label="LinearSVC")
|
||||
plt.plot(line2[:, 0], line2[:, 1], "b--", linewidth=2, label="SVC")
|
||||
plt.plot(line3[:, 0], line3[:, 1], "r-", label="SGDClassifier")
|
||||
plt.plot(X[:, 0][y==1], X[:, 1][y==1], "bs") # label="Iris-Versicolor"
|
||||
plt.plot(X[:, 0][y==0], X[:, 1][y==0], "yo") # label="Iris-Setosa"
|
||||
plt.xlabel("Petal length", fontsize=14)
|
||||
plt.ylabel("Petal width", fontsize=14)
|
||||
plt.legend(loc="upper center", fontsize=14)
|
||||
plt.axis([0, 5.5, 0, 2])
|
||||
|
||||
plt.show()
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[1], line 1[0m
|
||||
[0;32m----> 1[0m [43mget_ipython[49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43mrun_line_magic[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mmatplotlib[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43minline[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 3[0m [38;5;28;01mfrom[39;00m [38;5;21;01msklearn[39;00m [38;5;28;01mimport[39;00m datasets
|
||||
[1;32m 4[0m [38;5;28;01mfrom[39;00m [38;5;21;01msklearn[39;00m[38;5;21;01m.[39;00m[38;5;21;01msvm[39;00m [38;5;28;01mimport[39;00m SVC, LinearSVC
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2432[0m, in [0;36mInteractiveShell.run_line_magic[0;34m(self, magic_name, line, _stack_depth)[0m
|
||||
[1;32m 2430[0m kwargs[[38;5;124m'[39m[38;5;124mlocal_ns[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mget_local_scope(stack_depth)
|
||||
[1;32m 2431[0m [38;5;28;01mwith[39;00m [38;5;28mself[39m[38;5;241m.[39mbuiltin_trap:
|
||||
[0;32m-> 2432[0m result [38;5;241m=[39m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
[1;32m 2434[0m [38;5;66;03m# The code below prevents the output from being displayed[39;00m
|
||||
[1;32m 2435[0m [38;5;66;03m# when using magics with decorator @output_can_be_silenced[39;00m
|
||||
[1;32m 2436[0m [38;5;66;03m# when the last Python token in the expression is a ';'.[39;00m
|
||||
[1;32m 2437[0m [38;5;28;01mif[39;00m [38;5;28mgetattr[39m(fn, magic[38;5;241m.[39mMAGIC_OUTPUT_CAN_BE_SILENCED, [38;5;28;01mFalse[39;00m):
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99[0m, in [0;36mPylabMagics.matplotlib[0;34m(self, line)[0m
|
||||
[1;32m 97[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mAvailable matplotlib backends: [39m[38;5;132;01m%s[39;00m[38;5;124m"[39m [38;5;241m%[39m backends_list)
|
||||
[1;32m 98[0m [38;5;28;01melse[39;00m:
|
||||
[0;32m---> 99[0m gui, backend [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mshell[49m[38;5;241;43m.[39;49m[43menable_matplotlib[49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[38;5;241;43m.[39;49m[43mlower[49m[43m([49m[43m)[49m[43m [49m[38;5;28;43;01mif[39;49;00m[43m [49m[38;5;28;43misinstance[39;49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m,[49m[43m [49m[38;5;28;43mstr[39;49m[43m)[49m[43m [49m[38;5;28;43;01melse[39;49;00m[43m [49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m)[49m
|
||||
[1;32m 100[0m [38;5;28mself[39m[38;5;241m.[39m_show_matplotlib_backend(args[38;5;241m.[39mgui, backend)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3606[0m, in [0;36mInteractiveShell.enable_matplotlib[0;34m(self, gui)[0m
|
||||
[1;32m 3585[0m [38;5;28;01mdef[39;00m [38;5;21menable_matplotlib[39m([38;5;28mself[39m, gui[38;5;241m=[39m[38;5;28;01mNone[39;00m):
|
||||
[1;32m 3586[0m [38;5;250m [39m[38;5;124;03m"""Enable interactive matplotlib and inline figure support.[39;00m
|
||||
[1;32m 3587[0m
|
||||
[1;32m 3588[0m [38;5;124;03m This takes the following steps:[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 3604[0m [38;5;124;03m display figures inline.[39;00m
|
||||
[1;32m 3605[0m [38;5;124;03m """[39;00m
|
||||
[0;32m-> 3606[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib_inline[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackend_inline[39;00m [38;5;28;01mimport[39;00m configure_inline_support
|
||||
[1;32m 3608[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcore[39;00m [38;5;28;01mimport[39;00m pylabtools [38;5;28;01mas[39;00m pt
|
||||
[1;32m 3609[0m gui, backend [38;5;241m=[39m pt[38;5;241m.[39mfind_gui_and_backend(gui, [38;5;28mself[39m[38;5;241m.[39mpylab_gui_select)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/__init__.py:1[0m
|
||||
[0;32m----> 1[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m backend_inline, config [38;5;66;03m# noqa[39;00m
|
||||
[1;32m 2[0m __version__ [38;5;241m=[39m [38;5;124m"[39m[38;5;124m0.1.6[39m[38;5;124m"[39m [38;5;66;03m# noqa[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:6[0m
|
||||
[1;32m 1[0m [38;5;124;03m"""A matplotlib backend for publishing figures via display_data"""[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Copyright (c) IPython Development Team.[39;00m
|
||||
[1;32m 4[0m [38;5;66;03m# Distributed under the terms of the BSD 3-Clause License.[39;00m
|
||||
[0;32m----> 6[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m
|
||||
[1;32m 7[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m colors
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackends[39;00m [38;5;28;01mimport[39;00m backend_agg
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'matplotlib'
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
# Import the necessary packages
|
||||
import numpy
|
||||
from cvxopt import matrix
|
||||
from cvxopt import solvers
|
||||
P = matrix(numpy.diag([1,0]), tc=’d’)
|
||||
q = matrix(numpy.array([3,4]), tc=’d’)
|
||||
G = matrix(numpy.array([[-1,0],[0,-1],[-1,-3],[2,5],[3,4]]), tc=’d’)
|
||||
h = matrix(numpy.array([0,0,-15,100,80]), tc=’d’)
|
||||
# Construct the QP, invoke solver
|
||||
sol = solvers.qp(P,q,G,h)
|
||||
# Extract optimal value and solution
|
||||
sol[’x’]
|
||||
sol[’primal objective’]
|
||||
------------------
|
||||
|
||||
[0;36m Input [0;32mIn [5][0;36m[0m
|
||||
[0;31m P = matrix(numpy.diag([1,0]), tc=’d’)[0m
|
||||
[0m ^[0m
|
||||
[0;31mSyntaxError[0m[0;31m:[0m invalid character '’' (U+2019)
|
||||
|
||||
SyntaxError: invalid character '’' (U+2019) (3974140161.py, line 5)
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from sklearn.preprocessing import PolynomialFeatures
|
||||
from sklearn.linear_model import LinearRegression
|
||||
|
||||
steps=250
|
||||
|
||||
distance=0
|
||||
x=0
|
||||
distance_list=[]
|
||||
steps_list=[]
|
||||
while x<steps:
|
||||
distance+=np.random.randint(-1,2)
|
||||
distance_list.append(distance)
|
||||
x+=1
|
||||
steps_list.append(x)
|
||||
plt.plot(steps_list,distance_list, color='green', label="Random Walk Data")
|
||||
|
||||
steps_list=np.asarray(steps_list)
|
||||
distance_list=np.asarray(distance_list)
|
||||
|
||||
X=steps_list[:,np.newaxis]
|
||||
|
||||
#Polynomial fits
|
||||
|
||||
#Degree 2
|
||||
poly_features=PolynomialFeatures(degree=2, include_bias=False)
|
||||
X_poly=poly_features.fit_transform(X)
|
||||
|
||||
lin_reg=LinearRegression()
|
||||
poly_fit=lin_reg.fit(X_poly,distance_list)
|
||||
b=lin_reg.coef_
|
||||
c=lin_reg.intercept_
|
||||
print ("2nd degree coefficients:")
|
||||
print ("zero power: ",c)
|
||||
print ("first power: ", b[0])
|
||||
print ("second power: ",b[1])
|
||||
|
||||
z = np.arange(0, steps, .01)
|
||||
z_mod=b[1]*z**2+b[0]*z+c
|
||||
|
||||
fit_mod=b[1]*X**2+b[0]*X+c
|
||||
plt.plot(z, z_mod, color='r', label="2nd Degree Fit")
|
||||
plt.title("Polynomial Regression")
|
||||
|
||||
plt.xlabel("Steps")
|
||||
plt.ylabel("Distance")
|
||||
|
||||
#Degree 10
|
||||
poly_features10=PolynomialFeatures(degree=10, include_bias=False)
|
||||
X_poly10=poly_features10.fit_transform(X)
|
||||
|
||||
poly_fit10=lin_reg.fit(X_poly10,distance_list)
|
||||
|
||||
y_plot=poly_fit10.predict(X_poly10)
|
||||
plt.plot(X, y_plot, color='black', label="10th Degree Fit")
|
||||
|
||||
plt.legend()
|
||||
plt.show()
|
||||
|
||||
|
||||
#Decision Tree Regression
|
||||
from sklearn.tree import DecisionTreeRegressor
|
||||
regr_1=DecisionTreeRegressor(max_depth=2)
|
||||
regr_2=DecisionTreeRegressor(max_depth=5)
|
||||
regr_3=DecisionTreeRegressor(max_depth=7)
|
||||
regr_1.fit(X, distance_list)
|
||||
regr_2.fit(X, distance_list)
|
||||
regr_3.fit(X, distance_list)
|
||||
|
||||
X_test = np.arange(0.0, steps, 0.01)[:, np.newaxis]
|
||||
y_1 = regr_1.predict(X_test)
|
||||
y_2 = regr_2.predict(X_test)
|
||||
y_3=regr_3.predict(X_test)
|
||||
|
||||
# Plot the results
|
||||
plt.figure()
|
||||
plt.scatter(X, distance_list, s=2.5, c="black", label="data")
|
||||
plt.plot(X_test, y_1, color="red",
|
||||
label="max_depth=2", linewidth=2)
|
||||
plt.plot(X_test, y_2, color="green", label="max_depth=5", linewidth=2)
|
||||
plt.plot(X_test, y_3, color="m", label="max_depth=7", linewidth=2)
|
||||
|
||||
plt.xlabel("Data")
|
||||
plt.ylabel("Darget")
|
||||
plt.title("Decision Tree Regression")
|
||||
plt.legend()
|
||||
plt.show()
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[1], line 1[0m
|
||||
[0;32m----> 1[0m [43mget_ipython[49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43mrun_line_magic[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mmatplotlib[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43minline[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 3[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
[1;32m 4[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mpyplot[39;00m [38;5;28;01mas[39;00m [38;5;21;01mplt[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2432[0m, in [0;36mInteractiveShell.run_line_magic[0;34m(self, magic_name, line, _stack_depth)[0m
|
||||
[1;32m 2430[0m kwargs[[38;5;124m'[39m[38;5;124mlocal_ns[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mget_local_scope(stack_depth)
|
||||
[1;32m 2431[0m [38;5;28;01mwith[39;00m [38;5;28mself[39m[38;5;241m.[39mbuiltin_trap:
|
||||
[0;32m-> 2432[0m result [38;5;241m=[39m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
[1;32m 2434[0m [38;5;66;03m# The code below prevents the output from being displayed[39;00m
|
||||
[1;32m 2435[0m [38;5;66;03m# when using magics with decorator @output_can_be_silenced[39;00m
|
||||
[1;32m 2436[0m [38;5;66;03m# when the last Python token in the expression is a ';'.[39;00m
|
||||
[1;32m 2437[0m [38;5;28;01mif[39;00m [38;5;28mgetattr[39m(fn, magic[38;5;241m.[39mMAGIC_OUTPUT_CAN_BE_SILENCED, [38;5;28;01mFalse[39;00m):
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99[0m, in [0;36mPylabMagics.matplotlib[0;34m(self, line)[0m
|
||||
[1;32m 97[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mAvailable matplotlib backends: [39m[38;5;132;01m%s[39;00m[38;5;124m"[39m [38;5;241m%[39m backends_list)
|
||||
[1;32m 98[0m [38;5;28;01melse[39;00m:
|
||||
[0;32m---> 99[0m gui, backend [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mshell[49m[38;5;241;43m.[39;49m[43menable_matplotlib[49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[38;5;241;43m.[39;49m[43mlower[49m[43m([49m[43m)[49m[43m [49m[38;5;28;43;01mif[39;49;00m[43m [49m[38;5;28;43misinstance[39;49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m,[49m[43m [49m[38;5;28;43mstr[39;49m[43m)[49m[43m [49m[38;5;28;43;01melse[39;49;00m[43m [49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m)[49m
|
||||
[1;32m 100[0m [38;5;28mself[39m[38;5;241m.[39m_show_matplotlib_backend(args[38;5;241m.[39mgui, backend)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3606[0m, in [0;36mInteractiveShell.enable_matplotlib[0;34m(self, gui)[0m
|
||||
[1;32m 3585[0m [38;5;28;01mdef[39;00m [38;5;21menable_matplotlib[39m([38;5;28mself[39m, gui[38;5;241m=[39m[38;5;28;01mNone[39;00m):
|
||||
[1;32m 3586[0m [38;5;250m [39m[38;5;124;03m"""Enable interactive matplotlib and inline figure support.[39;00m
|
||||
[1;32m 3587[0m
|
||||
[1;32m 3588[0m [38;5;124;03m This takes the following steps:[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 3604[0m [38;5;124;03m display figures inline.[39;00m
|
||||
[1;32m 3605[0m [38;5;124;03m """[39;00m
|
||||
[0;32m-> 3606[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib_inline[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackend_inline[39;00m [38;5;28;01mimport[39;00m configure_inline_support
|
||||
[1;32m 3608[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcore[39;00m [38;5;28;01mimport[39;00m pylabtools [38;5;28;01mas[39;00m pt
|
||||
[1;32m 3609[0m gui, backend [38;5;241m=[39m pt[38;5;241m.[39mfind_gui_and_backend(gui, [38;5;28mself[39m[38;5;241m.[39mpylab_gui_select)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/__init__.py:1[0m
|
||||
[0;32m----> 1[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m backend_inline, config [38;5;66;03m# noqa[39;00m
|
||||
[1;32m 2[0m __version__ [38;5;241m=[39m [38;5;124m"[39m[38;5;124m0.1.6[39m[38;5;124m"[39m [38;5;66;03m# noqa[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:6[0m
|
||||
[1;32m 1[0m [38;5;124;03m"""A matplotlib backend for publishing figures via display_data"""[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Copyright (c) IPython Development Team.[39;00m
|
||||
[1;32m 4[0m [38;5;66;03m# Distributed under the terms of the BSD 3-Clause License.[39;00m
|
||||
[0;32m----> 6[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m
|
||||
[1;32m 7[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m colors
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackends[39;00m [38;5;28;01mimport[39;00m backend_agg
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'matplotlib'
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
# Common imports
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import matplotlib.pyplot as plt
|
||||
from sklearn.tree import DecisionTreeClassifier
|
||||
from sklearn.model_selection import train_test_split
|
||||
from sklearn.tree import export_graphviz
|
||||
from sklearn.preprocessing import StandardScaler, OneHotEncoder
|
||||
from sklearn.compose import ColumnTransformer
|
||||
from IPython.display import Image
|
||||
from pydot import graph_from_dot_data
|
||||
import os
|
||||
|
||||
# Where to save the figures and data files
|
||||
PROJECT_ROOT_DIR = "Results"
|
||||
FIGURE_ID = "Results/FigureFiles"
|
||||
DATA_ID = "DataFiles/"
|
||||
|
||||
if not os.path.exists(PROJECT_ROOT_DIR):
|
||||
os.mkdir(PROJECT_ROOT_DIR)
|
||||
|
||||
if not os.path.exists(FIGURE_ID):
|
||||
os.makedirs(FIGURE_ID)
|
||||
|
||||
if not os.path.exists(DATA_ID):
|
||||
os.makedirs(DATA_ID)
|
||||
|
||||
def image_path(fig_id):
|
||||
return os.path.join(FIGURE_ID, fig_id)
|
||||
|
||||
def data_path(dat_id):
|
||||
return os.path.join(DATA_ID, dat_id)
|
||||
|
||||
def save_fig(fig_id):
|
||||
plt.savefig(image_path(fig_id) + ".png", format='png')
|
||||
|
||||
infile = open(data_path("rideclass.csv"),'r')
|
||||
|
||||
# Read the experimental data with Pandas
|
||||
from IPython.display import display
|
||||
ridedata = pd.read_csv(infile,names = ('Outlook','Temperature','Humidity','Wind','Ride'))
|
||||
ridedata = pd.DataFrame(ridedata)
|
||||
|
||||
# Features and targets
|
||||
X = ridedata.loc[:, ridedata.columns != 'Ride'].values
|
||||
y = ridedata.loc[:, ridedata.columns == 'Ride'].values
|
||||
|
||||
# Create the encoder.
|
||||
encoder = OneHotEncoder(handle_unknown="ignore")
|
||||
# Assume for simplicity all features are categorical.
|
||||
encoder.fit(X)
|
||||
# Apply the encoder.
|
||||
X = encoder.transform(X)
|
||||
print(X)
|
||||
# Then do a Classification tree
|
||||
tree_clf = DecisionTreeClassifier(max_depth=2)
|
||||
tree_clf.fit(X, y)
|
||||
print("Train set accuracy with Decision Tree: {:.2f}".format(tree_clf.score(X,y)))
|
||||
#transfer to a decision tree graph
|
||||
export_graphviz(
|
||||
tree_clf,
|
||||
out_file="DataFiles/ride.dot",
|
||||
rounded=True,
|
||||
filled=True
|
||||
)
|
||||
cmd = 'dot -Tpng DataFiles/cancer.dot -o DataFiles/cancer.png'
|
||||
os.system(cmd)
|
||||
------------------
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mFileNotFoundError[0m Traceback (most recent call last)
|
||||
Input [0;32mIn [6][0m, in [0;36m<cell line: 37>[0;34m()[0m
|
||||
[1;32m 34[0m [38;5;28;01mdef[39;00m [38;5;21msave_fig[39m(fig_id):
|
||||
[1;32m 35[0m plt[38;5;241m.[39msavefig(image_path(fig_id) [38;5;241m+[39m [38;5;124m"[39m[38;5;124m.png[39m[38;5;124m"[39m, [38;5;28mformat[39m[38;5;241m=[39m[38;5;124m'[39m[38;5;124mpng[39m[38;5;124m'[39m)
|
||||
[0;32m---> 37[0m infile [38;5;241m=[39m [38;5;28;43mopen[39;49m[43m([49m[43mdata_path[49m[43m([49m[38;5;124;43m"[39;49m[38;5;124;43mrideclass.csv[39;49m[38;5;124;43m"[39;49m[43m)[49m[43m,[49m[38;5;124;43m'[39;49m[38;5;124;43mr[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 39[0m [38;5;66;03m# Read the experimental data with Pandas[39;00m
|
||||
[1;32m 40[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mdisplay[39;00m [38;5;28;01mimport[39;00m display
|
||||
|
||||
[0;31mFileNotFoundError[0m: [Errno 2] No such file or directory: 'DataFiles/rideclass.csv'
|
||||
FileNotFoundError: [Errno 2] No such file or directory: 'DataFiles/rideclass.csv'
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
heads_proba = 0.51
|
||||
coin_tosses = (np.random.rand(10000, 10) < heads_proba).astype(np.int32)
|
||||
cumulative_heads_ratio = np.cumsum(coin_tosses, axis=0) / np.arange(1, 10001).reshape(-1, 1)
|
||||
plt.figure(figsize=(8,3.5))
|
||||
plt.plot(cumulative_heads_ratio)
|
||||
plt.plot([0, 10000], [0.51, 0.51], "k--", linewidth=2, label="51%")
|
||||
plt.plot([0, 10000], [0.5, 0.5], "k-", label="50%")
|
||||
plt.xlabel("Number of coin tosses")
|
||||
plt.ylabel("Heads ratio")
|
||||
plt.legend(loc="lower right")
|
||||
plt.axis([0, 10000, 0.42, 0.58])
|
||||
save_fig("votingsimple")
|
||||
plt.show()
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mNameError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[1], line 2[0m
|
||||
[1;32m 1[0m heads_proba [38;5;241m=[39m [38;5;241m0.51[39m
|
||||
[0;32m----> 2[0m coin_tosses [38;5;241m=[39m ([43mnp[49m[38;5;241m.[39mrandom[38;5;241m.[39mrand([38;5;241m10000[39m, [38;5;241m10[39m) [38;5;241m<[39m heads_proba)[38;5;241m.[39mastype(np[38;5;241m.[39mint32)
|
||||
[1;32m 3[0m cumulative_heads_ratio [38;5;241m=[39m np[38;5;241m.[39mcumsum(coin_tosses, axis[38;5;241m=[39m[38;5;241m0[39m) [38;5;241m/[39m np[38;5;241m.[39marange([38;5;241m1[39m, [38;5;241m10001[39m)[38;5;241m.[39mreshape([38;5;241m-[39m[38;5;241m1[39m, [38;5;241m1[39m)
|
||||
[1;32m 4[0m plt[38;5;241m.[39mfigure(figsize[38;5;241m=[39m([38;5;241m8[39m,[38;5;241m3.5[39m))
|
||||
|
||||
[0;31mNameError[0m: name 'np' is not defined
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
heads_proba = 0.51
|
||||
coin_tosses = (np.random.rand(10000, 10) < heads_proba).astype(np.int32)
|
||||
cumulative_heads_ratio = np.cumsum(coin_tosses, axis=0) / np.arange(1, 10001).reshape(-1, 1)
|
||||
plt.figure(figsize=(8,3.5))
|
||||
plt.plot(cumulative_heads_ratio)
|
||||
plt.plot([0, 10000], [0.51, 0.51], "k--", linewidth=2, label="51%")
|
||||
plt.plot([0, 10000], [0.5, 0.5], "k-", label="50%")
|
||||
plt.xlabel("Number of coin tosses")
|
||||
plt.ylabel("Heads ratio")
|
||||
plt.legend(loc="lower right")
|
||||
plt.axis([0, 10000, 0.42, 0.58])
|
||||
save_fig("votingsimple")
|
||||
plt.show()
|
||||
------------------
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mNameError[0m Traceback (most recent call last)
|
||||
Input [0;32mIn [1][0m, in [0;36m<cell line: 2>[0;34m()[0m
|
||||
[1;32m 1[0m heads_proba [38;5;241m=[39m [38;5;241m0.51[39m
|
||||
[0;32m----> 2[0m coin_tosses [38;5;241m=[39m ([43mnp[49m[38;5;241m.[39mrandom[38;5;241m.[39mrand([38;5;241m10000[39m, [38;5;241m10[39m) [38;5;241m<[39m heads_proba)[38;5;241m.[39mastype(np[38;5;241m.[39mint32)
|
||||
[1;32m 3[0m cumulative_heads_ratio [38;5;241m=[39m np[38;5;241m.[39mcumsum(coin_tosses, axis[38;5;241m=[39m[38;5;241m0[39m) [38;5;241m/[39m np[38;5;241m.[39marange([38;5;241m1[39m, [38;5;241m10001[39m)[38;5;241m.[39mreshape([38;5;241m-[39m[38;5;241m1[39m, [38;5;241m1[39m)
|
||||
[1;32m 4[0m plt[38;5;241m.[39mfigure(figsize[38;5;241m=[39m([38;5;241m8[39m,[38;5;241m3.5[39m))
|
||||
|
||||
[0;31mNameError[0m: name 'np' is not defined
|
||||
NameError: name 'np' is not defined
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
n = 10
|
||||
x = np.random.normal(size=n)
|
||||
x = x - np.mean(x)
|
||||
y = 4+3*x+np.random.normal(size=n)
|
||||
y = y - np.mean(y)
|
||||
X = (np.vstack((x, y))).T
|
||||
print(X)
|
||||
Xpd = pd.DataFrame(X)
|
||||
print(Xpd)
|
||||
correlation_matrix = Xpd.corr()
|
||||
print(correlation_matrix)
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[3], line 2[0m
|
||||
[1;32m 1[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
[0;32m----> 2[0m [38;5;28;01mimport[39;00m [38;5;21;01mpandas[39;00m [38;5;28;01mas[39;00m [38;5;21;01mpd[39;00m
|
||||
[1;32m 3[0m n [38;5;241m=[39m [38;5;241m10[39m
|
||||
[1;32m 4[0m x [38;5;241m=[39m np[38;5;241m.[39mrandom[38;5;241m.[39mnormal(size[38;5;241m=[39mn)
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'pandas'
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
"""The sigmoid function (or the logistic curve) is a
|
||||
function that takes any real number, z, and outputs a number (0,1).
|
||||
It is useful in neural networks for assigning weights on a relative scale.
|
||||
The value z is the weighted sum of parameters involved in the learning algorithm."""
|
||||
|
||||
import numpy
|
||||
import matplotlib.pyplot as plt
|
||||
import math as mt
|
||||
|
||||
z = numpy.arange(-5, 5, .1)
|
||||
sigma_fn = numpy.vectorize(lambda z: 1/(1+numpy.exp(-z)))
|
||||
sigma = sigma_fn(z)
|
||||
|
||||
fig = plt.figure()
|
||||
ax = fig.add_subplot(111)
|
||||
ax.plot(z, sigma)
|
||||
ax.set_ylim([-0.1, 1.1])
|
||||
ax.set_xlim([-5,5])
|
||||
ax.grid(True)
|
||||
ax.set_xlabel('z')
|
||||
ax.set_title('sigmoid function')
|
||||
|
||||
plt.show()
|
||||
|
||||
"""Step Function"""
|
||||
z = numpy.arange(-5, 5, .02)
|
||||
step_fn = numpy.vectorize(lambda z: 1.0 if z >= 0.0 else 0.0)
|
||||
step = step_fn(z)
|
||||
|
||||
fig = plt.figure()
|
||||
ax = fig.add_subplot(111)
|
||||
ax.plot(z, step)
|
||||
ax.set_ylim([-0.5, 1.5])
|
||||
ax.set_xlim([-5,5])
|
||||
ax.grid(True)
|
||||
ax.set_xlabel('z')
|
||||
ax.set_title('step function')
|
||||
|
||||
plt.show()
|
||||
|
||||
"""Sine Function"""
|
||||
z = numpy.arange(-2*mt.pi, 2*mt.pi, 0.1)
|
||||
t = numpy.sin(z)
|
||||
|
||||
fig = plt.figure()
|
||||
ax = fig.add_subplot(111)
|
||||
ax.plot(z, t)
|
||||
ax.set_ylim([-1.0, 1.0])
|
||||
ax.set_xlim([-2*mt.pi,2*mt.pi])
|
||||
ax.grid(True)
|
||||
ax.set_xlabel('z')
|
||||
ax.set_title('sine function')
|
||||
|
||||
plt.show()
|
||||
|
||||
"""Plots a graph of the squashing function used by a rectified linear
|
||||
unit"""
|
||||
z = numpy.arange(-2, 2, .1)
|
||||
zero = numpy.zeros(len(z))
|
||||
y = numpy.max([zero, z], axis=0)
|
||||
|
||||
fig = plt.figure()
|
||||
ax = fig.add_subplot(111)
|
||||
ax.plot(z, y)
|
||||
ax.set_ylim([-2.0, 2.0])
|
||||
ax.set_xlim([-2.0, 2.0])
|
||||
ax.grid(True)
|
||||
ax.set_xlabel('z')
|
||||
ax.set_title('Rectified linear unit')
|
||||
|
||||
plt.show()
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[1], line 1[0m
|
||||
[0;32m----> 1[0m [43mget_ipython[49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43mrun_line_magic[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mmatplotlib[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43minline[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 3[0m [38;5;124;03m"""The sigmoid function (or the logistic curve) is a [39;00m
|
||||
[1;32m 4[0m [38;5;124;03mfunction that takes any real number, z, and outputs a number (0,1).[39;00m
|
||||
[1;32m 5[0m [38;5;124;03mIt is useful in neural networks for assigning weights on a relative scale.[39;00m
|
||||
[1;32m 6[0m [38;5;124;03mThe value z is the weighted sum of parameters involved in the learning algorithm."""[39;00m
|
||||
[1;32m 8[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2432[0m, in [0;36mInteractiveShell.run_line_magic[0;34m(self, magic_name, line, _stack_depth)[0m
|
||||
[1;32m 2430[0m kwargs[[38;5;124m'[39m[38;5;124mlocal_ns[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mget_local_scope(stack_depth)
|
||||
[1;32m 2431[0m [38;5;28;01mwith[39;00m [38;5;28mself[39m[38;5;241m.[39mbuiltin_trap:
|
||||
[0;32m-> 2432[0m result [38;5;241m=[39m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
[1;32m 2434[0m [38;5;66;03m# The code below prevents the output from being displayed[39;00m
|
||||
[1;32m 2435[0m [38;5;66;03m# when using magics with decorator @output_can_be_silenced[39;00m
|
||||
[1;32m 2436[0m [38;5;66;03m# when the last Python token in the expression is a ';'.[39;00m
|
||||
[1;32m 2437[0m [38;5;28;01mif[39;00m [38;5;28mgetattr[39m(fn, magic[38;5;241m.[39mMAGIC_OUTPUT_CAN_BE_SILENCED, [38;5;28;01mFalse[39;00m):
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99[0m, in [0;36mPylabMagics.matplotlib[0;34m(self, line)[0m
|
||||
[1;32m 97[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mAvailable matplotlib backends: [39m[38;5;132;01m%s[39;00m[38;5;124m"[39m [38;5;241m%[39m backends_list)
|
||||
[1;32m 98[0m [38;5;28;01melse[39;00m:
|
||||
[0;32m---> 99[0m gui, backend [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mshell[49m[38;5;241;43m.[39;49m[43menable_matplotlib[49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[38;5;241;43m.[39;49m[43mlower[49m[43m([49m[43m)[49m[43m [49m[38;5;28;43;01mif[39;49;00m[43m [49m[38;5;28;43misinstance[39;49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m,[49m[43m [49m[38;5;28;43mstr[39;49m[43m)[49m[43m [49m[38;5;28;43;01melse[39;49;00m[43m [49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m)[49m
|
||||
[1;32m 100[0m [38;5;28mself[39m[38;5;241m.[39m_show_matplotlib_backend(args[38;5;241m.[39mgui, backend)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3606[0m, in [0;36mInteractiveShell.enable_matplotlib[0;34m(self, gui)[0m
|
||||
[1;32m 3585[0m [38;5;28;01mdef[39;00m [38;5;21menable_matplotlib[39m([38;5;28mself[39m, gui[38;5;241m=[39m[38;5;28;01mNone[39;00m):
|
||||
[1;32m 3586[0m [38;5;250m [39m[38;5;124;03m"""Enable interactive matplotlib and inline figure support.[39;00m
|
||||
[1;32m 3587[0m
|
||||
[1;32m 3588[0m [38;5;124;03m This takes the following steps:[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 3604[0m [38;5;124;03m display figures inline.[39;00m
|
||||
[1;32m 3605[0m [38;5;124;03m """[39;00m
|
||||
[0;32m-> 3606[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib_inline[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackend_inline[39;00m [38;5;28;01mimport[39;00m configure_inline_support
|
||||
[1;32m 3608[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcore[39;00m [38;5;28;01mimport[39;00m pylabtools [38;5;28;01mas[39;00m pt
|
||||
[1;32m 3609[0m gui, backend [38;5;241m=[39m pt[38;5;241m.[39mfind_gui_and_backend(gui, [38;5;28mself[39m[38;5;241m.[39mpylab_gui_select)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/__init__.py:1[0m
|
||||
[0;32m----> 1[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m backend_inline, config [38;5;66;03m# noqa[39;00m
|
||||
[1;32m 2[0m __version__ [38;5;241m=[39m [38;5;124m"[39m[38;5;124m0.1.6[39m[38;5;124m"[39m [38;5;66;03m# noqa[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:6[0m
|
||||
[1;32m 1[0m [38;5;124;03m"""A matplotlib backend for publishing figures via display_data"""[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Copyright (c) IPython Development Team.[39;00m
|
||||
[1;32m 4[0m [38;5;66;03m# Distributed under the terms of the BSD 3-Clause License.[39;00m
|
||||
[0;32m----> 6[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m
|
||||
[1;32m 7[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m colors
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackends[39;00m [38;5;28;01mimport[39;00m backend_agg
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'matplotlib'
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
import numpy as np
|
||||
import numpy.linalg as la
|
||||
|
||||
import scipy.optimize as sopt
|
||||
|
||||
import matplotlib.pyplot as pt
|
||||
from mpl_toolkits.mplot3d import axes3d
|
||||
|
||||
def f(x):
|
||||
return 0.5*x[0]**2 + 2.5*x[1]**2
|
||||
|
||||
def df(x):
|
||||
return np.array([x[0], 5*x[1]])
|
||||
|
||||
fig = pt.figure()
|
||||
ax = fig.gca(projection="3d")
|
||||
|
||||
xmesh, ymesh = np.mgrid[-2:2:50j,-2:2:50j]
|
||||
fmesh = f(np.array([xmesh, ymesh]))
|
||||
ax.plot_surface(xmesh, ymesh, fmesh)
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[1], line 1[0m
|
||||
[0;32m----> 1[0m [43mget_ipython[49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43mrun_line_magic[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mmatplotlib[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43minline[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 3[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
[1;32m 4[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlinalg[39;00m [38;5;28;01mas[39;00m [38;5;21;01mla[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2432[0m, in [0;36mInteractiveShell.run_line_magic[0;34m(self, magic_name, line, _stack_depth)[0m
|
||||
[1;32m 2430[0m kwargs[[38;5;124m'[39m[38;5;124mlocal_ns[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mget_local_scope(stack_depth)
|
||||
[1;32m 2431[0m [38;5;28;01mwith[39;00m [38;5;28mself[39m[38;5;241m.[39mbuiltin_trap:
|
||||
[0;32m-> 2432[0m result [38;5;241m=[39m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
[1;32m 2434[0m [38;5;66;03m# The code below prevents the output from being displayed[39;00m
|
||||
[1;32m 2435[0m [38;5;66;03m# when using magics with decorator @output_can_be_silenced[39;00m
|
||||
[1;32m 2436[0m [38;5;66;03m# when the last Python token in the expression is a ';'.[39;00m
|
||||
[1;32m 2437[0m [38;5;28;01mif[39;00m [38;5;28mgetattr[39m(fn, magic[38;5;241m.[39mMAGIC_OUTPUT_CAN_BE_SILENCED, [38;5;28;01mFalse[39;00m):
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99[0m, in [0;36mPylabMagics.matplotlib[0;34m(self, line)[0m
|
||||
[1;32m 97[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mAvailable matplotlib backends: [39m[38;5;132;01m%s[39;00m[38;5;124m"[39m [38;5;241m%[39m backends_list)
|
||||
[1;32m 98[0m [38;5;28;01melse[39;00m:
|
||||
[0;32m---> 99[0m gui, backend [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mshell[49m[38;5;241;43m.[39;49m[43menable_matplotlib[49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[38;5;241;43m.[39;49m[43mlower[49m[43m([49m[43m)[49m[43m [49m[38;5;28;43;01mif[39;49;00m[43m [49m[38;5;28;43misinstance[39;49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m,[49m[43m [49m[38;5;28;43mstr[39;49m[43m)[49m[43m [49m[38;5;28;43;01melse[39;49;00m[43m [49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m)[49m
|
||||
[1;32m 100[0m [38;5;28mself[39m[38;5;241m.[39m_show_matplotlib_backend(args[38;5;241m.[39mgui, backend)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3606[0m, in [0;36mInteractiveShell.enable_matplotlib[0;34m(self, gui)[0m
|
||||
[1;32m 3585[0m [38;5;28;01mdef[39;00m [38;5;21menable_matplotlib[39m([38;5;28mself[39m, gui[38;5;241m=[39m[38;5;28;01mNone[39;00m):
|
||||
[1;32m 3586[0m [38;5;250m [39m[38;5;124;03m"""Enable interactive matplotlib and inline figure support.[39;00m
|
||||
[1;32m 3587[0m
|
||||
[1;32m 3588[0m [38;5;124;03m This takes the following steps:[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 3604[0m [38;5;124;03m display figures inline.[39;00m
|
||||
[1;32m 3605[0m [38;5;124;03m """[39;00m
|
||||
[0;32m-> 3606[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib_inline[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackend_inline[39;00m [38;5;28;01mimport[39;00m configure_inline_support
|
||||
[1;32m 3608[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcore[39;00m [38;5;28;01mimport[39;00m pylabtools [38;5;28;01mas[39;00m pt
|
||||
[1;32m 3609[0m gui, backend [38;5;241m=[39m pt[38;5;241m.[39mfind_gui_and_backend(gui, [38;5;28mself[39m[38;5;241m.[39mpylab_gui_select)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/__init__.py:1[0m
|
||||
[0;32m----> 1[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m backend_inline, config [38;5;66;03m# noqa[39;00m
|
||||
[1;32m 2[0m __version__ [38;5;241m=[39m [38;5;124m"[39m[38;5;124m0.1.6[39m[38;5;124m"[39m [38;5;66;03m# noqa[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:6[0m
|
||||
[1;32m 1[0m [38;5;124;03m"""A matplotlib backend for publishing figures via display_data"""[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Copyright (c) IPython Development Team.[39;00m
|
||||
[1;32m 4[0m [38;5;66;03m# Distributed under the terms of the BSD 3-Clause License.[39;00m
|
||||
[0;32m----> 6[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m
|
||||
[1;32m 7[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m colors
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackends[39;00m [38;5;28;01mimport[39;00m backend_agg
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'matplotlib'
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
import autograd.numpy as np
|
||||
from autograd import grad
|
||||
def f9(a): # Assume a is an array with 2 elements
|
||||
b = np.array([1.0,2.0])
|
||||
return a.dot(b)
|
||||
|
||||
f9_grad = grad(f9)
|
||||
|
||||
x = np.array([1.0,0.0])
|
||||
|
||||
print("The derivative of f9 is:",f9_grad(x))
|
||||
------------------
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mAttributeError[0m Traceback (most recent call last)
|
||||
Input [0;32mIn [23][0m, in [0;36m<cell line: 11>[0;34m()[0m
|
||||
[1;32m 7[0m f9_grad [38;5;241m=[39m grad(f9)
|
||||
[1;32m 9[0m x [38;5;241m=[39m np[38;5;241m.[39marray([[38;5;241m1.0[39m,[38;5;241m0.0[39m])
|
||||
[0;32m---> 11[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mThe derivative of f9 is:[39m[38;5;124m"[39m,[43mf9_grad[49m[43m([49m[43mx[49m[43m)[49m)
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/wrap_util.py:20[0m, in [0;36munary_to_nary.<locals>.nary_operator.<locals>.nary_f[0;34m(*args, **kwargs)[0m
|
||||
[1;32m 18[0m [38;5;28;01melse[39;00m:
|
||||
[1;32m 19[0m x [38;5;241m=[39m [38;5;28mtuple[39m(args[i] [38;5;28;01mfor[39;00m i [38;5;129;01min[39;00m argnum)
|
||||
[0;32m---> 20[0m [38;5;28;01mreturn[39;00m [43munary_operator[49m[43m([49m[43munary_f[49m[43m,[49m[43m [49m[43mx[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[43mnary_op_args[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mnary_op_kwargs[49m[43m)[49m
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/differential_operators.py:25[0m, in [0;36mgrad[0;34m(fun, x)[0m
|
||||
[1;32m 18[0m [38;5;129m@unary_to_nary[39m
|
||||
[1;32m 19[0m [38;5;28;01mdef[39;00m [38;5;21mgrad[39m(fun, x):
|
||||
[1;32m 20[0m [38;5;250m [39m[38;5;124;03m"""[39;00m
|
||||
[1;32m 21[0m [38;5;124;03m Returns a function which computes the gradient of `fun` with respect to[39;00m
|
||||
[1;32m 22[0m [38;5;124;03m positional argument number `argnum`. The returned function takes the same[39;00m
|
||||
[1;32m 23[0m [38;5;124;03m arguments as `fun`, but returns the gradient instead. The function `fun`[39;00m
|
||||
[1;32m 24[0m [38;5;124;03m should be scalar-valued. The gradient has the same type as the argument."""[39;00m
|
||||
[0;32m---> 25[0m vjp, ans [38;5;241m=[39m [43m_make_vjp[49m[43m([49m[43mfun[49m[43m,[49m[43m [49m[43mx[49m[43m)[49m
|
||||
[1;32m 26[0m [38;5;28;01mif[39;00m [38;5;129;01mnot[39;00m vspace(ans)[38;5;241m.[39msize [38;5;241m==[39m [38;5;241m1[39m:
|
||||
[1;32m 27[0m [38;5;28;01mraise[39;00m [38;5;167;01mTypeError[39;00m([38;5;124m"[39m[38;5;124mGrad only applies to real scalar-output functions. [39m[38;5;124m"[39m
|
||||
[1;32m 28[0m [38;5;124m"[39m[38;5;124mTry jacobian, elementwise_grad or holomorphic_grad.[39m[38;5;124m"[39m)
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/core.py:10[0m, in [0;36mmake_vjp[0;34m(fun, x)[0m
|
||||
[1;32m 8[0m [38;5;28;01mdef[39;00m [38;5;21mmake_vjp[39m(fun, x):
|
||||
[1;32m 9[0m start_node [38;5;241m=[39m VJPNode[38;5;241m.[39mnew_root()
|
||||
[0;32m---> 10[0m end_value, end_node [38;5;241m=[39m [43mtrace[49m[43m([49m[43mstart_node[49m[43m,[49m[43m [49m[43mfun[49m[43m,[49m[43m [49m[43mx[49m[43m)[49m
|
||||
[1;32m 11[0m [38;5;28;01mif[39;00m end_node [38;5;129;01mis[39;00m [38;5;28;01mNone[39;00m:
|
||||
[1;32m 12[0m [38;5;28;01mdef[39;00m [38;5;21mvjp[39m(g): [38;5;28;01mreturn[39;00m vspace(x)[38;5;241m.[39mzeros()
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/tracer.py:10[0m, in [0;36mtrace[0;34m(start_node, fun, x)[0m
|
||||
[1;32m 8[0m [38;5;28;01mwith[39;00m trace_stack[38;5;241m.[39mnew_trace() [38;5;28;01mas[39;00m t:
|
||||
[1;32m 9[0m start_box [38;5;241m=[39m new_box(x, t, start_node)
|
||||
[0;32m---> 10[0m end_box [38;5;241m=[39m [43mfun[49m[43m([49m[43mstart_box[49m[43m)[49m
|
||||
[1;32m 11[0m [38;5;28;01mif[39;00m isbox(end_box) [38;5;129;01mand[39;00m end_box[38;5;241m.[39m_trace [38;5;241m==[39m start_box[38;5;241m.[39m_trace:
|
||||
[1;32m 12[0m [38;5;28;01mreturn[39;00m end_box[38;5;241m.[39m_value, end_box[38;5;241m.[39m_node
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/wrap_util.py:15[0m, in [0;36munary_to_nary.<locals>.nary_operator.<locals>.nary_f.<locals>.unary_f[0;34m(x)[0m
|
||||
[1;32m 13[0m [38;5;28;01melse[39;00m:
|
||||
[1;32m 14[0m subargs [38;5;241m=[39m subvals(args, [38;5;28mzip[39m(argnum, x))
|
||||
[0;32m---> 15[0m [38;5;28;01mreturn[39;00m [43mfun[49m[43m([49m[38;5;241;43m*[39;49m[43msubargs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
|
||||
Input [0;32mIn [23][0m, in [0;36mf9[0;34m(a)[0m
|
||||
[1;32m 3[0m [38;5;28;01mdef[39;00m [38;5;21mf9[39m(a): [38;5;66;03m# Assume a is an array with 2 elements[39;00m
|
||||
[1;32m 4[0m b [38;5;241m=[39m np[38;5;241m.[39marray([[38;5;241m1.0[39m,[38;5;241m2.0[39m])
|
||||
[0;32m----> 5[0m [38;5;28;01mreturn[39;00m [43ma[49m[38;5;241;43m.[39;49m[43mdot[49m(b)
|
||||
|
||||
[0;31mAttributeError[0m: 'ArrayBox' object has no attribute 'dot'
|
||||
AttributeError: 'ArrayBox' object has no attribute 'dot'
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
import time
|
||||
import numpy as np
|
||||
import tensorflow as tf
|
||||
from matplotlib import image
|
||||
import matplotlib.pyplot as plt
|
||||
from sklearn.cluster import KMeans
|
||||
from IPython.display import display
|
||||
|
||||
np.random.seed(2021)
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[1], line 1[0m
|
||||
[0;32m----> 1[0m [43mget_ipython[49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43mrun_line_magic[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mmatplotlib[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43minline[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 3[0m [38;5;28;01mimport[39;00m [38;5;21;01mtime[39;00m
|
||||
[1;32m 4[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2432[0m, in [0;36mInteractiveShell.run_line_magic[0;34m(self, magic_name, line, _stack_depth)[0m
|
||||
[1;32m 2430[0m kwargs[[38;5;124m'[39m[38;5;124mlocal_ns[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mget_local_scope(stack_depth)
|
||||
[1;32m 2431[0m [38;5;28;01mwith[39;00m [38;5;28mself[39m[38;5;241m.[39mbuiltin_trap:
|
||||
[0;32m-> 2432[0m result [38;5;241m=[39m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
[1;32m 2434[0m [38;5;66;03m# The code below prevents the output from being displayed[39;00m
|
||||
[1;32m 2435[0m [38;5;66;03m# when using magics with decorator @output_can_be_silenced[39;00m
|
||||
[1;32m 2436[0m [38;5;66;03m# when the last Python token in the expression is a ';'.[39;00m
|
||||
[1;32m 2437[0m [38;5;28;01mif[39;00m [38;5;28mgetattr[39m(fn, magic[38;5;241m.[39mMAGIC_OUTPUT_CAN_BE_SILENCED, [38;5;28;01mFalse[39;00m):
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99[0m, in [0;36mPylabMagics.matplotlib[0;34m(self, line)[0m
|
||||
[1;32m 97[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mAvailable matplotlib backends: [39m[38;5;132;01m%s[39;00m[38;5;124m"[39m [38;5;241m%[39m backends_list)
|
||||
[1;32m 98[0m [38;5;28;01melse[39;00m:
|
||||
[0;32m---> 99[0m gui, backend [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mshell[49m[38;5;241;43m.[39;49m[43menable_matplotlib[49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[38;5;241;43m.[39;49m[43mlower[49m[43m([49m[43m)[49m[43m [49m[38;5;28;43;01mif[39;49;00m[43m [49m[38;5;28;43misinstance[39;49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m,[49m[43m [49m[38;5;28;43mstr[39;49m[43m)[49m[43m [49m[38;5;28;43;01melse[39;49;00m[43m [49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m)[49m
|
||||
[1;32m 100[0m [38;5;28mself[39m[38;5;241m.[39m_show_matplotlib_backend(args[38;5;241m.[39mgui, backend)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3606[0m, in [0;36mInteractiveShell.enable_matplotlib[0;34m(self, gui)[0m
|
||||
[1;32m 3585[0m [38;5;28;01mdef[39;00m [38;5;21menable_matplotlib[39m([38;5;28mself[39m, gui[38;5;241m=[39m[38;5;28;01mNone[39;00m):
|
||||
[1;32m 3586[0m [38;5;250m [39m[38;5;124;03m"""Enable interactive matplotlib and inline figure support.[39;00m
|
||||
[1;32m 3587[0m
|
||||
[1;32m 3588[0m [38;5;124;03m This takes the following steps:[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 3604[0m [38;5;124;03m display figures inline.[39;00m
|
||||
[1;32m 3605[0m [38;5;124;03m """[39;00m
|
||||
[0;32m-> 3606[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib_inline[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackend_inline[39;00m [38;5;28;01mimport[39;00m configure_inline_support
|
||||
[1;32m 3608[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcore[39;00m [38;5;28;01mimport[39;00m pylabtools [38;5;28;01mas[39;00m pt
|
||||
[1;32m 3609[0m gui, backend [38;5;241m=[39m pt[38;5;241m.[39mfind_gui_and_backend(gui, [38;5;28mself[39m[38;5;241m.[39mpylab_gui_select)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/__init__.py:1[0m
|
||||
[0;32m----> 1[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m backend_inline, config [38;5;66;03m# noqa[39;00m
|
||||
[1;32m 2[0m __version__ [38;5;241m=[39m [38;5;124m"[39m[38;5;124m0.1.6[39m[38;5;124m"[39m [38;5;66;03m# noqa[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:6[0m
|
||||
[1;32m 1[0m [38;5;124;03m"""A matplotlib backend for publishing figures via display_data"""[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Copyright (c) IPython Development Team.[39;00m
|
||||
[1;32m 4[0m [38;5;66;03m# Distributed under the terms of the BSD 3-Clause License.[39;00m
|
||||
[0;32m----> 6[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m
|
||||
[1;32m 7[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m colors
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackends[39;00m [38;5;28;01mimport[39;00m backend_agg
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'matplotlib'
|
||||
|
||||
@@ -0,0 +1,239 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
import time
|
||||
import numpy as np
|
||||
import tensorflow as tf
|
||||
from matplotlib import image
|
||||
import matplotlib.pyplot as plt
|
||||
from sklearn.cluster import KMeans
|
||||
from IPython.display import display
|
||||
|
||||
np.random.seed(2021)
|
||||
------------------
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mAttributeError[0m Traceback (most recent call last)
|
||||
Input [0;32mIn [1][0m, in [0;36m<cell line: 5>[0;34m()[0m
|
||||
[1;32m 3[0m [38;5;28;01mimport[39;00m [38;5;21;01mtime[39;00m
|
||||
[1;32m 4[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
[0;32m----> 5[0m [38;5;28;01mimport[39;00m [38;5;21;01mtensorflow[39;00m [38;5;28;01mas[39;00m [38;5;21;01mtf[39;00m
|
||||
[1;32m 6[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m image
|
||||
[1;32m 7[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mpyplot[39;00m [38;5;28;01mas[39;00m [38;5;21;01mplt[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/tensorflow/__init__.py:51[0m, in [0;36m<module>[0;34m[0m
|
||||
[1;32m 49[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m[38;5;21;01m_api[39;00m[38;5;21;01m.[39;00m[38;5;21;01mv2[39;00m [38;5;28;01mimport[39;00m autograph
|
||||
[1;32m 50[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m[38;5;21;01m_api[39;00m[38;5;21;01m.[39;00m[38;5;21;01mv2[39;00m [38;5;28;01mimport[39;00m bitwise
|
||||
[0;32m---> 51[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m[38;5;21;01m_api[39;00m[38;5;21;01m.[39;00m[38;5;21;01mv2[39;00m [38;5;28;01mimport[39;00m compat
|
||||
[1;32m 52[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m[38;5;21;01m_api[39;00m[38;5;21;01m.[39;00m[38;5;21;01mv2[39;00m [38;5;28;01mimport[39;00m config
|
||||
[1;32m 53[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m[38;5;21;01m_api[39;00m[38;5;21;01m.[39;00m[38;5;21;01mv2[39;00m [38;5;28;01mimport[39;00m data
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/tensorflow/_api/v2/compat/__init__.py:37[0m, in [0;36m<module>[0;34m[0m
|
||||
[1;32m 3[0m [38;5;124;03m"""Compatibility functions.[39;00m
|
||||
[1;32m 4[0m
|
||||
[1;32m 5[0m [38;5;124;03mThe `tf.compat` module contains two sets of compatibility functions.[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 32[0m
|
||||
[1;32m 33[0m [38;5;124;03m"""[39;00m
|
||||
[1;32m 35[0m [38;5;28;01mimport[39;00m [38;5;21;01msys[39;00m [38;5;28;01mas[39;00m [38;5;21;01m_sys[39;00m
|
||||
[0;32m---> 37[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m v1
|
||||
[1;32m 38[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m v2
|
||||
[1;32m 39[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtensorflow[39;00m[38;5;21;01m.[39;00m[38;5;21;01mpython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcompat[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcompat[39;00m [38;5;28;01mimport[39;00m forward_compatibility_horizon
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/tensorflow/_api/v2/compat/v1/__init__.py:30[0m, in [0;36m<module>[0;34m[0m
|
||||
[1;32m 28[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m autograph
|
||||
[1;32m 29[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m bitwise
|
||||
[0;32m---> 30[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m compat
|
||||
[1;32m 31[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m config
|
||||
[1;32m 32[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m data
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/tensorflow/_api/v2/compat/v1/compat/__init__.py:37[0m, in [0;36m<module>[0;34m[0m
|
||||
[1;32m 3[0m [38;5;124;03m"""Compatibility functions.[39;00m
|
||||
[1;32m 4[0m
|
||||
[1;32m 5[0m [38;5;124;03mThe `tf.compat` module contains two sets of compatibility functions.[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 32[0m
|
||||
[1;32m 33[0m [38;5;124;03m"""[39;00m
|
||||
[1;32m 35[0m [38;5;28;01mimport[39;00m [38;5;21;01msys[39;00m [38;5;28;01mas[39;00m [38;5;21;01m_sys[39;00m
|
||||
[0;32m---> 37[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m v1
|
||||
[1;32m 38[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m v2
|
||||
[1;32m 39[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtensorflow[39;00m[38;5;21;01m.[39;00m[38;5;21;01mpython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcompat[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcompat[39;00m [38;5;28;01mimport[39;00m forward_compatibility_horizon
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/tensorflow/_api/v2/compat/v1/compat/v1/__init__.py:47[0m, in [0;36m<module>[0;34m[0m
|
||||
[1;32m 45[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtensorflow[39;00m[38;5;21;01m.[39;00m[38;5;21;01m_api[39;00m[38;5;21;01m.[39;00m[38;5;21;01mv2[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcompat[39;00m[38;5;21;01m.[39;00m[38;5;21;01mv1[39;00m [38;5;28;01mimport[39;00m layers
|
||||
[1;32m 46[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtensorflow[39;00m[38;5;21;01m.[39;00m[38;5;21;01m_api[39;00m[38;5;21;01m.[39;00m[38;5;21;01mv2[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcompat[39;00m[38;5;21;01m.[39;00m[38;5;21;01mv1[39;00m [38;5;28;01mimport[39;00m linalg
|
||||
[0;32m---> 47[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtensorflow[39;00m[38;5;21;01m.[39;00m[38;5;21;01m_api[39;00m[38;5;21;01m.[39;00m[38;5;21;01mv2[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcompat[39;00m[38;5;21;01m.[39;00m[38;5;21;01mv1[39;00m [38;5;28;01mimport[39;00m lite
|
||||
[1;32m 48[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtensorflow[39;00m[38;5;21;01m.[39;00m[38;5;21;01m_api[39;00m[38;5;21;01m.[39;00m[38;5;21;01mv2[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcompat[39;00m[38;5;21;01m.[39;00m[38;5;21;01mv1[39;00m [38;5;28;01mimport[39;00m logging
|
||||
[1;32m 49[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtensorflow[39;00m[38;5;21;01m.[39;00m[38;5;21;01m_api[39;00m[38;5;21;01m.[39;00m[38;5;21;01mv2[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcompat[39;00m[38;5;21;01m.[39;00m[38;5;21;01mv1[39;00m [38;5;28;01mimport[39;00m lookup
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/tensorflow/_api/v2/compat/v1/lite/__init__.py:9[0m, in [0;36m<module>[0;34m[0m
|
||||
[1;32m 6[0m [38;5;28;01mimport[39;00m [38;5;21;01msys[39;00m [38;5;28;01mas[39;00m [38;5;21;01m_sys[39;00m
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m constants
|
||||
[0;32m----> 9[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m experimental
|
||||
[1;32m 10[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtensorflow[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlite[39;00m[38;5;21;01m.[39;00m[38;5;21;01mpython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlite[39;00m [38;5;28;01mimport[39;00m Interpreter
|
||||
[1;32m 11[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtensorflow[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlite[39;00m[38;5;21;01m.[39;00m[38;5;21;01mpython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlite[39;00m [38;5;28;01mimport[39;00m OpHint
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/tensorflow/_api/v2/compat/v1/lite/experimental/__init__.py:8[0m, in [0;36m<module>[0;34m[0m
|
||||
[1;32m 3[0m [38;5;124;03m"""Public API for tf.lite.experimental namespace.[39;00m
|
||||
[1;32m 4[0m [38;5;124;03m"""[39;00m
|
||||
[1;32m 6[0m [38;5;28;01mimport[39;00m [38;5;21;01msys[39;00m [38;5;28;01mas[39;00m [38;5;21;01m_sys[39;00m
|
||||
[0;32m----> 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m authoring
|
||||
[1;32m 9[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtensorflow[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlite[39;00m[38;5;21;01m.[39;00m[38;5;21;01mpython[39;00m[38;5;21;01m.[39;00m[38;5;21;01manalyzer[39;00m [38;5;28;01mimport[39;00m ModelAnalyzer [38;5;28;01mas[39;00m Analyzer
|
||||
[1;32m 10[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtensorflow[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlite[39;00m[38;5;21;01m.[39;00m[38;5;21;01mpython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlite[39;00m [38;5;28;01mimport[39;00m OpResolverType
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/tensorflow/_api/v2/compat/v1/lite/experimental/authoring/__init__.py:8[0m, in [0;36m<module>[0;34m[0m
|
||||
[1;32m 3[0m [38;5;124;03m"""Public API for tf.lite.experimental.authoring namespace.[39;00m
|
||||
[1;32m 4[0m [38;5;124;03m"""[39;00m
|
||||
[1;32m 6[0m [38;5;28;01mimport[39;00m [38;5;21;01msys[39;00m [38;5;28;01mas[39;00m [38;5;21;01m_sys[39;00m
|
||||
[0;32m----> 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtensorflow[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlite[39;00m[38;5;21;01m.[39;00m[38;5;21;01mpython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mauthoring[39;00m[38;5;21;01m.[39;00m[38;5;21;01mauthoring[39;00m [38;5;28;01mimport[39;00m compatible
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/tensorflow/lite/python/authoring/authoring.py:43[0m, in [0;36m<module>[0;34m[0m
|
||||
[1;32m 39[0m [38;5;28;01mimport[39;00m [38;5;21;01mfunctools[39;00m
|
||||
[1;32m 42[0m [38;5;66;03m# pylint: disable=g-import-not-at-top[39;00m
|
||||
[0;32m---> 43[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtensorflow[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlite[39;00m[38;5;21;01m.[39;00m[38;5;21;01mpython[39;00m [38;5;28;01mimport[39;00m convert
|
||||
[1;32m 44[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtensorflow[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlite[39;00m[38;5;21;01m.[39;00m[38;5;21;01mpython[39;00m [38;5;28;01mimport[39;00m lite
|
||||
[1;32m 45[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtensorflow[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlite[39;00m[38;5;21;01m.[39;00m[38;5;21;01mpython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mmetrics[39;00m [38;5;28;01mimport[39;00m converter_error_data_pb2
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/tensorflow/lite/python/convert.py:29[0m, in [0;36m<module>[0;34m[0m
|
||||
[1;32m 26[0m [38;5;28;01mimport[39;00m [38;5;21;01msix[39;00m
|
||||
[1;32m 28[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtensorflow[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlite[39;00m[38;5;21;01m.[39;00m[38;5;21;01mpython[39;00m [38;5;28;01mimport[39;00m lite_constants
|
||||
[0;32m---> 29[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtensorflow[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlite[39;00m[38;5;21;01m.[39;00m[38;5;21;01mpython[39;00m [38;5;28;01mimport[39;00m util
|
||||
[1;32m 30[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtensorflow[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlite[39;00m[38;5;21;01m.[39;00m[38;5;21;01mpython[39;00m [38;5;28;01mimport[39;00m wrap_toco
|
||||
[1;32m 31[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtensorflow[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlite[39;00m[38;5;21;01m.[39;00m[38;5;21;01mpython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mconvert_phase[39;00m [38;5;28;01mimport[39;00m Component
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/tensorflow/lite/python/util.py:51[0m, in [0;36m<module>[0;34m[0m
|
||||
[1;32m 47[0m [38;5;66;03m# Jax functions used by TFLite[39;00m
|
||||
[1;32m 48[0m [38;5;66;03m# pylint: disable=g-import-not-at-top[39;00m
|
||||
[1;32m 49[0m [38;5;66;03m# pylint: disable=unused-import[39;00m
|
||||
[1;32m 50[0m [38;5;28;01mtry[39;00m:
|
||||
[0;32m---> 51[0m [38;5;28;01mfrom[39;00m [38;5;21;01mjax[39;00m [38;5;28;01mimport[39;00m xla_computation [38;5;28;01mas[39;00m _xla_computation
|
||||
[1;32m 52[0m [38;5;28;01mexcept[39;00m [38;5;167;01mImportError[39;00m:
|
||||
[1;32m 53[0m _xla_computation [38;5;241m=[39m [38;5;28;01mNone[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/jax/__init__.py:116[0m, in [0;36m<module>[0;34m[0m
|
||||
[1;32m 40[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m[38;5;21;01m_src[39;00m[38;5;21;01m.[39;00m[38;5;21;01mconfig[39;00m [38;5;28;01mimport[39;00m (
|
||||
[1;32m 41[0m config [38;5;28;01mas[39;00m config,
|
||||
[1;32m 42[0m enable_checks [38;5;28;01mas[39;00m enable_checks,
|
||||
[0;32m (...)[0m
|
||||
[1;32m 51[0m numpy_rank_promotion [38;5;28;01mas[39;00m numpy_rank_promotion,
|
||||
[1;32m 52[0m )
|
||||
[1;32m 53[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m[38;5;21;01m_src[39;00m[38;5;21;01m.[39;00m[38;5;21;01mapi[39;00m [38;5;28;01mimport[39;00m (
|
||||
[1;32m 54[0m ad, [38;5;66;03m# TODO(phawkins): update users to avoid this.[39;00m
|
||||
[1;32m 55[0m checkpoint [38;5;28;01mas[39;00m checkpoint,
|
||||
[0;32m (...)[0m
|
||||
[1;32m 114[0m xla_computation [38;5;28;01mas[39;00m xla_computation,
|
||||
[1;32m 115[0m )
|
||||
[0;32m--> 116[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m[38;5;21;01mexperimental[39;00m[38;5;21;01m.[39;00m[38;5;21;01mmaps[39;00m [38;5;28;01mimport[39;00m soft_pmap [38;5;28;01mas[39;00m soft_pmap
|
||||
[1;32m 117[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m[38;5;21;01mversion[39;00m [38;5;28;01mimport[39;00m __version__ [38;5;28;01mas[39;00m __version__
|
||||
[1;32m 119[0m [38;5;66;03m# These submodules are separate because they are in an import cycle with[39;00m
|
||||
[1;32m 120[0m [38;5;66;03m# jax and rely on the names imported above.[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/jax/experimental/maps.py:26[0m, in [0;36m<module>[0;34m[0m
|
||||
[1;32m 23[0m [38;5;28;01mfrom[39;00m [38;5;21;01mfunctools[39;00m [38;5;28;01mimport[39;00m wraps, partial, partialmethod
|
||||
[1;32m 24[0m [38;5;28;01mfrom[39;00m [38;5;21;01menum[39;00m [38;5;28;01mimport[39;00m Enum
|
||||
[0;32m---> 26[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m[38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m numpy [38;5;28;01mas[39;00m jnp
|
||||
[1;32m 27[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m[38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m core
|
||||
[1;32m 28[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m[38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m linear_util [38;5;28;01mas[39;00m lu
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/jax/numpy/__init__.py:19[0m, in [0;36m<module>[0;34m[0m
|
||||
[1;32m 1[0m [38;5;66;03m# Copyright 2018 Google LLC[39;00m
|
||||
[1;32m 2[0m [38;5;66;03m#[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Licensed under the Apache License, Version 2.0 (the "License");[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 17[0m
|
||||
[1;32m 18[0m [38;5;66;03m# flake8: noqa: F401[39;00m
|
||||
[0;32m---> 19[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m fft [38;5;28;01mas[39;00m fft
|
||||
[1;32m 20[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m linalg [38;5;28;01mas[39;00m linalg
|
||||
[1;32m 22[0m [38;5;28;01mfrom[39;00m [38;5;21;01mjax[39;00m[38;5;21;01m.[39;00m[38;5;21;01minterpreters[39;00m[38;5;21;01m.[39;00m[38;5;21;01mxla[39;00m [38;5;28;01mimport[39;00m DeviceArray [38;5;28;01mas[39;00m DeviceArray
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/jax/numpy/fft.py:17[0m, in [0;36m<module>[0;34m[0m
|
||||
[1;32m 1[0m [38;5;66;03m# Copyright 2020 Google LLC[39;00m
|
||||
[1;32m 2[0m [38;5;66;03m#[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Licensed under the Apache License, Version 2.0 (the "License");[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 14[0m
|
||||
[1;32m 15[0m [38;5;66;03m# flake8: noqa: F401[39;00m
|
||||
[0;32m---> 17[0m [38;5;28;01mfrom[39;00m [38;5;21;01mjax[39;00m[38;5;21;01m.[39;00m[38;5;21;01m_src[39;00m[38;5;21;01m.[39;00m[38;5;21;01mnumpy[39;00m[38;5;21;01m.[39;00m[38;5;21;01mfft[39;00m [38;5;28;01mimport[39;00m (
|
||||
[1;32m 18[0m ifft [38;5;28;01mas[39;00m ifft,
|
||||
[1;32m 19[0m ifft2 [38;5;28;01mas[39;00m ifft2,
|
||||
[1;32m 20[0m ifftn [38;5;28;01mas[39;00m ifftn,
|
||||
[1;32m 21[0m ifftshift [38;5;28;01mas[39;00m ifftshift,
|
||||
[1;32m 22[0m ihfft [38;5;28;01mas[39;00m ihfft,
|
||||
[1;32m 23[0m irfft [38;5;28;01mas[39;00m irfft,
|
||||
[1;32m 24[0m irfft2 [38;5;28;01mas[39;00m irfft2,
|
||||
[1;32m 25[0m irfftn [38;5;28;01mas[39;00m irfftn,
|
||||
[1;32m 26[0m fft [38;5;28;01mas[39;00m fft,
|
||||
[1;32m 27[0m fft2 [38;5;28;01mas[39;00m fft2,
|
||||
[1;32m 28[0m fftfreq [38;5;28;01mas[39;00m fftfreq,
|
||||
[1;32m 29[0m fftn [38;5;28;01mas[39;00m fftn,
|
||||
[1;32m 30[0m fftshift [38;5;28;01mas[39;00m fftshift,
|
||||
[1;32m 31[0m hfft [38;5;28;01mas[39;00m hfft,
|
||||
[1;32m 32[0m rfft [38;5;28;01mas[39;00m rfft,
|
||||
[1;32m 33[0m rfft2 [38;5;28;01mas[39;00m rfft2,
|
||||
[1;32m 34[0m rfftfreq [38;5;28;01mas[39;00m rfftfreq,
|
||||
[1;32m 35[0m rfftn [38;5;28;01mas[39;00m rfftn,
|
||||
[1;32m 36[0m )
|
||||
[1;32m 38[0m [38;5;66;03m# Module initialization is encapsulated in a function to avoid accidental[39;00m
|
||||
[1;32m 39[0m [38;5;66;03m# namespace pollution.[39;00m
|
||||
[1;32m 40[0m _NOT_IMPLEMENTED [38;5;241m=[39m []
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/jax/_src/numpy/fft.py:19[0m, in [0;36m<module>[0;34m[0m
|
||||
[1;32m 16[0m [38;5;28;01mimport[39;00m [38;5;21;01moperator[39;00m
|
||||
[1;32m 17[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
[0;32m---> 19[0m [38;5;28;01mfrom[39;00m [38;5;21;01mjax[39;00m [38;5;28;01mimport[39;00m lax
|
||||
[1;32m 20[0m [38;5;28;01mfrom[39;00m [38;5;21;01mjax[39;00m[38;5;21;01m.[39;00m[38;5;21;01m_src[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlib[39;00m [38;5;28;01mimport[39;00m xla_client
|
||||
[1;32m 21[0m [38;5;28;01mfrom[39;00m [38;5;21;01mjax[39;00m[38;5;21;01m.[39;00m[38;5;21;01m_src[39;00m[38;5;21;01m.[39;00m[38;5;21;01mutil[39;00m [38;5;28;01mimport[39;00m safe_zip
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/jax/lax/__init__.py:332[0m, in [0;36m<module>[0;34m[0m
|
||||
[1;32m 299[0m [38;5;28;01mfrom[39;00m [38;5;21;01mjax[39;00m[38;5;21;01m.[39;00m[38;5;21;01m_src[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlax[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlax[39;00m [38;5;28;01mimport[39;00m (_reduce_sum, _reduce_max, _reduce_min, _reduce_or,
|
||||
[1;32m 300[0m _reduce_and, _reduce_window_sum, _reduce_window_max,
|
||||
[1;32m 301[0m _reduce_window_min, _reduce_window_prod,
|
||||
[0;32m (...)[0m
|
||||
[1;32m 306[0m _upcast_fp16_for_computation, _broadcasting_shape_rule,
|
||||
[1;32m 307[0m _eye, _tri, _delta, _ones, _zeros, _dilate_shape)
|
||||
[1;32m 308[0m [38;5;28;01mfrom[39;00m [38;5;21;01mjax[39;00m[38;5;21;01m.[39;00m[38;5;21;01m_src[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlax[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcontrol_flow[39;00m [38;5;28;01mimport[39;00m (
|
||||
[1;32m 309[0m associative_scan [38;5;28;01mas[39;00m associative_scan,
|
||||
[1;32m 310[0m cond [38;5;28;01mas[39;00m cond,
|
||||
[0;32m (...)[0m
|
||||
[1;32m 330[0m while_p [38;5;28;01mas[39;00m while_p,
|
||||
[1;32m 331[0m )
|
||||
[0;32m--> 332[0m [38;5;28;01mfrom[39;00m [38;5;21;01mjax[39;00m[38;5;21;01m.[39;00m[38;5;21;01m_src[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlax[39;00m[38;5;21;01m.[39;00m[38;5;21;01mfft[39;00m [38;5;28;01mimport[39;00m (
|
||||
[1;32m 333[0m fft [38;5;28;01mas[39;00m fft,
|
||||
[1;32m 334[0m fft_p [38;5;28;01mas[39;00m fft_p,
|
||||
[1;32m 335[0m )
|
||||
[1;32m 336[0m [38;5;28;01mfrom[39;00m [38;5;21;01mjax[39;00m[38;5;21;01m.[39;00m[38;5;21;01m_src[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlax[39;00m[38;5;21;01m.[39;00m[38;5;21;01mparallel[39;00m [38;5;28;01mimport[39;00m (
|
||||
[1;32m 337[0m all_gather [38;5;28;01mas[39;00m all_gather,
|
||||
[1;32m 338[0m all_to_all [38;5;28;01mas[39;00m all_to_all,
|
||||
[0;32m (...)[0m
|
||||
[1;32m 355[0m xeinsum [38;5;28;01mas[39;00m xeinsum,
|
||||
[1;32m 356[0m )
|
||||
[1;32m 357[0m [38;5;28;01mfrom[39;00m [38;5;21;01mjax[39;00m[38;5;21;01m.[39;00m[38;5;21;01m_src[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlax[39;00m[38;5;21;01m.[39;00m[38;5;21;01mother[39;00m [38;5;28;01mimport[39;00m (
|
||||
[1;32m 358[0m conv_general_dilated_patches [38;5;28;01mas[39;00m conv_general_dilated_patches
|
||||
[1;32m 359[0m )
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/jax/_src/lax/fft.py:145[0m, in [0;36m<module>[0;34m[0m
|
||||
[1;32m 143[0m batching[38;5;241m.[39mprimitive_batchers[fft_p] [38;5;241m=[39m fft_batching_rule
|
||||
[1;32m 144[0m [38;5;28;01mif[39;00m pocketfft:
|
||||
[0;32m--> 145[0m xla[38;5;241m.[39mbackend_specific_translations[[38;5;124m'[39m[38;5;124mcpu[39m[38;5;124m'[39m][fft_p] [38;5;241m=[39m [43mpocketfft[49m[38;5;241;43m.[39;49m[43mpocketfft[49m
|
||||
|
||||
[0;31mAttributeError[0m: module 'jaxlib.pocketfft' has no attribute 'pocketfft'
|
||||
AttributeError: module 'jaxlib.pocketfft' has no attribute 'pocketfft'
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
x = np.random.rand(100,1)
|
||||
y = 2.0+5*x*x+0.1*np.random.randn(100,1)
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mNameError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[1], line 1[0m
|
||||
[0;32m----> 1[0m x [38;5;241m=[39m [43mnp[49m[38;5;241m.[39mrandom[38;5;241m.[39mrand([38;5;241m100[39m,[38;5;241m1[39m)
|
||||
[1;32m 2[0m y [38;5;241m=[39m [38;5;241m2.0[39m[38;5;241m+[39m[38;5;241m5[39m[38;5;241m*[39mx[38;5;241m*[39mx[38;5;241m+[39m[38;5;241m0.1[39m[38;5;241m*[39mnp[38;5;241m.[39mrandom[38;5;241m.[39mrandn([38;5;241m100[39m,[38;5;241m1[39m)
|
||||
|
||||
[0;31mNameError[0m: name 'np' is not defined
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
x = np.random.rand(100,1)
|
||||
y = 2.0+5*x*x+0.1*np.random.randn(100,1)
|
||||
------------------
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mNameError[0m Traceback (most recent call last)
|
||||
Input [0;32mIn [1][0m, in [0;36m<cell line: 1>[0;34m()[0m
|
||||
[0;32m----> 1[0m x [38;5;241m=[39m [43mnp[49m[38;5;241m.[39mrandom[38;5;241m.[39mrand([38;5;241m100[39m,[38;5;241m1[39m)
|
||||
[1;32m 2[0m y [38;5;241m=[39m [38;5;241m2.0[39m[38;5;241m+[39m[38;5;241m5[39m[38;5;241m*[39mx[38;5;241m*[39mx[38;5;241m+[39m[38;5;241m0.1[39m[38;5;241m*[39mnp[38;5;241m.[39mrandom[38;5;241m.[39mrandn([38;5;241m100[39m,[38;5;241m1[39m)
|
||||
|
||||
[0;31mNameError[0m: name 'np' is not defined
|
||||
NameError: name 'np' is not defined
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from scipy import sparse
|
||||
eye = np.eye(4)
|
||||
print(eye)
|
||||
sparse_mtx = sparse.csr_matrix(eye)
|
||||
print(sparse_mtx)
|
||||
x = np.linspace(-10,10,100)
|
||||
y = np.sin(x)
|
||||
plt.plot(x,y,marker='x')
|
||||
plt.show()
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[15], line 1[0m
|
||||
[0;32m----> 1[0m [43mget_ipython[49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43mrun_line_magic[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mmatplotlib[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43minline[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 3[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
[1;32m 4[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mpyplot[39;00m [38;5;28;01mas[39;00m [38;5;21;01mplt[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2432[0m, in [0;36mInteractiveShell.run_line_magic[0;34m(self, magic_name, line, _stack_depth)[0m
|
||||
[1;32m 2430[0m kwargs[[38;5;124m'[39m[38;5;124mlocal_ns[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mget_local_scope(stack_depth)
|
||||
[1;32m 2431[0m [38;5;28;01mwith[39;00m [38;5;28mself[39m[38;5;241m.[39mbuiltin_trap:
|
||||
[0;32m-> 2432[0m result [38;5;241m=[39m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
[1;32m 2434[0m [38;5;66;03m# The code below prevents the output from being displayed[39;00m
|
||||
[1;32m 2435[0m [38;5;66;03m# when using magics with decorator @output_can_be_silenced[39;00m
|
||||
[1;32m 2436[0m [38;5;66;03m# when the last Python token in the expression is a ';'.[39;00m
|
||||
[1;32m 2437[0m [38;5;28;01mif[39;00m [38;5;28mgetattr[39m(fn, magic[38;5;241m.[39mMAGIC_OUTPUT_CAN_BE_SILENCED, [38;5;28;01mFalse[39;00m):
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99[0m, in [0;36mPylabMagics.matplotlib[0;34m(self, line)[0m
|
||||
[1;32m 97[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mAvailable matplotlib backends: [39m[38;5;132;01m%s[39;00m[38;5;124m"[39m [38;5;241m%[39m backends_list)
|
||||
[1;32m 98[0m [38;5;28;01melse[39;00m:
|
||||
[0;32m---> 99[0m gui, backend [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mshell[49m[38;5;241;43m.[39;49m[43menable_matplotlib[49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[38;5;241;43m.[39;49m[43mlower[49m[43m([49m[43m)[49m[43m [49m[38;5;28;43;01mif[39;49;00m[43m [49m[38;5;28;43misinstance[39;49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m,[49m[43m [49m[38;5;28;43mstr[39;49m[43m)[49m[43m [49m[38;5;28;43;01melse[39;49;00m[43m [49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m)[49m
|
||||
[1;32m 100[0m [38;5;28mself[39m[38;5;241m.[39m_show_matplotlib_backend(args[38;5;241m.[39mgui, backend)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3606[0m, in [0;36mInteractiveShell.enable_matplotlib[0;34m(self, gui)[0m
|
||||
[1;32m 3585[0m [38;5;28;01mdef[39;00m [38;5;21menable_matplotlib[39m([38;5;28mself[39m, gui[38;5;241m=[39m[38;5;28;01mNone[39;00m):
|
||||
[1;32m 3586[0m [38;5;250m [39m[38;5;124;03m"""Enable interactive matplotlib and inline figure support.[39;00m
|
||||
[1;32m 3587[0m
|
||||
[1;32m 3588[0m [38;5;124;03m This takes the following steps:[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 3604[0m [38;5;124;03m display figures inline.[39;00m
|
||||
[1;32m 3605[0m [38;5;124;03m """[39;00m
|
||||
[0;32m-> 3606[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib_inline[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackend_inline[39;00m [38;5;28;01mimport[39;00m configure_inline_support
|
||||
[1;32m 3608[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcore[39;00m [38;5;28;01mimport[39;00m pylabtools [38;5;28;01mas[39;00m pt
|
||||
[1;32m 3609[0m gui, backend [38;5;241m=[39m pt[38;5;241m.[39mfind_gui_and_backend(gui, [38;5;28mself[39m[38;5;241m.[39mpylab_gui_select)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/__init__.py:1[0m
|
||||
[0;32m----> 1[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m backend_inline, config [38;5;66;03m# noqa[39;00m
|
||||
[1;32m 2[0m __version__ [38;5;241m=[39m [38;5;124m"[39m[38;5;124m0.1.6[39m[38;5;124m"[39m [38;5;66;03m# noqa[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:6[0m
|
||||
[1;32m 1[0m [38;5;124;03m"""A matplotlib backend for publishing figures via display_data"""[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Copyright (c) IPython Development Team.[39;00m
|
||||
[1;32m 4[0m [38;5;66;03m# Distributed under the terms of the BSD 3-Clause License.[39;00m
|
||||
[0;32m----> 6[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m
|
||||
[1;32m 7[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m colors
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackends[39;00m [38;5;28;01mimport[39;00m backend_agg
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'matplotlib'
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
import numpy as np
|
||||
x = np.log(np.array([4.0, 7.0, 8.0])
|
||||
print(x)
|
||||
------------------
|
||||
|
||||
[0;36m File [0;32m"<ipython-input-6-f6d7a289d493>"[0;36m, line [0;32m3[0m
|
||||
[0;31m print(x)[0m
|
||||
[0m ^[0m
|
||||
[0;31mSyntaxError[0m[0;31m:[0m invalid syntax
|
||||
|
||||
SyntaxError: invalid syntax (<ipython-input-6-f6d7a289d493>, line 3)
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
from mpl_toolkits.mplot3d import Axes3D
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib import cm
|
||||
from matplotlib.ticker import LinearLocator, FormatStrFormatter
|
||||
import numpy as np
|
||||
from random import random, seed
|
||||
|
||||
fig = plt.figure()
|
||||
ax = fig.gca(projection='3d')
|
||||
|
||||
# Make data.
|
||||
x = np.arange(0, 1, 0.05)
|
||||
y = np.arange(0, 1, 0.05)
|
||||
x, y = np.meshgrid(x,y)
|
||||
|
||||
|
||||
def FrankeFunction(x,y):
|
||||
term1 = 0.75*np.exp(-(0.25*(9*x-2)**2) - 0.25*((9*y-2)**2))
|
||||
term2 = 0.75*np.exp(-((9*x+1)**2)/49.0 - 0.1*(9*y+1))
|
||||
term3 = 0.5*np.exp(-(9*x-7)**2/4.0 - 0.25*((9*y-3)**2))
|
||||
term4 = -0.2*np.exp(-(9*x-4)**2 - (9*y-7)**2)
|
||||
return term1 + term2 + term3 + term4
|
||||
|
||||
|
||||
z = FrankeFunction(x, y)
|
||||
|
||||
# Plot the surface.
|
||||
surf = ax.plot_surface(x, y, z, cmap=cm.coolwarm,
|
||||
linewidth=0, antialiased=False)
|
||||
|
||||
# Customize the z axis.
|
||||
ax.set_zlim(-0.10, 1.40)
|
||||
ax.zaxis.set_major_locator(LinearLocator(10))
|
||||
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
|
||||
|
||||
# Add a color bar which maps values to colors.
|
||||
fig.colorbar(surf, shrink=0.5, aspect=5)
|
||||
|
||||
plt.show()
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[1], line 1[0m
|
||||
[0;32m----> 1[0m [43mget_ipython[49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43mrun_line_magic[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mmatplotlib[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43minline[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 3[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmpl_toolkits[39;00m[38;5;21;01m.[39;00m[38;5;21;01mmplot3d[39;00m [38;5;28;01mimport[39;00m Axes3D
|
||||
[1;32m 4[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mpyplot[39;00m [38;5;28;01mas[39;00m [38;5;21;01mplt[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2432[0m, in [0;36mInteractiveShell.run_line_magic[0;34m(self, magic_name, line, _stack_depth)[0m
|
||||
[1;32m 2430[0m kwargs[[38;5;124m'[39m[38;5;124mlocal_ns[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mget_local_scope(stack_depth)
|
||||
[1;32m 2431[0m [38;5;28;01mwith[39;00m [38;5;28mself[39m[38;5;241m.[39mbuiltin_trap:
|
||||
[0;32m-> 2432[0m result [38;5;241m=[39m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
[1;32m 2434[0m [38;5;66;03m# The code below prevents the output from being displayed[39;00m
|
||||
[1;32m 2435[0m [38;5;66;03m# when using magics with decorator @output_can_be_silenced[39;00m
|
||||
[1;32m 2436[0m [38;5;66;03m# when the last Python token in the expression is a ';'.[39;00m
|
||||
[1;32m 2437[0m [38;5;28;01mif[39;00m [38;5;28mgetattr[39m(fn, magic[38;5;241m.[39mMAGIC_OUTPUT_CAN_BE_SILENCED, [38;5;28;01mFalse[39;00m):
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99[0m, in [0;36mPylabMagics.matplotlib[0;34m(self, line)[0m
|
||||
[1;32m 97[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mAvailable matplotlib backends: [39m[38;5;132;01m%s[39;00m[38;5;124m"[39m [38;5;241m%[39m backends_list)
|
||||
[1;32m 98[0m [38;5;28;01melse[39;00m:
|
||||
[0;32m---> 99[0m gui, backend [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mshell[49m[38;5;241;43m.[39;49m[43menable_matplotlib[49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[38;5;241;43m.[39;49m[43mlower[49m[43m([49m[43m)[49m[43m [49m[38;5;28;43;01mif[39;49;00m[43m [49m[38;5;28;43misinstance[39;49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m,[49m[43m [49m[38;5;28;43mstr[39;49m[43m)[49m[43m [49m[38;5;28;43;01melse[39;49;00m[43m [49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m)[49m
|
||||
[1;32m 100[0m [38;5;28mself[39m[38;5;241m.[39m_show_matplotlib_backend(args[38;5;241m.[39mgui, backend)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3606[0m, in [0;36mInteractiveShell.enable_matplotlib[0;34m(self, gui)[0m
|
||||
[1;32m 3585[0m [38;5;28;01mdef[39;00m [38;5;21menable_matplotlib[39m([38;5;28mself[39m, gui[38;5;241m=[39m[38;5;28;01mNone[39;00m):
|
||||
[1;32m 3586[0m [38;5;250m [39m[38;5;124;03m"""Enable interactive matplotlib and inline figure support.[39;00m
|
||||
[1;32m 3587[0m
|
||||
[1;32m 3588[0m [38;5;124;03m This takes the following steps:[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 3604[0m [38;5;124;03m display figures inline.[39;00m
|
||||
[1;32m 3605[0m [38;5;124;03m """[39;00m
|
||||
[0;32m-> 3606[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib_inline[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackend_inline[39;00m [38;5;28;01mimport[39;00m configure_inline_support
|
||||
[1;32m 3608[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcore[39;00m [38;5;28;01mimport[39;00m pylabtools [38;5;28;01mas[39;00m pt
|
||||
[1;32m 3609[0m gui, backend [38;5;241m=[39m pt[38;5;241m.[39mfind_gui_and_backend(gui, [38;5;28mself[39m[38;5;241m.[39mpylab_gui_select)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/__init__.py:1[0m
|
||||
[0;32m----> 1[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m backend_inline, config [38;5;66;03m# noqa[39;00m
|
||||
[1;32m 2[0m __version__ [38;5;241m=[39m [38;5;124m"[39m[38;5;124m0.1.6[39m[38;5;124m"[39m [38;5;66;03m# noqa[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:6[0m
|
||||
[1;32m 1[0m [38;5;124;03m"""A matplotlib backend for publishing figures via display_data"""[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Copyright (c) IPython Development Team.[39;00m
|
||||
[1;32m 4[0m [38;5;66;03m# Distributed under the terms of the BSD 3-Clause License.[39;00m
|
||||
[0;32m----> 6[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m
|
||||
[1;32m 7[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m colors
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackends[39;00m [38;5;28;01mimport[39;00m backend_agg
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'matplotlib'
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
scipy.misc.imread
|
||||
------------------
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mNameError[0m Traceback (most recent call last)
|
||||
Input [0;32mIn [2][0m, in [0;36m<cell line: 1>[0;34m()[0m
|
||||
[0;32m----> 1[0m [43mscipy[49m[38;5;241m.[39mmisc[38;5;241m.[39mimread
|
||||
|
||||
[0;31mNameError[0m: name 'scipy' is not defined
|
||||
NameError: name 'scipy' is not defined
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
import numpy as np
|
||||
from math import acos, exp, sqrt
|
||||
from matplotlib import pyplot as plt
|
||||
from matplotlib import rc, rcParams
|
||||
import matplotlib.units as units
|
||||
import matplotlib.ticker as ticker
|
||||
rc('text',usetex=True)
|
||||
rc('font',**{'family':'serif','serif':['Gaussian distribution']})
|
||||
font = {'family' : 'serif',
|
||||
'color' : 'darkred',
|
||||
'weight' : 'normal',
|
||||
'size' : 16,
|
||||
}
|
||||
pi = acos(-1.0)
|
||||
mu0 = 0.0
|
||||
sigma0 = 1.0
|
||||
mu1= 1.0
|
||||
sigma1 = 2.0
|
||||
mu2 = 2.0
|
||||
sigma2 = 4.0
|
||||
|
||||
x = np.linspace(-20.0, 20.0)
|
||||
v0 = np.exp(-(x*x-2*x*mu0+mu0*mu0)/(2*sigma0*sigma0))/sqrt(2*pi*sigma0*sigma0)
|
||||
v1 = np.exp(-(x*x-2*x*mu1+mu1*mu1)/(2*sigma1*sigma1))/sqrt(2*pi*sigma1*sigma1)
|
||||
v2 = np.exp(-(x*x-2*x*mu2+mu2*mu2)/(2*sigma2*sigma2))/sqrt(2*pi*sigma2*sigma2)
|
||||
plt.plot(x, v0, 'b-', x, v1, 'r-', x, v2, 'g-')
|
||||
plt.title(r'{\bf Gaussian distributions}', fontsize=20)
|
||||
plt.text(-19, 0.3, r'Parameters: $\mu = 0$, $\sigma = 1$', fontdict=font)
|
||||
plt.text(-19, 0.18, r'Parameters: $\mu = 1$, $\sigma = 2$', fontdict=font)
|
||||
plt.text(-19, 0.08, r'Parameters: $\mu = 2$, $\sigma = 4$', fontdict=font)
|
||||
plt.xlabel(r'$x$',fontsize=20)
|
||||
plt.ylabel(r'$p(x)$ [MeV]',fontsize=20)
|
||||
|
||||
# Tweak spacing to prevent clipping of ylabel
|
||||
plt.subplots_adjust(left=0.15)
|
||||
plt.savefig('gaussian.pdf', format='pdf')
|
||||
plt.show()
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[1], line 1[0m
|
||||
[0;32m----> 1[0m [43mget_ipython[49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43mrun_line_magic[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mmatplotlib[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43minline[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 3[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
[1;32m 4[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmath[39;00m [38;5;28;01mimport[39;00m acos, exp, sqrt
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2432[0m, in [0;36mInteractiveShell.run_line_magic[0;34m(self, magic_name, line, _stack_depth)[0m
|
||||
[1;32m 2430[0m kwargs[[38;5;124m'[39m[38;5;124mlocal_ns[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mget_local_scope(stack_depth)
|
||||
[1;32m 2431[0m [38;5;28;01mwith[39;00m [38;5;28mself[39m[38;5;241m.[39mbuiltin_trap:
|
||||
[0;32m-> 2432[0m result [38;5;241m=[39m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
[1;32m 2434[0m [38;5;66;03m# The code below prevents the output from being displayed[39;00m
|
||||
[1;32m 2435[0m [38;5;66;03m# when using magics with decorator @output_can_be_silenced[39;00m
|
||||
[1;32m 2436[0m [38;5;66;03m# when the last Python token in the expression is a ';'.[39;00m
|
||||
[1;32m 2437[0m [38;5;28;01mif[39;00m [38;5;28mgetattr[39m(fn, magic[38;5;241m.[39mMAGIC_OUTPUT_CAN_BE_SILENCED, [38;5;28;01mFalse[39;00m):
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99[0m, in [0;36mPylabMagics.matplotlib[0;34m(self, line)[0m
|
||||
[1;32m 97[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mAvailable matplotlib backends: [39m[38;5;132;01m%s[39;00m[38;5;124m"[39m [38;5;241m%[39m backends_list)
|
||||
[1;32m 98[0m [38;5;28;01melse[39;00m:
|
||||
[0;32m---> 99[0m gui, backend [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mshell[49m[38;5;241;43m.[39;49m[43menable_matplotlib[49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[38;5;241;43m.[39;49m[43mlower[49m[43m([49m[43m)[49m[43m [49m[38;5;28;43;01mif[39;49;00m[43m [49m[38;5;28;43misinstance[39;49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m,[49m[43m [49m[38;5;28;43mstr[39;49m[43m)[49m[43m [49m[38;5;28;43;01melse[39;49;00m[43m [49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m)[49m
|
||||
[1;32m 100[0m [38;5;28mself[39m[38;5;241m.[39m_show_matplotlib_backend(args[38;5;241m.[39mgui, backend)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3606[0m, in [0;36mInteractiveShell.enable_matplotlib[0;34m(self, gui)[0m
|
||||
[1;32m 3585[0m [38;5;28;01mdef[39;00m [38;5;21menable_matplotlib[39m([38;5;28mself[39m, gui[38;5;241m=[39m[38;5;28;01mNone[39;00m):
|
||||
[1;32m 3586[0m [38;5;250m [39m[38;5;124;03m"""Enable interactive matplotlib and inline figure support.[39;00m
|
||||
[1;32m 3587[0m
|
||||
[1;32m 3588[0m [38;5;124;03m This takes the following steps:[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 3604[0m [38;5;124;03m display figures inline.[39;00m
|
||||
[1;32m 3605[0m [38;5;124;03m """[39;00m
|
||||
[0;32m-> 3606[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib_inline[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackend_inline[39;00m [38;5;28;01mimport[39;00m configure_inline_support
|
||||
[1;32m 3608[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcore[39;00m [38;5;28;01mimport[39;00m pylabtools [38;5;28;01mas[39;00m pt
|
||||
[1;32m 3609[0m gui, backend [38;5;241m=[39m pt[38;5;241m.[39mfind_gui_and_backend(gui, [38;5;28mself[39m[38;5;241m.[39mpylab_gui_select)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/__init__.py:1[0m
|
||||
[0;32m----> 1[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m backend_inline, config [38;5;66;03m# noqa[39;00m
|
||||
[1;32m 2[0m __version__ [38;5;241m=[39m [38;5;124m"[39m[38;5;124m0.1.6[39m[38;5;124m"[39m [38;5;66;03m# noqa[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:6[0m
|
||||
[1;32m 1[0m [38;5;124;03m"""A matplotlib backend for publishing figures via display_data"""[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Copyright (c) IPython Development Team.[39;00m
|
||||
[1;32m 4[0m [38;5;66;03m# Distributed under the terms of the BSD 3-Clause License.[39;00m
|
||||
[0;32m----> 6[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m
|
||||
[1;32m 7[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m colors
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackends[39;00m [38;5;28;01mimport[39;00m backend_agg
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'matplotlib'
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
# Blocking
|
||||
@timeFunction
|
||||
def blocking(self, blockSizeMax = 500):
|
||||
blockSizeMin = 1
|
||||
|
||||
self.blockSizes = []
|
||||
self.meanVec = []
|
||||
self.varVec = []
|
||||
|
||||
for i in range(blockSizeMin, blockSizeMax):
|
||||
if(len(self.data) % i != 0):
|
||||
pass#continue
|
||||
blockSize = i
|
||||
meanTempVec = []
|
||||
varTempVec = []
|
||||
startPoint = 0
|
||||
endPoint = blockSize
|
||||
|
||||
while endPoint <= len(self.data):
|
||||
meanTempVec.append(np.average(self.data[startPoint:endPoint]))
|
||||
startPoint = endPoint
|
||||
endPoint += blockSize
|
||||
mean, var = np.average(meanTempVec), np.var(meanTempVec)/len(meanTempVec)
|
||||
self.meanVec.append(mean)
|
||||
self.varVec.append(var)
|
||||
self.blockSizes.append(blockSize)
|
||||
|
||||
self.blockingAvg = np.average(self.meanVec[-200:])
|
||||
self.blockingVar = (np.average(self.varVec[-200:]))
|
||||
self.blockingStd = np.sqrt(self.blockingVar)
|
||||
------------------
|
||||
|
||||
[0;36m File [0;32m"<ipython-input-6-2ff97f4bf03b>"[0;36m, line [0;32m2[0m
|
||||
[0;31m @timeFunction[0m
|
||||
[0m ^[0m
|
||||
[0;31mIndentationError[0m[0;31m:[0m unexpected indent
|
||||
|
||||
IndentationError: unexpected indent (<ipython-input-6-2ff97f4bf03b>, line 2)
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from scipy import sparse
|
||||
eye = np.eye(4)
|
||||
print(eye)
|
||||
sparse_mtx = sparse.csr_matrix(eye)
|
||||
print(sparse_mtx)
|
||||
x = np.linspace(-10,10,100)
|
||||
y = np.sin(x)
|
||||
plt.plot(x,y,marker='x')
|
||||
plt.show()
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[16], line 1[0m
|
||||
[0;32m----> 1[0m [43mget_ipython[49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43mrun_line_magic[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mmatplotlib[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43minline[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 3[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
[1;32m 4[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mpyplot[39;00m [38;5;28;01mas[39;00m [38;5;21;01mplt[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2432[0m, in [0;36mInteractiveShell.run_line_magic[0;34m(self, magic_name, line, _stack_depth)[0m
|
||||
[1;32m 2430[0m kwargs[[38;5;124m'[39m[38;5;124mlocal_ns[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mget_local_scope(stack_depth)
|
||||
[1;32m 2431[0m [38;5;28;01mwith[39;00m [38;5;28mself[39m[38;5;241m.[39mbuiltin_trap:
|
||||
[0;32m-> 2432[0m result [38;5;241m=[39m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
[1;32m 2434[0m [38;5;66;03m# The code below prevents the output from being displayed[39;00m
|
||||
[1;32m 2435[0m [38;5;66;03m# when using magics with decorator @output_can_be_silenced[39;00m
|
||||
[1;32m 2436[0m [38;5;66;03m# when the last Python token in the expression is a ';'.[39;00m
|
||||
[1;32m 2437[0m [38;5;28;01mif[39;00m [38;5;28mgetattr[39m(fn, magic[38;5;241m.[39mMAGIC_OUTPUT_CAN_BE_SILENCED, [38;5;28;01mFalse[39;00m):
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99[0m, in [0;36mPylabMagics.matplotlib[0;34m(self, line)[0m
|
||||
[1;32m 97[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mAvailable matplotlib backends: [39m[38;5;132;01m%s[39;00m[38;5;124m"[39m [38;5;241m%[39m backends_list)
|
||||
[1;32m 98[0m [38;5;28;01melse[39;00m:
|
||||
[0;32m---> 99[0m gui, backend [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mshell[49m[38;5;241;43m.[39;49m[43menable_matplotlib[49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[38;5;241;43m.[39;49m[43mlower[49m[43m([49m[43m)[49m[43m [49m[38;5;28;43;01mif[39;49;00m[43m [49m[38;5;28;43misinstance[39;49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m,[49m[43m [49m[38;5;28;43mstr[39;49m[43m)[49m[43m [49m[38;5;28;43;01melse[39;49;00m[43m [49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m)[49m
|
||||
[1;32m 100[0m [38;5;28mself[39m[38;5;241m.[39m_show_matplotlib_backend(args[38;5;241m.[39mgui, backend)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3606[0m, in [0;36mInteractiveShell.enable_matplotlib[0;34m(self, gui)[0m
|
||||
[1;32m 3585[0m [38;5;28;01mdef[39;00m [38;5;21menable_matplotlib[39m([38;5;28mself[39m, gui[38;5;241m=[39m[38;5;28;01mNone[39;00m):
|
||||
[1;32m 3586[0m [38;5;250m [39m[38;5;124;03m"""Enable interactive matplotlib and inline figure support.[39;00m
|
||||
[1;32m 3587[0m
|
||||
[1;32m 3588[0m [38;5;124;03m This takes the following steps:[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 3604[0m [38;5;124;03m display figures inline.[39;00m
|
||||
[1;32m 3605[0m [38;5;124;03m """[39;00m
|
||||
[0;32m-> 3606[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib_inline[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackend_inline[39;00m [38;5;28;01mimport[39;00m configure_inline_support
|
||||
[1;32m 3608[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcore[39;00m [38;5;28;01mimport[39;00m pylabtools [38;5;28;01mas[39;00m pt
|
||||
[1;32m 3609[0m gui, backend [38;5;241m=[39m pt[38;5;241m.[39mfind_gui_and_backend(gui, [38;5;28mself[39m[38;5;241m.[39mpylab_gui_select)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/__init__.py:1[0m
|
||||
[0;32m----> 1[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m backend_inline, config [38;5;66;03m# noqa[39;00m
|
||||
[1;32m 2[0m __version__ [38;5;241m=[39m [38;5;124m"[39m[38;5;124m0.1.6[39m[38;5;124m"[39m [38;5;66;03m# noqa[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:6[0m
|
||||
[1;32m 1[0m [38;5;124;03m"""A matplotlib backend for publishing figures via display_data"""[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Copyright (c) IPython Development Team.[39;00m
|
||||
[1;32m 4[0m [38;5;66;03m# Distributed under the terms of the BSD 3-Clause License.[39;00m
|
||||
[0;32m----> 6[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m
|
||||
[1;32m 7[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m colors
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackends[39;00m [38;5;28;01mimport[39;00m backend_agg
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'matplotlib'
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
# Read the experimental data with Pandas
|
||||
Masses = pd.read_fwf(infile, usecols=(2,3,4,6,11),
|
||||
names=('N', 'Z', 'A', 'Element', 'Ebinding'),
|
||||
widths=(1,3,5,5,5,1,3,4,1,13,11,11,9,1,2,11,9,1,3,1,12,11,1),
|
||||
header=39,
|
||||
index_col=False)
|
||||
|
||||
# Extrapolated values are indicated by '#' in place of the decimal place, so
|
||||
# the Ebinding column won't be numeric. Coerce to float and drop these entries.
|
||||
Masses['Ebinding'] = pd.to_numeric(Masses['Ebinding'], errors='coerce')
|
||||
Masses = Masses.dropna()
|
||||
# Convert from keV to MeV.
|
||||
Masses['Ebinding'] /= 1000
|
||||
|
||||
# Group the DataFrame by nucleon number, A.
|
||||
Masses = Masses.groupby('A')
|
||||
# Find the rows of the grouped DataFrame with the maximum binding energy.
|
||||
Masses = Masses.apply(lambda t: t[t.Ebinding==t.Ebinding.max()])
|
||||
------------------
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mValueError[0m Traceback (most recent call last)
|
||||
Input [0;32mIn [30][0m, in [0;36m<cell line: 2>[0;34m()[0m
|
||||
[1;32m 1[0m [38;5;66;03m# Read the experimental data with Pandas[39;00m
|
||||
[0;32m----> 2[0m Masses [38;5;241m=[39m [43mpd[49m[38;5;241;43m.[39;49m[43mread_fwf[49m[43m([49m[43minfile[49m[43m,[49m[43m [49m[43musecols[49m[38;5;241;43m=[39;49m[43m([49m[38;5;241;43m2[39;49m[43m,[49m[38;5;241;43m3[39;49m[43m,[49m[38;5;241;43m4[39;49m[43m,[49m[38;5;241;43m6[39;49m[43m,[49m[38;5;241;43m11[39;49m[43m)[49m[43m,[49m
|
||||
[1;32m 3[0m [43m [49m[43mnames[49m[38;5;241;43m=[39;49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mN[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43mZ[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43mA[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43mElement[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43mEbinding[39;49m[38;5;124;43m'[39;49m[43m)[49m[43m,[49m
|
||||
[1;32m 4[0m [43m [49m[43mwidths[49m[38;5;241;43m=[39;49m[43m([49m[38;5;241;43m1[39;49m[43m,[49m[38;5;241;43m3[39;49m[43m,[49m[38;5;241;43m5[39;49m[43m,[49m[38;5;241;43m5[39;49m[43m,[49m[38;5;241;43m5[39;49m[43m,[49m[38;5;241;43m1[39;49m[43m,[49m[38;5;241;43m3[39;49m[43m,[49m[38;5;241;43m4[39;49m[43m,[49m[38;5;241;43m1[39;49m[43m,[49m[38;5;241;43m13[39;49m[43m,[49m[38;5;241;43m11[39;49m[43m,[49m[38;5;241;43m11[39;49m[43m,[49m[38;5;241;43m9[39;49m[43m,[49m[38;5;241;43m1[39;49m[43m,[49m[38;5;241;43m2[39;49m[43m,[49m[38;5;241;43m11[39;49m[43m,[49m[38;5;241;43m9[39;49m[43m,[49m[38;5;241;43m1[39;49m[43m,[49m[38;5;241;43m3[39;49m[43m,[49m[38;5;241;43m1[39;49m[43m,[49m[38;5;241;43m12[39;49m[43m,[49m[38;5;241;43m11[39;49m[43m,[49m[38;5;241;43m1[39;49m[43m)[49m[43m,[49m
|
||||
[1;32m 5[0m [43m [49m[43mheader[49m[38;5;241;43m=[39;49m[38;5;241;43m39[39;49m[43m,[49m
|
||||
[1;32m 6[0m [43m [49m[43mindex_col[49m[38;5;241;43m=[39;49m[38;5;28;43;01mFalse[39;49;00m[43m)[49m
|
||||
[1;32m 8[0m [38;5;66;03m# Extrapolated values are indicated by '#' in place of the decimal place, so[39;00m
|
||||
[1;32m 9[0m [38;5;66;03m# the Ebinding column won't be numeric. Coerce to float and drop these entries.[39;00m
|
||||
[1;32m 10[0m Masses[[38;5;124m'[39m[38;5;124mEbinding[39m[38;5;124m'[39m] [38;5;241m=[39m pd[38;5;241m.[39mto_numeric(Masses[[38;5;124m'[39m[38;5;124mEbinding[39m[38;5;124m'[39m], errors[38;5;241m=[39m[38;5;124m'[39m[38;5;124mcoerce[39m[38;5;124m'[39m)
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/pandas/util/_decorators.py:311[0m, in [0;36mdeprecate_nonkeyword_arguments.<locals>.decorate.<locals>.wrapper[0;34m(*args, **kwargs)[0m
|
||||
[1;32m 305[0m [38;5;28;01mif[39;00m [38;5;28mlen[39m(args) [38;5;241m>[39m num_allow_args:
|
||||
[1;32m 306[0m warnings[38;5;241m.[39mwarn(
|
||||
[1;32m 307[0m msg[38;5;241m.[39mformat(arguments[38;5;241m=[39marguments),
|
||||
[1;32m 308[0m [38;5;167;01mFutureWarning[39;00m,
|
||||
[1;32m 309[0m stacklevel[38;5;241m=[39mstacklevel,
|
||||
[1;32m 310[0m )
|
||||
[0;32m--> 311[0m [38;5;28;01mreturn[39;00m [43mfunc[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/pandas/io/parsers/readers.py:871[0m, in [0;36mread_fwf[0;34m(filepath_or_buffer, colspecs, widths, infer_nrows, **kwds)[0m
|
||||
[1;32m 869[0m len_index [38;5;241m=[39m [38;5;28mlen[39m(index_col)
|
||||
[1;32m 870[0m [38;5;28;01mif[39;00m [38;5;28mlen[39m(names) [38;5;241m+[39m len_index [38;5;241m!=[39m [38;5;28mlen[39m(colspecs):
|
||||
[0;32m--> 871[0m [38;5;28;01mraise[39;00m [38;5;167;01mValueError[39;00m([38;5;124m"[39m[38;5;124mLength of colspecs must match length of names[39m[38;5;124m"[39m)
|
||||
[1;32m 873[0m kwds[[38;5;124m"[39m[38;5;124mcolspecs[39m[38;5;124m"[39m] [38;5;241m=[39m colspecs
|
||||
[1;32m 874[0m kwds[[38;5;124m"[39m[38;5;124minfer_nrows[39m[38;5;124m"[39m] [38;5;241m=[39m infer_nrows
|
||||
|
||||
[0;31mValueError[0m: Length of colspecs must match length of names
|
||||
ValueError: Length of colspecs must match length of names
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
import os
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import matplotlib.pyplot as plt
|
||||
from sklearn.model_selection import train_test_split
|
||||
|
||||
|
||||
def R2(y_data, y_model):
|
||||
return 1 - np.sum((y_data - y_model) ** 2) / np.sum((y_data - np.mean(y_data)) ** 2)
|
||||
def MSE(y_data,y_model):
|
||||
n = np.size(y_model)
|
||||
return np.sum((y_data-y_model)**2)/n
|
||||
|
||||
x = np.random.rand(100)
|
||||
y = 2.0+5*x*x+0.1*np.random.randn(100)
|
||||
|
||||
|
||||
# The design matrix now as function of a fourth-order polynomial
|
||||
X = np.zeros((len(x),5))
|
||||
X[:,0] = 1.0
|
||||
X[:,1] = x
|
||||
X[:,2] = x**2
|
||||
X[:,3] = x**3
|
||||
X[:,4] = x**4
|
||||
# We split the data in test and training data
|
||||
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
|
||||
# matrix inversion to find beta
|
||||
beta = np.linalg.inv(X_train.T @ X_train) @ X_train.T @ y_train
|
||||
print(beta)
|
||||
# and then make the prediction
|
||||
ytilde = X_train @ beta
|
||||
print("Training R2")
|
||||
print(R2(y_train,ytilde))
|
||||
print("Training MSE")
|
||||
print(MSE(y_train,ytilde))
|
||||
ypredict = X_test @ beta
|
||||
print("Test R2")
|
||||
print(R2(y_test,ypredict))
|
||||
print("Test MSE")
|
||||
print(MSE(y_test,ypredict))
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[7], line 1[0m
|
||||
[0;32m----> 1[0m [43mget_ipython[49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43mrun_line_magic[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mmatplotlib[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43minline[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 3[0m [38;5;28;01mimport[39;00m [38;5;21;01mos[39;00m
|
||||
[1;32m 4[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2432[0m, in [0;36mInteractiveShell.run_line_magic[0;34m(self, magic_name, line, _stack_depth)[0m
|
||||
[1;32m 2430[0m kwargs[[38;5;124m'[39m[38;5;124mlocal_ns[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mget_local_scope(stack_depth)
|
||||
[1;32m 2431[0m [38;5;28;01mwith[39;00m [38;5;28mself[39m[38;5;241m.[39mbuiltin_trap:
|
||||
[0;32m-> 2432[0m result [38;5;241m=[39m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
[1;32m 2434[0m [38;5;66;03m# The code below prevents the output from being displayed[39;00m
|
||||
[1;32m 2435[0m [38;5;66;03m# when using magics with decorator @output_can_be_silenced[39;00m
|
||||
[1;32m 2436[0m [38;5;66;03m# when the last Python token in the expression is a ';'.[39;00m
|
||||
[1;32m 2437[0m [38;5;28;01mif[39;00m [38;5;28mgetattr[39m(fn, magic[38;5;241m.[39mMAGIC_OUTPUT_CAN_BE_SILENCED, [38;5;28;01mFalse[39;00m):
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99[0m, in [0;36mPylabMagics.matplotlib[0;34m(self, line)[0m
|
||||
[1;32m 97[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mAvailable matplotlib backends: [39m[38;5;132;01m%s[39;00m[38;5;124m"[39m [38;5;241m%[39m backends_list)
|
||||
[1;32m 98[0m [38;5;28;01melse[39;00m:
|
||||
[0;32m---> 99[0m gui, backend [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mshell[49m[38;5;241;43m.[39;49m[43menable_matplotlib[49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[38;5;241;43m.[39;49m[43mlower[49m[43m([49m[43m)[49m[43m [49m[38;5;28;43;01mif[39;49;00m[43m [49m[38;5;28;43misinstance[39;49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m,[49m[43m [49m[38;5;28;43mstr[39;49m[43m)[49m[43m [49m[38;5;28;43;01melse[39;49;00m[43m [49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m)[49m
|
||||
[1;32m 100[0m [38;5;28mself[39m[38;5;241m.[39m_show_matplotlib_backend(args[38;5;241m.[39mgui, backend)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3606[0m, in [0;36mInteractiveShell.enable_matplotlib[0;34m(self, gui)[0m
|
||||
[1;32m 3585[0m [38;5;28;01mdef[39;00m [38;5;21menable_matplotlib[39m([38;5;28mself[39m, gui[38;5;241m=[39m[38;5;28;01mNone[39;00m):
|
||||
[1;32m 3586[0m [38;5;250m [39m[38;5;124;03m"""Enable interactive matplotlib and inline figure support.[39;00m
|
||||
[1;32m 3587[0m
|
||||
[1;32m 3588[0m [38;5;124;03m This takes the following steps:[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 3604[0m [38;5;124;03m display figures inline.[39;00m
|
||||
[1;32m 3605[0m [38;5;124;03m """[39;00m
|
||||
[0;32m-> 3606[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib_inline[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackend_inline[39;00m [38;5;28;01mimport[39;00m configure_inline_support
|
||||
[1;32m 3608[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcore[39;00m [38;5;28;01mimport[39;00m pylabtools [38;5;28;01mas[39;00m pt
|
||||
[1;32m 3609[0m gui, backend [38;5;241m=[39m pt[38;5;241m.[39mfind_gui_and_backend(gui, [38;5;28mself[39m[38;5;241m.[39mpylab_gui_select)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/__init__.py:1[0m
|
||||
[0;32m----> 1[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m backend_inline, config [38;5;66;03m# noqa[39;00m
|
||||
[1;32m 2[0m __version__ [38;5;241m=[39m [38;5;124m"[39m[38;5;124m0.1.6[39m[38;5;124m"[39m [38;5;66;03m# noqa[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:6[0m
|
||||
[1;32m 1[0m [38;5;124;03m"""A matplotlib backend for publishing figures via display_data"""[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Copyright (c) IPython Development Team.[39;00m
|
||||
[1;32m 4[0m [38;5;66;03m# Distributed under the terms of the BSD 3-Clause License.[39;00m
|
||||
[0;32m----> 6[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m
|
||||
[1;32m 7[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m colors
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackends[39;00m [38;5;28;01mimport[39;00m backend_agg
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'matplotlib'
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
fit = np.linalg.lstsq(X, Energies, rcond =None)[0]
|
||||
ytildenp = np.dot(fit,X.T)
|
||||
------------------
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mNameError[0m Traceback (most recent call last)
|
||||
Input [0;32mIn [2][0m, in [0;36m<cell line: 1>[0;34m()[0m
|
||||
[0;32m----> 1[0m fit [38;5;241m=[39m np[38;5;241m.[39mlinalg[38;5;241m.[39mlstsq(X, [43mEnergies[49m, rcond [38;5;241m=[39m[38;5;28;01mNone[39;00m)[[38;5;241m0[39m]
|
||||
[1;32m 2[0m ytildenp [38;5;241m=[39m np[38;5;241m.[39mdot(fit,X[38;5;241m.[39mT)
|
||||
|
||||
[0;31mNameError[0m: name 'Energies' is not defined
|
||||
NameError: name 'Energies' is not defined
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
import numpy as np
|
||||
X = np.array( [ [1,2,3],[2,4,5],[3,5,6]])
|
||||
Xinv = np.linlag.pinv(X)
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mAttributeError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[1], line 3[0m
|
||||
[1;32m 1[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
[1;32m 2[0m X [38;5;241m=[39m np[38;5;241m.[39marray( [ [[38;5;241m1[39m,[38;5;241m2[39m,[38;5;241m3[39m],[[38;5;241m2[39m,[38;5;241m4[39m,[38;5;241m5[39m],[[38;5;241m3[39m,[38;5;241m5[39m,[38;5;241m6[39m]])
|
||||
[0;32m----> 3[0m Xinv [38;5;241m=[39m [43mnp[49m[38;5;241;43m.[39;49m[43mlinlag[49m[38;5;241m.[39mpinv(X)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/numpy/__init__.py:313[0m, in [0;36m__getattr__[0;34m(attr)[0m
|
||||
[1;32m 310[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m[38;5;21;01mtesting[39;00m [38;5;28;01mimport[39;00m Tester
|
||||
[1;32m 311[0m [38;5;28;01mreturn[39;00m Tester
|
||||
[0;32m--> 313[0m [38;5;28;01mraise[39;00m [38;5;167;01mAttributeError[39;00m([38;5;124m"[39m[38;5;124mmodule [39m[38;5;132;01m{!r}[39;00m[38;5;124m has no attribute [39m[38;5;124m"[39m
|
||||
[1;32m 314[0m [38;5;124m"[39m[38;5;132;01m{!r}[39;00m[38;5;124m"[39m[38;5;241m.[39mformat([38;5;18m__name__[39m, attr))
|
||||
|
||||
[0;31mAttributeError[0m: module 'numpy' has no attribute 'linlag'
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
import numpy as np
|
||||
X = np.array( [ [1,2,3],[2,4,5],[3,5,6]])
|
||||
Xinv = np.linlag.pinv(X)
|
||||
------------------
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mAttributeError[0m Traceback (most recent call last)
|
||||
Input [0;32mIn [1][0m, in [0;36m<cell line: 3>[0;34m()[0m
|
||||
[1;32m 1[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
[1;32m 2[0m X [38;5;241m=[39m np[38;5;241m.[39marray( [ [[38;5;241m1[39m,[38;5;241m2[39m,[38;5;241m3[39m],[[38;5;241m2[39m,[38;5;241m4[39m,[38;5;241m5[39m],[[38;5;241m3[39m,[38;5;241m5[39m,[38;5;241m6[39m]])
|
||||
[0;32m----> 3[0m Xinv [38;5;241m=[39m [43mnp[49m[38;5;241;43m.[39;49m[43mlinlag[49m[38;5;241m.[39mpinv(X)
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/numpy/__init__.py:315[0m, in [0;36m__getattr__[0;34m(attr)[0m
|
||||
[1;32m 312[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m[38;5;21;01mtesting[39;00m [38;5;28;01mimport[39;00m Tester
|
||||
[1;32m 313[0m [38;5;28;01mreturn[39;00m Tester
|
||||
[0;32m--> 315[0m [38;5;28;01mraise[39;00m [38;5;167;01mAttributeError[39;00m([38;5;124m"[39m[38;5;124mmodule [39m[38;5;132;01m{!r}[39;00m[38;5;124m has no attribute [39m[38;5;124m"[39m
|
||||
[1;32m 316[0m [38;5;124m"[39m[38;5;132;01m{!r}[39;00m[38;5;124m"[39m[38;5;241m.[39mformat([38;5;18m__name__[39m, attr))
|
||||
|
||||
[0;31mAttributeError[0m: module 'numpy' has no attribute 'linlag'
|
||||
AttributeError: module 'numpy' has no attribute 'linlag'
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
import numpy as np
|
||||
from time import time
|
||||
from scipy.stats import norm
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# Returns mean of bootstrap samples
|
||||
# Bootstrap algorithm
|
||||
def bootstrap(data, datapoints):
|
||||
t = np.zeros(datapoints)
|
||||
n = len(data)
|
||||
# non-parametric bootstrap
|
||||
for i in range(datapoints):
|
||||
t[i] = np.mean(data[np.random.randint(0,n,n)])
|
||||
# analysis
|
||||
print("Bootstrap Statistics :")
|
||||
print("original bias std. error")
|
||||
print("%8g %8g %14g %15g" % (np.mean(data), np.std(data),np.mean(t),np.std(t)))
|
||||
return t
|
||||
|
||||
# We set the mean value to 100 and the standard deviation to 15
|
||||
mu, sigma = 100, 15
|
||||
datapoints = 10000
|
||||
# We generate random numbers according to the normal distribution
|
||||
x = mu + sigma*np.random.randn(datapoints)
|
||||
# bootstrap returns the data sample
|
||||
t = bootstrap(x, datapoints)
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[1], line 1[0m
|
||||
[0;32m----> 1[0m [43mget_ipython[49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43mrun_line_magic[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mmatplotlib[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43minline[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 3[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
[1;32m 4[0m [38;5;28;01mfrom[39;00m [38;5;21;01mtime[39;00m [38;5;28;01mimport[39;00m time
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2432[0m, in [0;36mInteractiveShell.run_line_magic[0;34m(self, magic_name, line, _stack_depth)[0m
|
||||
[1;32m 2430[0m kwargs[[38;5;124m'[39m[38;5;124mlocal_ns[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mget_local_scope(stack_depth)
|
||||
[1;32m 2431[0m [38;5;28;01mwith[39;00m [38;5;28mself[39m[38;5;241m.[39mbuiltin_trap:
|
||||
[0;32m-> 2432[0m result [38;5;241m=[39m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
[1;32m 2434[0m [38;5;66;03m# The code below prevents the output from being displayed[39;00m
|
||||
[1;32m 2435[0m [38;5;66;03m# when using magics with decorator @output_can_be_silenced[39;00m
|
||||
[1;32m 2436[0m [38;5;66;03m# when the last Python token in the expression is a ';'.[39;00m
|
||||
[1;32m 2437[0m [38;5;28;01mif[39;00m [38;5;28mgetattr[39m(fn, magic[38;5;241m.[39mMAGIC_OUTPUT_CAN_BE_SILENCED, [38;5;28;01mFalse[39;00m):
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99[0m, in [0;36mPylabMagics.matplotlib[0;34m(self, line)[0m
|
||||
[1;32m 97[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mAvailable matplotlib backends: [39m[38;5;132;01m%s[39;00m[38;5;124m"[39m [38;5;241m%[39m backends_list)
|
||||
[1;32m 98[0m [38;5;28;01melse[39;00m:
|
||||
[0;32m---> 99[0m gui, backend [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mshell[49m[38;5;241;43m.[39;49m[43menable_matplotlib[49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[38;5;241;43m.[39;49m[43mlower[49m[43m([49m[43m)[49m[43m [49m[38;5;28;43;01mif[39;49;00m[43m [49m[38;5;28;43misinstance[39;49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m,[49m[43m [49m[38;5;28;43mstr[39;49m[43m)[49m[43m [49m[38;5;28;43;01melse[39;49;00m[43m [49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m)[49m
|
||||
[1;32m 100[0m [38;5;28mself[39m[38;5;241m.[39m_show_matplotlib_backend(args[38;5;241m.[39mgui, backend)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3606[0m, in [0;36mInteractiveShell.enable_matplotlib[0;34m(self, gui)[0m
|
||||
[1;32m 3585[0m [38;5;28;01mdef[39;00m [38;5;21menable_matplotlib[39m([38;5;28mself[39m, gui[38;5;241m=[39m[38;5;28;01mNone[39;00m):
|
||||
[1;32m 3586[0m [38;5;250m [39m[38;5;124;03m"""Enable interactive matplotlib and inline figure support.[39;00m
|
||||
[1;32m 3587[0m
|
||||
[1;32m 3588[0m [38;5;124;03m This takes the following steps:[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 3604[0m [38;5;124;03m display figures inline.[39;00m
|
||||
[1;32m 3605[0m [38;5;124;03m """[39;00m
|
||||
[0;32m-> 3606[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib_inline[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackend_inline[39;00m [38;5;28;01mimport[39;00m configure_inline_support
|
||||
[1;32m 3608[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcore[39;00m [38;5;28;01mimport[39;00m pylabtools [38;5;28;01mas[39;00m pt
|
||||
[1;32m 3609[0m gui, backend [38;5;241m=[39m pt[38;5;241m.[39mfind_gui_and_backend(gui, [38;5;28mself[39m[38;5;241m.[39mpylab_gui_select)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/__init__.py:1[0m
|
||||
[0;32m----> 1[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m backend_inline, config [38;5;66;03m# noqa[39;00m
|
||||
[1;32m 2[0m __version__ [38;5;241m=[39m [38;5;124m"[39m[38;5;124m0.1.6[39m[38;5;124m"[39m [38;5;66;03m# noqa[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:6[0m
|
||||
[1;32m 1[0m [38;5;124;03m"""A matplotlib backend for publishing figures via display_data"""[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Copyright (c) IPython Development Team.[39;00m
|
||||
[1;32m 4[0m [38;5;66;03m# Distributed under the terms of the BSD 3-Clause License.[39;00m
|
||||
[0;32m----> 6[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m
|
||||
[1;32m 7[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m colors
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackends[39;00m [38;5;28;01mimport[39;00m backend_agg
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'matplotlib'
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
from sklearn import linear_model
|
||||
np.random.seed(2018)
|
||||
n = 10
|
||||
d = 2
|
||||
Lambda = 0.01
|
||||
|
||||
# Make data set.
|
||||
x = np.linspace(-3, 3, n)
|
||||
y = 2.0 + 0.5*x + 5.0*(x**2)+ np.random.randn(n)
|
||||
|
||||
# Design matrix X does not include the intercept.
|
||||
X = np.zeros((n, d))
|
||||
for p in range(d):
|
||||
X[:, p] = x ** (p+1)
|
||||
|
||||
#Split data in train and test
|
||||
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
|
||||
# Scale data by subtracting mean value of the input using scikit-learn
|
||||
scaler = StandardScaler(with_std=False)
|
||||
scaler.fit(X_train)
|
||||
X_train_mean = np.mean(X_train,axis=0)
|
||||
X_train_scaled = scaler.transform(X_train)
|
||||
X_test_scaled = scaler.transform(X_test)
|
||||
# We scale also the output, here by our own code
|
||||
y_scaler = np.mean(y_train)
|
||||
y_train_scaled = y_train - y_scaler
|
||||
y_test_scaled = y_test- y_scaler
|
||||
|
||||
#Calculate beta
|
||||
OLS = LinearRegression()
|
||||
betaOLS=OLS.fit(X_train_scaled,y_train_scaled)
|
||||
ypredictOLS = OLS.predict(X_test_scaled)
|
||||
linear_model.Ridge(Lambda)
|
||||
RegRidge.fit(X_train_scaled,y_train_scaled)
|
||||
ypredictRidge = RegRidge.predict(X_test_scaled)
|
||||
betaOLS = OLS.coef_
|
||||
betaRidge = RegRidge.coef_
|
||||
print(betaOLS)
|
||||
print(betaRidge)
|
||||
interceptOLS = np.mean(y_train) - X_train_mean @ betaOLS
|
||||
interceptRidge = y_scaler - X_train_mean @ betaRidge
|
||||
print(interceptOLS)
|
||||
print(interceptRidge)
|
||||
#predict value
|
||||
ytilde_test_Ridge = X_test_scaled @ betaRidge+y_scaler
|
||||
ytilde_test_OLS = X_test_scaled @ betaOLS+y_scaler
|
||||
|
||||
#Calculate MSE
|
||||
print(" ")
|
||||
print("test MSE of OLS")
|
||||
print(MSE(y_test,ytilde_test_OLS))
|
||||
print(" ")
|
||||
print("test MSE of Ridge")
|
||||
print(MSE(y_test,ytilde_test_Ridge))
|
||||
plt.scatter(x,y,label='Data')
|
||||
plt.plot(x, X @ RegRidge.coef_ + RegRidge.intercept_ , label="Ridge_Fit")
|
||||
plt.grid()
|
||||
plt.legend()
|
||||
plt.show()
|
||||
------------------
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mNameError[0m Traceback (most recent call last)
|
||||
Input [0;32mIn [11][0m, in [0;36m<cell line: 34>[0;34m()[0m
|
||||
[1;32m 32[0m ypredictOLS [38;5;241m=[39m OLS[38;5;241m.[39mpredict(X_test_scaled)
|
||||
[1;32m 33[0m linear_model[38;5;241m.[39mRidge(Lambda)
|
||||
[0;32m---> 34[0m [43mRegRidge[49m[38;5;241m.[39mfit(X_train_scaled,y_train_scaled)
|
||||
[1;32m 35[0m ypredictRidge [38;5;241m=[39m RegRidge[38;5;241m.[39mpredict(X_test_scaled)
|
||||
[1;32m 36[0m betaOLS [38;5;241m=[39m OLS[38;5;241m.[39mcoef_
|
||||
|
||||
[0;31mNameError[0m: name 'RegRidge' is not defined
|
||||
NameError: name 'RegRidge' is not defined
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from sklearn.model_selection import KFold
|
||||
from sklearn.linear_model import Ridge
|
||||
from sklearn.model_selection import cross_val_score
|
||||
from sklearn.preprocessing import PolynomialFeatures
|
||||
|
||||
# A seed just to ensure that the random numbers are the same for every run.
|
||||
# Useful for eventual debugging.
|
||||
np.random.seed(3155)
|
||||
|
||||
# Generate the data.
|
||||
nsamples = 100
|
||||
x = np.random.randn(nsamples)
|
||||
y = 3*x**2 + np.random.randn(nsamples)
|
||||
|
||||
## Cross-validation on Ridge regression using KFold only
|
||||
|
||||
# Decide degree on polynomial to fit
|
||||
poly = PolynomialFeatures(degree = 6)
|
||||
|
||||
# Decide which values of lambda to use
|
||||
nlambdas = 500
|
||||
lambdas = np.logspace(-3, 5, nlambdas)
|
||||
|
||||
# Initialize a KFold instance
|
||||
k = 5
|
||||
kfold = KFold(n_splits = k)
|
||||
|
||||
# Perform the cross-validation to estimate MSE
|
||||
scores_KFold = np.zeros((nlambdas, k))
|
||||
|
||||
i = 0
|
||||
for lmb in lambdas:
|
||||
ridge = Ridge(alpha = lmb)
|
||||
j = 0
|
||||
for train_inds, test_inds in kfold.split(x):
|
||||
xtrain = x[train_inds]
|
||||
ytrain = y[train_inds]
|
||||
|
||||
xtest = x[test_inds]
|
||||
ytest = y[test_inds]
|
||||
|
||||
Xtrain = poly.fit_transform(xtrain[:, np.newaxis])
|
||||
ridge.fit(Xtrain, ytrain[:, np.newaxis])
|
||||
|
||||
Xtest = poly.fit_transform(xtest[:, np.newaxis])
|
||||
ypred = ridge.predict(Xtest)
|
||||
|
||||
scores_KFold[i,j] = np.sum((ypred - ytest[:, np.newaxis])**2)/np.size(ypred)
|
||||
|
||||
j += 1
|
||||
i += 1
|
||||
|
||||
|
||||
estimated_mse_KFold = np.mean(scores_KFold, axis = 1)
|
||||
|
||||
## Cross-validation using cross_val_score from sklearn along with KFold
|
||||
|
||||
# kfold is an instance initialized above as:
|
||||
# kfold = KFold(n_splits = k)
|
||||
|
||||
estimated_mse_sklearn = np.zeros(nlambdas)
|
||||
i = 0
|
||||
for lmb in lambdas:
|
||||
ridge = Ridge(alpha = lmb)
|
||||
|
||||
X = poly.fit_transform(x[:, np.newaxis])
|
||||
estimated_mse_folds = cross_val_score(ridge, X, y[:, np.newaxis], scoring='neg_mean_squared_error', cv=kfold)
|
||||
|
||||
# cross_val_score return an array containing the estimated negative mse for every fold.
|
||||
# we have to the the mean of every array in order to get an estimate of the mse of the model
|
||||
estimated_mse_sklearn[i] = np.mean(-estimated_mse_folds)
|
||||
|
||||
i += 1
|
||||
|
||||
## Plot and compare the slightly different ways to perform cross-validation
|
||||
|
||||
plt.figure()
|
||||
|
||||
plt.plot(np.log10(lambdas), estimated_mse_sklearn, label = 'cross_val_score')
|
||||
plt.plot(np.log10(lambdas), estimated_mse_KFold, 'r--', label = 'KFold')
|
||||
|
||||
plt.xlabel('log10(lambda)')
|
||||
plt.ylabel('mse')
|
||||
|
||||
plt.legend()
|
||||
|
||||
plt.show()
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[1], line 1[0m
|
||||
[0;32m----> 1[0m [43mget_ipython[49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43mrun_line_magic[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mmatplotlib[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43minline[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 3[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
[1;32m 4[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mpyplot[39;00m [38;5;28;01mas[39;00m [38;5;21;01mplt[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2432[0m, in [0;36mInteractiveShell.run_line_magic[0;34m(self, magic_name, line, _stack_depth)[0m
|
||||
[1;32m 2430[0m kwargs[[38;5;124m'[39m[38;5;124mlocal_ns[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mget_local_scope(stack_depth)
|
||||
[1;32m 2431[0m [38;5;28;01mwith[39;00m [38;5;28mself[39m[38;5;241m.[39mbuiltin_trap:
|
||||
[0;32m-> 2432[0m result [38;5;241m=[39m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
[1;32m 2434[0m [38;5;66;03m# The code below prevents the output from being displayed[39;00m
|
||||
[1;32m 2435[0m [38;5;66;03m# when using magics with decorator @output_can_be_silenced[39;00m
|
||||
[1;32m 2436[0m [38;5;66;03m# when the last Python token in the expression is a ';'.[39;00m
|
||||
[1;32m 2437[0m [38;5;28;01mif[39;00m [38;5;28mgetattr[39m(fn, magic[38;5;241m.[39mMAGIC_OUTPUT_CAN_BE_SILENCED, [38;5;28;01mFalse[39;00m):
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99[0m, in [0;36mPylabMagics.matplotlib[0;34m(self, line)[0m
|
||||
[1;32m 97[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mAvailable matplotlib backends: [39m[38;5;132;01m%s[39;00m[38;5;124m"[39m [38;5;241m%[39m backends_list)
|
||||
[1;32m 98[0m [38;5;28;01melse[39;00m:
|
||||
[0;32m---> 99[0m gui, backend [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mshell[49m[38;5;241;43m.[39;49m[43menable_matplotlib[49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[38;5;241;43m.[39;49m[43mlower[49m[43m([49m[43m)[49m[43m [49m[38;5;28;43;01mif[39;49;00m[43m [49m[38;5;28;43misinstance[39;49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m,[49m[43m [49m[38;5;28;43mstr[39;49m[43m)[49m[43m [49m[38;5;28;43;01melse[39;49;00m[43m [49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m)[49m
|
||||
[1;32m 100[0m [38;5;28mself[39m[38;5;241m.[39m_show_matplotlib_backend(args[38;5;241m.[39mgui, backend)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3606[0m, in [0;36mInteractiveShell.enable_matplotlib[0;34m(self, gui)[0m
|
||||
[1;32m 3585[0m [38;5;28;01mdef[39;00m [38;5;21menable_matplotlib[39m([38;5;28mself[39m, gui[38;5;241m=[39m[38;5;28;01mNone[39;00m):
|
||||
[1;32m 3586[0m [38;5;250m [39m[38;5;124;03m"""Enable interactive matplotlib and inline figure support.[39;00m
|
||||
[1;32m 3587[0m
|
||||
[1;32m 3588[0m [38;5;124;03m This takes the following steps:[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 3604[0m [38;5;124;03m display figures inline.[39;00m
|
||||
[1;32m 3605[0m [38;5;124;03m """[39;00m
|
||||
[0;32m-> 3606[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib_inline[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackend_inline[39;00m [38;5;28;01mimport[39;00m configure_inline_support
|
||||
[1;32m 3608[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcore[39;00m [38;5;28;01mimport[39;00m pylabtools [38;5;28;01mas[39;00m pt
|
||||
[1;32m 3609[0m gui, backend [38;5;241m=[39m pt[38;5;241m.[39mfind_gui_and_backend(gui, [38;5;28mself[39m[38;5;241m.[39mpylab_gui_select)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/__init__.py:1[0m
|
||||
[0;32m----> 1[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m backend_inline, config [38;5;66;03m# noqa[39;00m
|
||||
[1;32m 2[0m __version__ [38;5;241m=[39m [38;5;124m"[39m[38;5;124m0.1.6[39m[38;5;124m"[39m [38;5;66;03m# noqa[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:6[0m
|
||||
[1;32m 1[0m [38;5;124;03m"""A matplotlib backend for publishing figures via display_data"""[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Copyright (c) IPython Development Team.[39;00m
|
||||
[1;32m 4[0m [38;5;66;03m# Distributed under the terms of the BSD 3-Clause License.[39;00m
|
||||
[0;32m----> 6[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m
|
||||
[1;32m 7[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m colors
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackends[39;00m [38;5;28;01mimport[39;00m backend_agg
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'matplotlib'
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
x = 2*np.random.rand(m,1)
|
||||
y = 4+3*x+np.random.randn(m,1)
|
||||
------------------
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mNameError[0m Traceback (most recent call last)
|
||||
Input [0;32mIn [13][0m, in [0;36m<cell line: 1>[0;34m()[0m
|
||||
[0;32m----> 1[0m x [38;5;241m=[39m [38;5;241m2[39m[38;5;241m*[39mnp[38;5;241m.[39mrandom[38;5;241m.[39mrand([43mm[49m,[38;5;241m1[39m)
|
||||
[1;32m 2[0m y [38;5;241m=[39m [38;5;241m4[39m[38;5;241m+[39m[38;5;241m3[39m[38;5;241m*[39mx[38;5;241m+[39mnp[38;5;241m.[39mrandom[38;5;241m.[39mrandn(m,[38;5;241m1[39m)
|
||||
|
||||
[0;31mNameError[0m: name 'm' is not defined
|
||||
NameError: name 'm' is not defined
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1305, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped
|
||||
return loop.run_until_complete(inner)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 705, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 1058, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/lib/python3.9/site-packages/nbclient/client.py", line 914, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
%matplotlib inline
|
||||
|
||||
import numpy as np
|
||||
import numpy.linalg as la
|
||||
|
||||
import scipy.optimize as sopt
|
||||
|
||||
import matplotlib.pyplot as pt
|
||||
from mpl_toolkits.mplot3d import axes3d
|
||||
|
||||
def f(x):
|
||||
return x[0]**2 + 3.0*x[1]**2
|
||||
|
||||
def df(x):
|
||||
return np.array([2*x[0], 6*x[1]])
|
||||
|
||||
fig = pt.figure()
|
||||
ax = fig.gca(projection="3d")
|
||||
|
||||
xmesh, ymesh = np.mgrid[-3:3:50j,-3:3:50j]
|
||||
fmesh = f(np.array([xmesh, ymesh]))
|
||||
ax.plot_surface(xmesh, ymesh, fmesh)
|
||||
------------------
|
||||
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mModuleNotFoundError[0m Traceback (most recent call last)
|
||||
Cell [0;32mIn[1], line 1[0m
|
||||
[0;32m----> 1[0m [43mget_ipython[49m[43m([49m[43m)[49m[38;5;241;43m.[39;49m[43mrun_line_magic[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mmatplotlib[39;49m[38;5;124;43m'[39;49m[43m,[49m[43m [49m[38;5;124;43m'[39;49m[38;5;124;43minline[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
||||
[1;32m 3[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m [38;5;28;01mas[39;00m [38;5;21;01mnp[39;00m
|
||||
[1;32m 4[0m [38;5;28;01mimport[39;00m [38;5;21;01mnumpy[39;00m[38;5;21;01m.[39;00m[38;5;21;01mlinalg[39;00m [38;5;28;01mas[39;00m [38;5;21;01mla[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2432[0m, in [0;36mInteractiveShell.run_line_magic[0;34m(self, magic_name, line, _stack_depth)[0m
|
||||
[1;32m 2430[0m kwargs[[38;5;124m'[39m[38;5;124mlocal_ns[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mget_local_scope(stack_depth)
|
||||
[1;32m 2431[0m [38;5;28;01mwith[39;00m [38;5;28mself[39m[38;5;241m.[39mbuiltin_trap:
|
||||
[0;32m-> 2432[0m result [38;5;241m=[39m [43mfn[49m[43m([49m[38;5;241;43m*[39;49m[43margs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
[1;32m 2434[0m [38;5;66;03m# The code below prevents the output from being displayed[39;00m
|
||||
[1;32m 2435[0m [38;5;66;03m# when using magics with decorator @output_can_be_silenced[39;00m
|
||||
[1;32m 2436[0m [38;5;66;03m# when the last Python token in the expression is a ';'.[39;00m
|
||||
[1;32m 2437[0m [38;5;28;01mif[39;00m [38;5;28mgetattr[39m(fn, magic[38;5;241m.[39mMAGIC_OUTPUT_CAN_BE_SILENCED, [38;5;28;01mFalse[39;00m):
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/magics/pylab.py:99[0m, in [0;36mPylabMagics.matplotlib[0;34m(self, line)[0m
|
||||
[1;32m 97[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mAvailable matplotlib backends: [39m[38;5;132;01m%s[39;00m[38;5;124m"[39m [38;5;241m%[39m backends_list)
|
||||
[1;32m 98[0m [38;5;28;01melse[39;00m:
|
||||
[0;32m---> 99[0m gui, backend [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mshell[49m[38;5;241;43m.[39;49m[43menable_matplotlib[49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[38;5;241;43m.[39;49m[43mlower[49m[43m([49m[43m)[49m[43m [49m[38;5;28;43;01mif[39;49;00m[43m [49m[38;5;28;43misinstance[39;49m[43m([49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m,[49m[43m [49m[38;5;28;43mstr[39;49m[43m)[49m[43m [49m[38;5;28;43;01melse[39;49;00m[43m [49m[43margs[49m[38;5;241;43m.[39;49m[43mgui[49m[43m)[49m
|
||||
[1;32m 100[0m [38;5;28mself[39m[38;5;241m.[39m_show_matplotlib_backend(args[38;5;241m.[39mgui, backend)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/IPython/core/interactiveshell.py:3606[0m, in [0;36mInteractiveShell.enable_matplotlib[0;34m(self, gui)[0m
|
||||
[1;32m 3585[0m [38;5;28;01mdef[39;00m [38;5;21menable_matplotlib[39m([38;5;28mself[39m, gui[38;5;241m=[39m[38;5;28;01mNone[39;00m):
|
||||
[1;32m 3586[0m [38;5;250m [39m[38;5;124;03m"""Enable interactive matplotlib and inline figure support.[39;00m
|
||||
[1;32m 3587[0m
|
||||
[1;32m 3588[0m [38;5;124;03m This takes the following steps:[39;00m
|
||||
[0;32m (...)[0m
|
||||
[1;32m 3604[0m [38;5;124;03m display figures inline.[39;00m
|
||||
[1;32m 3605[0m [38;5;124;03m """[39;00m
|
||||
[0;32m-> 3606[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib_inline[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackend_inline[39;00m [38;5;28;01mimport[39;00m configure_inline_support
|
||||
[1;32m 3608[0m [38;5;28;01mfrom[39;00m [38;5;21;01mIPython[39;00m[38;5;21;01m.[39;00m[38;5;21;01mcore[39;00m [38;5;28;01mimport[39;00m pylabtools [38;5;28;01mas[39;00m pt
|
||||
[1;32m 3609[0m gui, backend [38;5;241m=[39m pt[38;5;241m.[39mfind_gui_and_backend(gui, [38;5;28mself[39m[38;5;241m.[39mpylab_gui_select)
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/__init__.py:1[0m
|
||||
[0;32m----> 1[0m [38;5;28;01mfrom[39;00m [38;5;21;01m.[39;00m [38;5;28;01mimport[39;00m backend_inline, config [38;5;66;03m# noqa[39;00m
|
||||
[1;32m 2[0m __version__ [38;5;241m=[39m [38;5;124m"[39m[38;5;124m0.1.6[39m[38;5;124m"[39m [38;5;66;03m# noqa[39;00m
|
||||
|
||||
File [0;32m~/miniforge3/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py:6[0m
|
||||
[1;32m 1[0m [38;5;124;03m"""A matplotlib backend for publishing figures via display_data"""[39;00m
|
||||
[1;32m 3[0m [38;5;66;03m# Copyright (c) IPython Development Team.[39;00m
|
||||
[1;32m 4[0m [38;5;66;03m# Distributed under the terms of the BSD 3-Clause License.[39;00m
|
||||
[0;32m----> 6[0m [38;5;28;01mimport[39;00m [38;5;21;01mmatplotlib[39;00m
|
||||
[1;32m 7[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m [38;5;28;01mimport[39;00m colors
|
||||
[1;32m 8[0m [38;5;28;01mfrom[39;00m [38;5;21;01mmatplotlib[39;00m[38;5;21;01m.[39;00m[38;5;21;01mbackends[39;00m [38;5;28;01mimport[39;00m backend_agg
|
||||
|
||||
[0;31mModuleNotFoundError[0m: No module named 'matplotlib'
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
x = 2*np.random.rand(m,1)
|
||||
y = 4+3*x+np.random.randn(m,1)
|
||||
------------------
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mNameError[0m Traceback (most recent call last)
|
||||
Input [0;32mIn [6][0m, in [0;36m<cell line: 1>[0;34m()[0m
|
||||
[0;32m----> 1[0m x [38;5;241m=[39m [38;5;241m2[39m[38;5;241m*[39mnp[38;5;241m.[39mrandom[38;5;241m.[39mrand([43mm[49m,[38;5;241m1[39m)
|
||||
[1;32m 2[0m y [38;5;241m=[39m [38;5;241m4[39m[38;5;241m+[39m[38;5;241m3[39m[38;5;241m*[39mx[38;5;241m+[39mnp[38;5;241m.[39mrandom[38;5;241m.[39mrandn(m,[38;5;241m1[39m)
|
||||
|
||||
[0;31mNameError[0m: name 'm' is not defined
|
||||
NameError: name 'm' is not defined
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
import autograd.numpy as np
|
||||
from autograd import grad
|
||||
def f8(x): # Assume x is an array
|
||||
x[2] = 3
|
||||
return x*2
|
||||
|
||||
f8_grad = grad(f8)
|
||||
|
||||
x = 8.4
|
||||
|
||||
print("The derivative of f8 is:",f8_grad(x))
|
||||
------------------
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mTypeError[0m Traceback (most recent call last)
|
||||
Input [0;32mIn [13][0m, in [0;36m<cell line: 11>[0;34m()[0m
|
||||
[1;32m 7[0m f8_grad [38;5;241m=[39m grad(f8)
|
||||
[1;32m 9[0m x [38;5;241m=[39m [38;5;241m8.4[39m
|
||||
[0;32m---> 11[0m [38;5;28mprint[39m([38;5;124m"[39m[38;5;124mThe derivative of f8 is:[39m[38;5;124m"[39m,[43mf8_grad[49m[43m([49m[43mx[49m[43m)[49m)
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/wrap_util.py:20[0m, in [0;36munary_to_nary.<locals>.nary_operator.<locals>.nary_f[0;34m(*args, **kwargs)[0m
|
||||
[1;32m 18[0m [38;5;28;01melse[39;00m:
|
||||
[1;32m 19[0m x [38;5;241m=[39m [38;5;28mtuple[39m(args[i] [38;5;28;01mfor[39;00m i [38;5;129;01min[39;00m argnum)
|
||||
[0;32m---> 20[0m [38;5;28;01mreturn[39;00m [43munary_operator[49m[43m([49m[43munary_f[49m[43m,[49m[43m [49m[43mx[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[43mnary_op_args[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mnary_op_kwargs[49m[43m)[49m
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/differential_operators.py:25[0m, in [0;36mgrad[0;34m(fun, x)[0m
|
||||
[1;32m 18[0m [38;5;129m@unary_to_nary[39m
|
||||
[1;32m 19[0m [38;5;28;01mdef[39;00m [38;5;21mgrad[39m(fun, x):
|
||||
[1;32m 20[0m [38;5;250m [39m[38;5;124;03m"""[39;00m
|
||||
[1;32m 21[0m [38;5;124;03m Returns a function which computes the gradient of `fun` with respect to[39;00m
|
||||
[1;32m 22[0m [38;5;124;03m positional argument number `argnum`. The returned function takes the same[39;00m
|
||||
[1;32m 23[0m [38;5;124;03m arguments as `fun`, but returns the gradient instead. The function `fun`[39;00m
|
||||
[1;32m 24[0m [38;5;124;03m should be scalar-valued. The gradient has the same type as the argument."""[39;00m
|
||||
[0;32m---> 25[0m vjp, ans [38;5;241m=[39m [43m_make_vjp[49m[43m([49m[43mfun[49m[43m,[49m[43m [49m[43mx[49m[43m)[49m
|
||||
[1;32m 26[0m [38;5;28;01mif[39;00m [38;5;129;01mnot[39;00m vspace(ans)[38;5;241m.[39msize [38;5;241m==[39m [38;5;241m1[39m:
|
||||
[1;32m 27[0m [38;5;28;01mraise[39;00m [38;5;167;01mTypeError[39;00m([38;5;124m"[39m[38;5;124mGrad only applies to real scalar-output functions. [39m[38;5;124m"[39m
|
||||
[1;32m 28[0m [38;5;124m"[39m[38;5;124mTry jacobian, elementwise_grad or holomorphic_grad.[39m[38;5;124m"[39m)
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/core.py:10[0m, in [0;36mmake_vjp[0;34m(fun, x)[0m
|
||||
[1;32m 8[0m [38;5;28;01mdef[39;00m [38;5;21mmake_vjp[39m(fun, x):
|
||||
[1;32m 9[0m start_node [38;5;241m=[39m VJPNode[38;5;241m.[39mnew_root()
|
||||
[0;32m---> 10[0m end_value, end_node [38;5;241m=[39m [43mtrace[49m[43m([49m[43mstart_node[49m[43m,[49m[43m [49m[43mfun[49m[43m,[49m[43m [49m[43mx[49m[43m)[49m
|
||||
[1;32m 11[0m [38;5;28;01mif[39;00m end_node [38;5;129;01mis[39;00m [38;5;28;01mNone[39;00m:
|
||||
[1;32m 12[0m [38;5;28;01mdef[39;00m [38;5;21mvjp[39m(g): [38;5;28;01mreturn[39;00m vspace(x)[38;5;241m.[39mzeros()
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/tracer.py:10[0m, in [0;36mtrace[0;34m(start_node, fun, x)[0m
|
||||
[1;32m 8[0m [38;5;28;01mwith[39;00m trace_stack[38;5;241m.[39mnew_trace() [38;5;28;01mas[39;00m t:
|
||||
[1;32m 9[0m start_box [38;5;241m=[39m new_box(x, t, start_node)
|
||||
[0;32m---> 10[0m end_box [38;5;241m=[39m [43mfun[49m[43m([49m[43mstart_box[49m[43m)[49m
|
||||
[1;32m 11[0m [38;5;28;01mif[39;00m isbox(end_box) [38;5;129;01mand[39;00m end_box[38;5;241m.[39m_trace [38;5;241m==[39m start_box[38;5;241m.[39m_trace:
|
||||
[1;32m 12[0m [38;5;28;01mreturn[39;00m end_box[38;5;241m.[39m_value, end_box[38;5;241m.[39m_node
|
||||
|
||||
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/autograd/wrap_util.py:15[0m, in [0;36munary_to_nary.<locals>.nary_operator.<locals>.nary_f.<locals>.unary_f[0;34m(x)[0m
|
||||
[1;32m 13[0m [38;5;28;01melse[39;00m:
|
||||
[1;32m 14[0m subargs [38;5;241m=[39m subvals(args, [38;5;28mzip[39m(argnum, x))
|
||||
[0;32m---> 15[0m [38;5;28;01mreturn[39;00m [43mfun[49m[43m([49m[38;5;241;43m*[39;49m[43msubargs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m
|
||||
|
||||
Input [0;32mIn [13][0m, in [0;36mf8[0;34m(x)[0m
|
||||
[1;32m 3[0m [38;5;28;01mdef[39;00m [38;5;21mf8[39m(x): [38;5;66;03m# Assume x is an array[39;00m
|
||||
[0;32m----> 4[0m x[[38;5;241m2[39m] [38;5;241m=[39m [38;5;241m3[39m
|
||||
[1;32m 5[0m [38;5;28;01mreturn[39;00m x[38;5;241m*[39m[38;5;241m2[39m
|
||||
|
||||
[0;31mTypeError[0m: 'ArrayBox' object does not support item assignment
|
||||
TypeError: 'ArrayBox' object does not support item assignment
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
pip3 install tensorflow
|
||||
------------------
|
||||
|
||||
[0;36m Input [0;32mIn [14][0;36m[0m
|
||||
[0;31m pip3 install tensorflow[0m
|
||||
[0m ^[0m
|
||||
[0;31mSyntaxError[0m[0;31m:[0m invalid syntax
|
||||
|
||||
SyntaxError: invalid syntax (2357089093.py, line 1)
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 965, in async_execute_cell
|
||||
await self._check_raise_for_error(cell, cell_index, exec_reply)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 862, in _check_raise_for_error
|
||||
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
|
||||
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
||||
------------------
|
||||
# to categorical turns our integer vector into a onehot representation
|
||||
from sklearn.metrics import accuracy_score
|
||||
|
||||
# one-hot in numpy
|
||||
def to_categorical_numpy(integer_vector):
|
||||
n_inputs = len(integer_vector)
|
||||
n_categories = np.max(integer_vector) + 1
|
||||
onehot_vector = np.zeros((n_inputs, n_categories))
|
||||
onehot_vector[range(n_inputs), integer_vector] = 1
|
||||
|
||||
return onehot_vector
|
||||
|
||||
#Y_train_onehot, Y_test_onehot = to_categorical(Y_train), to_categorical(Y_test)
|
||||
Y_train_onehot, Y_test_onehot = to_categorical_numpy(Y_train), to_categorical_numpy(Y_test)
|
||||
|
||||
def feed_forward_train(X):
|
||||
# weighted sum of inputs to the hidden layer
|
||||
z_h = np.matmul(X, hidden_weights) + hidden_bias
|
||||
# activation in the hidden layer
|
||||
a_h = sigmoid(z_h)
|
||||
|
||||
# weighted sum of inputs to the output layer
|
||||
z_o = np.matmul(a_h, output_weights) + output_bias
|
||||
# softmax output
|
||||
# axis 0 holds each input and axis 1 the probabilities of each category
|
||||
exp_term = np.exp(z_o)
|
||||
probabilities = exp_term / np.sum(exp_term, axis=1, keepdims=True)
|
||||
|
||||
# for backpropagation need activations in hidden and output layers
|
||||
return a_h, probabilities
|
||||
|
||||
def backpropagation(X, Y):
|
||||
a_h, probabilities = feed_forward_train(X)
|
||||
|
||||
# error in the output layer
|
||||
error_output = probabilities - Y
|
||||
# error in the hidden layer
|
||||
error_hidden = np.matmul(error_output, output_weights.T) * a_h * (1 - a_h)
|
||||
|
||||
# gradients for the output layer
|
||||
output_weights_gradient = np.matmul(a_h.T, error_output)
|
||||
output_bias_gradient = np.sum(error_output, axis=0)
|
||||
|
||||
# gradient for the hidden layer
|
||||
hidden_weights_gradient = np.matmul(X.T, error_hidden)
|
||||
hidden_bias_gradient = np.sum(error_hidden, axis=0)
|
||||
|
||||
return output_weights_gradient, output_bias_gradient, hidden_weights_gradient, hidden_bias_gradient
|
||||
|
||||
print("Old accuracy on training data: " + str(accuracy_score(predict(X_train), Y_train)))
|
||||
|
||||
eta = 0.01
|
||||
lmbd = 0.01
|
||||
for i in range(1000):
|
||||
# calculate gradients
|
||||
dWo, dBo, dWh, dBh = backpropagation(X_train, Y_train_onehot)
|
||||
|
||||
# regularization term gradients
|
||||
dWo += lmbd * output_weights
|
||||
dWh += lmbd * hidden_weights
|
||||
|
||||
# update weights and biases
|
||||
output_weights -= eta * dWo
|
||||
output_bias -= eta * dBo
|
||||
hidden_weights -= eta * dWh
|
||||
hidden_bias -= eta * dBh
|
||||
|
||||
print("New accuracy on training data: " + str(accuracy_score(predict(X_train), Y_train)))
|
||||
------------------
|
||||
|
||||
[0;31m---------------------------------------------------------------------------[0m
|
||||
[0;31mRuntimeWarning[0m Traceback (most recent call last)
|
||||
Input [0;32mIn [26][0m, in [0;36m<cell line: 54>[0;34m()[0m
|
||||
[1;32m 53[0m lmbd [38;5;241m=[39m [38;5;241m0.01[39m
|
||||
[1;32m 54[0m [38;5;28;01mfor[39;00m i [38;5;129;01min[39;00m [38;5;28mrange[39m([38;5;241m1000[39m):
|
||||
[1;32m 55[0m [38;5;66;03m# calculate gradients[39;00m
|
||||
[0;32m---> 56[0m dWo, dBo, dWh, dBh [38;5;241m=[39m [43mbackpropagation[49m[43m([49m[43mX_train[49m[43m,[49m[43m [49m[43mY_train_onehot[49m[43m)[49m
|
||||
[1;32m 58[0m [38;5;66;03m# regularization term gradients[39;00m
|
||||
[1;32m 59[0m dWo [38;5;241m+[39m[38;5;241m=[39m lmbd [38;5;241m*[39m output_weights
|
||||
|
||||
Input [0;32mIn [26][0m, in [0;36mbackpropagation[0;34m(X, Y)[0m
|
||||
[1;32m 32[0m [38;5;28;01mdef[39;00m [38;5;21mbackpropagation[39m(X, Y):
|
||||
[0;32m---> 33[0m a_h, probabilities [38;5;241m=[39m [43mfeed_forward_train[49m[43m([49m[43mX[49m[43m)[49m
|
||||
[1;32m 35[0m [38;5;66;03m# error in the output layer[39;00m
|
||||
[1;32m 36[0m error_output [38;5;241m=[39m probabilities [38;5;241m-[39m Y
|
||||
|
||||
Input [0;32mIn [26][0m, in [0;36mfeed_forward_train[0;34m(X)[0m
|
||||
[1;32m 18[0m z_h [38;5;241m=[39m np[38;5;241m.[39mmatmul(X, hidden_weights) [38;5;241m+[39m hidden_bias
|
||||
[1;32m 19[0m [38;5;66;03m# activation in the hidden layer[39;00m
|
||||
[0;32m---> 20[0m a_h [38;5;241m=[39m [43msigmoid[49m[43m([49m[43mz_h[49m[43m)[49m
|
||||
[1;32m 22[0m [38;5;66;03m# weighted sum of inputs to the output layer[39;00m
|
||||
[1;32m 23[0m z_o [38;5;241m=[39m np[38;5;241m.[39mmatmul(a_h, output_weights) [38;5;241m+[39m output_bias
|
||||
|
||||
Input [0;32mIn [25][0m, in [0;36msigmoid[0;34m(x)[0m
|
||||
[1;32m 3[0m [38;5;28;01mdef[39;00m [38;5;21msigmoid[39m(x):
|
||||
[0;32m----> 4[0m [38;5;28;01mreturn[39;00m [38;5;241m1[39m[38;5;241m/[39m([38;5;241m1[39m [38;5;241m+[39m [43mnp[49m[38;5;241;43m.[39;49m[43mexp[49m[43m([49m[38;5;241;43m-[39;49m[43mx[49m[43m)[49m)
|
||||
|
||||
[0;31mRuntimeWarning[0m: overflow encountered in exp
|
||||
RuntimeWarning: overflow encountered in exp
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 730, in _async_poll_for_reply
|
||||
msg = await ensure_async(self.kc.shell_channel.get_msg(timeout=new_timeout))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 96, in ensure_async
|
||||
result = await obj
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_client/channels.py", line 230, in get_msg
|
||||
raise Empty
|
||||
_queue.Empty
|
||||
|
||||
During handling of the above exception, another exception occurred:
|
||||
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 949, in async_execute_cell
|
||||
exec_reply = await self.task_poll_for_reply
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 754, in _async_poll_for_reply
|
||||
await self._async_handle_timeout(timeout, cell)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 801, in _async_handle_timeout
|
||||
raise CellTimeoutError.error_from_timeout_and_cell(
|
||||
nbclient.exceptions.CellTimeoutError: A cell timed out while it was being executed, after 30 seconds.
|
||||
The message was: Cell execution timed out.
|
||||
Here is a preview of the cell contents:
|
||||
-------------------
|
||||
['CNN_keras = np.zeros((len(eta_vals), len(lmbd_vals)), dtype=object)', ' ', 'for i, eta in enumerate(eta_vals):', ' for j, lmbd in enumerate(lmbd_vals):', ' CNN = create_convolutional_neural_network_keras(input_shape, receptive_field,']
|
||||
...
|
||||
[' ', ' print("Learning rate = ", eta)', ' print("Lambda = ", lmbd)', ' print("Test accuracy: %.3f" % scores[1])', ' print()']
|
||||
-------------------
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 730, in _async_poll_for_reply
|
||||
msg = await ensure_async(self.kc.shell_channel.get_msg(timeout=new_timeout))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 96, in ensure_async
|
||||
result = await obj
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_client/channels.py", line 230, in get_msg
|
||||
raise Empty
|
||||
_queue.Empty
|
||||
|
||||
During handling of the above exception, another exception occurred:
|
||||
|
||||
Traceback (most recent call last):
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
||||
executenb(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 1204, in execute
|
||||
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 84, in wrapped
|
||||
return just_run(coro(*args, **kwargs))
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/util.py", line 62, in just_run
|
||||
return loop.run_until_complete(coro)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
|
||||
return future.result()
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 663, in async_execute
|
||||
await self.async_execute_cell(
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 949, in async_execute_cell
|
||||
exec_reply = await self.task_poll_for_reply
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 754, in _async_poll_for_reply
|
||||
await self._async_handle_timeout(timeout, cell)
|
||||
File "/Users/mhjensen/miniforge3/envs/myenv/lib/python3.9/site-packages/nbclient/client.py", line 801, in _async_handle_timeout
|
||||
raise CellTimeoutError.error_from_timeout_and_cell(
|
||||
nbclient.exceptions.CellTimeoutError: A cell timed out while it was being executed, after 30 seconds.
|
||||
The message was: Cell execution timed out.
|
||||
Here is a preview of the cell contents:
|
||||
-------------------
|
||||
['# Start importing packages', 'import pandas as pd', 'import numpy as np', 'import matplotlib.pyplot as plt', 'import tensorflow as tf']
|
||||
...
|
||||
['trainScore = model.evaluate(trainX, trainY, verbose=0)', 'print(trainScore)', 'plt.plot(df)', 'plt.plot(predicted)', 'plt.show()']
|
||||
-------------------
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "7e9869f2",
|
||||
"id": "967cdaca",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -14,7 +14,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "fca263d7",
|
||||
"id": "7f44e4d0",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -27,7 +27,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "8c3d9fea",
|
||||
"id": "3094316d",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -58,6 +58,10 @@
|
||||
"\n",
|
||||
" * These lecture notes\n",
|
||||
"\n",
|
||||
" * [Video of lecture](https://youtu.be/z0x-vgyAZUk)\n",
|
||||
"\n",
|
||||
" * [Whiteboard notes](https://github.com/CompPhysics/MachineLearning/blob/master/doc/HandWrittenNotes/2023/NotesNov9.pdf)\n",
|
||||
"\n",
|
||||
" * For a more in depth discussion on neural networks we recommend Goodfellow et al chapter 10. See also chapter 11 and 12 on practicalities and applications \n",
|
||||
"\n",
|
||||
" * Reading suggestions for implementation of RNNs: [Aurelien Geron's chapter 14](https://github.com/CompPhysics/MachineLearning/blob/master/doc/Textbooks/TensorflowML.pdf).\n",
|
||||
@@ -69,7 +73,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "d0107e8f",
|
||||
"id": "46b1e9db",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -79,7 +83,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "44ed2bb7",
|
||||
"id": "19315bd5",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -98,7 +102,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "7d202a1c",
|
||||
"id": "d03a6f44",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"editable": true
|
||||
@@ -155,7 +159,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "0fcc974f",
|
||||
"id": "e6cbd4ca",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -167,7 +171,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "693475c8",
|
||||
"id": "1ea723fc",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -182,7 +186,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "cdd8cf73",
|
||||
"id": "0ebb62df",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"editable": true
|
||||
@@ -235,7 +239,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "51ef3976",
|
||||
"id": "0fb161e1",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -250,7 +254,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "033bda9d",
|
||||
"id": "8bdb137e",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -270,7 +274,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "0a320c52",
|
||||
"id": "af61779f",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"editable": true
|
||||
@@ -324,7 +328,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "bcd8ea70",
|
||||
"id": "89f07674",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -339,7 +343,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "6fe70002",
|
||||
"id": "37c8ca05",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"editable": true
|
||||
@@ -366,7 +370,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "c4440f93",
|
||||
"id": "509bf7a9",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -380,7 +384,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "96a74e80",
|
||||
"id": "e9d06a0c",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"editable": true
|
||||
@@ -425,7 +429,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "98525677",
|
||||
"id": "ab1f9810",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -450,7 +454,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "d00d3339",
|
||||
"id": "d8a5dabe",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"editable": true
|
||||
@@ -462,7 +466,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "39d74647",
|
||||
"id": "69fd6511",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -473,7 +477,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"id": "382459a0",
|
||||
"id": "b74de9e5",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"editable": true
|
||||
@@ -485,7 +489,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "06da1caf",
|
||||
"id": "24e267e4",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -498,7 +502,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "2d846128",
|
||||
"id": "77a9c527",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -531,7 +535,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "23991e3b",
|
||||
"id": "5f6ea3f0",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -545,7 +549,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "4581b004",
|
||||
"id": "b0d324b8",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -557,7 +561,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "855fc1d5",
|
||||
"id": "d5593af9",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -569,7 +573,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "7b676376",
|
||||
"id": "e857f89e",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -581,7 +585,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "64e4f58f",
|
||||
"id": "13dc6da3",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -591,7 +595,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6bef46ee",
|
||||
"id": "0f77aa9a",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -603,7 +607,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ed7cfd1e",
|
||||
"id": "3c560ddf",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -613,7 +617,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "307589a6",
|
||||
"id": "b46686df",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -625,7 +629,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "24f17f38",
|
||||
"id": "24aec375",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -636,7 +640,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "e825c026",
|
||||
"id": "8d288b9d",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -655,7 +659,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6dcb34a4",
|
||||
"id": "e1663205",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -667,7 +671,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a975cae8",
|
||||
"id": "b34d890c",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -677,7 +681,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "d4971baf",
|
||||
"id": "14e7f314",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -689,7 +693,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a4bd001d",
|
||||
"id": "879bac6b",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -701,7 +705,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a8b1f114",
|
||||
"id": "31d2b3b7",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -713,7 +717,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "959cdbff",
|
||||
"id": "34fd7537",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -723,7 +727,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "59ee7f47",
|
||||
"id": "4bebbe84",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -735,7 +739,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "5cdba722",
|
||||
"id": "690c8d76",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -763,7 +767,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "35390ed4",
|
||||
"id": "12d8a75e",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -775,7 +779,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "b1651ea3",
|
||||
"id": "1df29154",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -800,7 +804,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "1bfac852",
|
||||
"id": "9083178e",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -818,7 +822,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "f655bb24",
|
||||
"id": "e7719466",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -829,7 +833,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "31f4ee21",
|
||||
"id": "bcddf060",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"editable": true
|
||||
@@ -872,7 +876,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "098bfaec",
|
||||
"id": "6ec55e94",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -882,7 +886,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "55cc0e20",
|
||||
"id": "690b1a08",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -909,7 +913,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "8860da9c",
|
||||
"id": "825bc136",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -920,7 +924,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"id": "7252c0b8",
|
||||
"id": "ce956b33",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"editable": true
|
||||
@@ -993,7 +997,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "fcbca2f7",
|
||||
"id": "002c4d99",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1013,7 +1017,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "1c5b70a2",
|
||||
"id": "6572c07f",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1029,7 +1033,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "29c129fe",
|
||||
"id": "fbd8e269",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1051,7 +1055,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "c2bc1aa3",
|
||||
"id": "919bb09e",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1069,7 +1073,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "01ef7e17",
|
||||
"id": "6e3360db",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1115,7 +1119,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "8dd26bf6",
|
||||
"id": "0f284cbd",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1136,7 +1140,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "3b42d5ef",
|
||||
"id": "b5e9785e",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1197,7 +1201,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "2f8de715",
|
||||
"id": "50a43c30",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1222,7 +1226,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "9998cb2c",
|
||||
"id": "f3e0d31b",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1241,7 +1245,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "45dfbeff",
|
||||
"id": "b1571231",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1265,7 +1269,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "141b8f50",
|
||||
"id": "e7886dd3",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1347,7 +1351,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "fbadc1e0",
|
||||
"id": "f878b195",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1363,7 +1367,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"id": "9365f92f",
|
||||
"id": "1889da48",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"editable": true
|
||||
@@ -1402,7 +1406,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "55c2aa23",
|
||||
"id": "5bf3bea4",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1446,7 +1450,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"id": "b57a3099",
|
||||
"id": "6fc9b3dd",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"editable": true
|
||||
@@ -1529,7 +1533,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "0b519f6c",
|
||||
"id": "6b02bff4",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1540,7 +1544,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"id": "82db8594",
|
||||
"id": "7030f585",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"editable": true
|
||||
@@ -1642,7 +1646,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "4711b0d4",
|
||||
"id": "53dc1510",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1664,7 +1668,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"id": "22123a0f",
|
||||
"id": "62aa2c1c",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"editable": true
|
||||
@@ -1761,7 +1765,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "50cd4d20",
|
||||
"id": "56fb2d92",
|
||||
"metadata": {
|
||||
"editable": true
|
||||
},
|
||||
@@ -1787,7 +1791,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"id": "5c3d5a53",
|
||||
"id": "145ed525",
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"editable": true
|
||||
|
||||
Reference in New Issue
Block a user