90 lines
4.0 KiB
Plaintext
90 lines
4.0 KiB
Plaintext
Traceback (most recent call last):
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
|
executenb(
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/client.py", line 1087, in execute
|
|
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/util.py", line 74, in wrapped
|
|
return just_run(coro(*args, **kwargs))
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/util.py", line 53, in just_run
|
|
return loop.run_until_complete(coro)
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
|
|
return future.result()
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/client.py", line 540, in async_execute
|
|
await self.async_execute_cell(
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/client.py", line 832, in async_execute_cell
|
|
self._check_raise_for_error(cell, exec_reply)
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/client.py", line 740, 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)
|
|
[0;32m<ipython-input-1-a77d5ac269b2>[0m in [0;36m<module>[0;34m[0m
|
|
[1;32m 38[0m [0mplt[0m[0;34m.[0m[0msavefig[0m[0;34m([0m[0mimage_path[0m[0;34m([0m[0mfig_id[0m[0;34m)[0m [0;34m+[0m [0;34m".png"[0m[0;34m,[0m [0mformat[0m[0;34m=[0m[0;34m'png'[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
|
|
[1;32m 39[0m [0;34m[0m[0m
|
|
[0;32m---> 40[0;31m [0minfile[0m [0;34m=[0m [0mopen[0m[0;34m([0m[0mdata_path[0m[0;34m([0m[0;34m"chddata.csv"[0m[0;34m)[0m[0;34m,[0m[0;34m'r'[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
|
|
[0m[1;32m 41[0m [0;34m[0m[0m
|
|
[1;32m 42[0m [0;31m# Read the chd data as csv file and organize the data into arrays with age group, age, and chd[0m[0;34m[0m[0;34m[0m[0;34m[0m[0m
|
|
|
|
[0;31mFileNotFoundError[0m: [Errno 2] No such file or directory: 'DataFiles/chddata.csv'
|
|
FileNotFoundError: [Errno 2] No such file or directory: 'DataFiles/chddata.csv'
|
|
|