Files
FYS-STK4155/doc/LectureNotes/_build/html/reports/chapter4.log
T
Morten Hjorth-Jensen e9d6ea5784 added slides
2024-11-03 14:40:38 +01:00

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()
------------------
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/matplotlib/style/core.py:137, in use(style)
 136 try:
--> 137 style = _rc_params_in_file(style)
 138 except OSError as err:
File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/matplotlib/__init__.py:870, in _rc_params_in_file(fname, transform, fail_on_error)
 869 rc_temp = {}
--> 870 with _open_file_or_url(fname) as fd:
 871 try:
File ~/miniforge3/envs/myenv/lib/python3.9/contextlib.py:119, in _GeneratorContextManager.__enter__(self)
 118 try:
--> 119 return next(self.gen)
 120 except StopIteration:
File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/matplotlib/__init__.py:847, in _open_file_or_url(fname)
 846 fname = os.path.expanduser(fname)
--> 847 with open(fname, encoding='utf-8') as f:
 848 yield f
FileNotFoundError: [Errno 2] No such file or directory: 'seaborn'
The above exception was the direct cause of the following exception:
OSError Traceback (most recent call last)
Cell In[1], line 14
 12 from IPython.display import display
 13 from pylab import plt, mpl
---> 14 plt.style.use('seaborn')
 15 mpl.rcParams['font.family'] = 'serif'
 17 # Where to save the figures and data files
File ~/miniforge3/envs/myenv/lib/python3.9/site-packages/matplotlib/style/core.py:139, in use(style)
 137 style = _rc_params_in_file(style)
 138 except OSError as err:
--> 139 raise OSError(
 140 f"{style!r} is not a valid package style, path of style "
 141 f"file, URL of style file, or library style name (library "
 142 f"styles are listed in `style.available`)") from err
 143 filtered = {}
 144 for k in style: # don't trigger RcParams.__getitem__('backend')
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`)
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`)