125 lines
7.3 KiB
Plaintext
125 lines
7.3 KiB
Plaintext
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 647, 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
|
|
|
|
# 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;31mFileNotFoundError[0m Traceback (most recent call last)
|
|
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/matplotlib/style/core.py:137[0m, in [0;36muse[0;34m(style)[0m
|
|
[1;32m 136[0m [38;5;28;01mtry[39;00m:
|
|
[0;32m--> 137[0m style [38;5;241m=[39m [43m_rc_params_in_file[49m[43m([49m[43mstyle[49m[43m)[49m
|
|
[1;32m 138[0m [38;5;28;01mexcept[39;00m [38;5;167;01mOSError[39;00m [38;5;28;01mas[39;00m err:
|
|
|
|
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/matplotlib/__init__.py:870[0m, in [0;36m_rc_params_in_file[0;34m(fname, transform, fail_on_error)[0m
|
|
[1;32m 869[0m rc_temp [38;5;241m=[39m {}
|
|
[0;32m--> 870[0m [38;5;28;01mwith[39;00m _open_file_or_url(fname) [38;5;28;01mas[39;00m fd:
|
|
[1;32m 871[0m [38;5;28;01mtry[39;00m:
|
|
|
|
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/contextlib.py:119[0m, in [0;36m_GeneratorContextManager.__enter__[0;34m(self)[0m
|
|
[1;32m 118[0m [38;5;28;01mtry[39;00m:
|
|
[0;32m--> 119[0m [38;5;28;01mreturn[39;00m [38;5;28;43mnext[39;49m[43m([49m[38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mgen[49m[43m)[49m
|
|
[1;32m 120[0m [38;5;28;01mexcept[39;00m [38;5;167;01mStopIteration[39;00m:
|
|
|
|
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/matplotlib/__init__.py:847[0m, in [0;36m_open_file_or_url[0;34m(fname)[0m
|
|
[1;32m 846[0m fname [38;5;241m=[39m os[38;5;241m.[39mpath[38;5;241m.[39mexpanduser(fname)
|
|
[0;32m--> 847[0m [38;5;28;01mwith[39;00m [38;5;28;43mopen[39;49m[43m([49m[43mfname[49m[43m,[49m[43m [49m[43mencoding[49m[38;5;241;43m=[39;49m[38;5;124;43m'[39;49m[38;5;124;43mutf-8[39;49m[38;5;124;43m'[39;49m[43m)[49m [38;5;28;01mas[39;00m f:
|
|
[1;32m 848[0m [38;5;28;01myield[39;00m f
|
|
|
|
[0;31mFileNotFoundError[0m: [Errno 2] No such file or directory: 'seaborn'
|
|
|
|
The above exception was the direct cause of the following exception:
|
|
|
|
[0;31mOSError[0m Traceback (most recent call last)
|
|
Cell [0;32mIn[1], line 14[0m
|
|
[1;32m 12[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
|
|
[1;32m 13[0m [38;5;28;01mfrom[39;00m [38;5;21;01mpylab[39;00m [38;5;28;01mimport[39;00m plt, mpl
|
|
[0;32m---> 14[0m [43mplt[49m[38;5;241;43m.[39;49m[43mstyle[49m[38;5;241;43m.[39;49m[43muse[49m[43m([49m[38;5;124;43m'[39;49m[38;5;124;43mseaborn[39;49m[38;5;124;43m'[39;49m[43m)[49m
|
|
[1;32m 15[0m mpl[38;5;241m.[39mrcParams[[38;5;124m'[39m[38;5;124mfont.family[39m[38;5;124m'[39m] [38;5;241m=[39m [38;5;124m'[39m[38;5;124mserif[39m[38;5;124m'[39m
|
|
[1;32m 17[0m [38;5;66;03m# Where to save the figures and data files[39;00m
|
|
|
|
File [0;32m~/miniforge3/envs/myenv/lib/python3.9/site-packages/matplotlib/style/core.py:139[0m, in [0;36muse[0;34m(style)[0m
|
|
[1;32m 137[0m style [38;5;241m=[39m _rc_params_in_file(style)
|
|
[1;32m 138[0m [38;5;28;01mexcept[39;00m [38;5;167;01mOSError[39;00m [38;5;28;01mas[39;00m err:
|
|
[0;32m--> 139[0m [38;5;28;01mraise[39;00m [38;5;167;01mOSError[39;00m(
|
|
[1;32m 140[0m [38;5;124mf[39m[38;5;124m"[39m[38;5;132;01m{[39;00mstyle[38;5;132;01m!r}[39;00m[38;5;124m is not a valid package style, path of style [39m[38;5;124m"[39m
|
|
[1;32m 141[0m [38;5;124mf[39m[38;5;124m"[39m[38;5;124mfile, URL of style file, or library style name (library [39m[38;5;124m"[39m
|
|
[1;32m 142[0m [38;5;124mf[39m[38;5;124m"[39m[38;5;124mstyles are listed in `style.available`)[39m[38;5;124m"[39m) [38;5;28;01mfrom[39;00m [38;5;21;01merr[39;00m
|
|
[1;32m 143[0m filtered [38;5;241m=[39m {}
|
|
[1;32m 144[0m [38;5;28;01mfor[39;00m k [38;5;129;01min[39;00m style: [38;5;66;03m# don't trigger RcParams.__getitem__('backend')[39;00m
|
|
|
|
[0;31mOSError[0m: 'seaborn' is not a valid package style, path of style file, URL of style file, or library style name (library styles are listed in `style.available`)
|
|
OSError: 'seaborn' is not a valid package style, path of style file, URL of style file, or library style name (library styles are listed in `style.available`)
|
|
|