diff --git a/doc/src/week38/DataFiles/chddata.csv b/doc/src/week38/DataFiles/chddata.csv new file mode 100644 index 000000000..591f7ad32 --- /dev/null +++ b/doc/src/week38/DataFiles/chddata.csv @@ -0,0 +1,100 @@ +1 21 1 0 +2 23 1 0 +3 25 1 1 +4 29 1 0 +5 21 1 0 +6 24 1 0 +7 27 1 0 +8 29 1 0 +9 28 1 0 +10 26 1 0 +11 30 2 0 +12 31 2 0 +13 31 2 0 +14 31 2 1 +15 32 2 0 +16 34 2 0 +17 34 2 0 +18 31 2 0 +19 32 2 0 +20 32 2 0 +21 33 2 0 +22 34 2 0 +23 31 2 1 +24 30 2 0 +25 33 2 0 +26 36 3 1 +27 35 3 0 +28 35 3 0 +29 38 3 0 +30 37 3 1 +31 36 3 0 +32 35 3 0 +33 39 3 0 +34 39 3 0 +35 38 3 1 +36 37 3 0 +37 37 3 0 +38 40 4 0 +39 41 4 1 +40 44 4 0 +41 44 4 0 +42 43 4 1 +43 42 4 0 +44 41 4 0 +45 40 4 1 +46 42 4 0 +47 42 4 0 +48 43 4 0 +49 44 4 1 +50 44 4 0 +51 42 4 0 +52 41 4 1 +53 45 5 0 +54 45 5 1 +55 49 5 0 +56 48 5 1 +57 47 5 0 +58 49 5 1 +59 46 5 1 +60 45 5 0 +61 49 5 1 +62 48 5 0 +63 47 5 1 +64 46 5 0 +65 47 5 0 +66 50 6 1 +67 51 6 1 +68 51 6 0 +69 54 6 1 +70 53 6 1 +71 51 6 0 +72 52 6 1 +73 54 6 0 +74 55 7 1 +75 56 7 1 +76 58 7 0 +77 59 7 1 +78 59 7 1 +79 58 7 0 +80 55 7 1 +81 56 7 1 +82 57 7 1 +83 58 7 1 +84 59 7 0 +85 55 7 1 +86 56 7 1 +87 57 7 1 +88 58 7 0 +89 59 7 1 +90 56 7 1 +91 60 8 1 +92 65 8 1 +93 67 8 1 +94 66 8 0 +95 63 8 1 +96 61 8 1 +97 69 8 1 +98 65 8 1 +99 64 8 1 +100 63 8 0 \ No newline at end of file diff --git a/doc/src/week38/DataFiles/chddata.csv~ b/doc/src/week38/DataFiles/chddata.csv~ new file mode 100644 index 000000000..9c52675fd --- /dev/null +++ b/doc/src/week38/DataFiles/chddata.csv~ @@ -0,0 +1,101 @@ +ID Age Agegroup CHD +1 21 1 0 +2 23 1 0 +3 25 1 1 +4 29 1 0 +5 21 1 0 +6 24 1 0 +7 27 1 0 +8 29 1 0 +9 28 1 0 +10 26 1 0 +11 30 2 0 +12 31 2 0 +13 31 2 0 +14 31 2 1 +15 32 2 0 +16 34 2 0 +17 34 2 0 +18 31 2 0 +19 32 2 0 +20 32 2 0 +21 33 2 0 +22 34 2 0 +23 31 2 1 +24 30 2 0 +25 33 2 0 +26 36 3 1 +27 35 3 0 +28 35 3 0 +29 38 3 0 +30 37 3 1 +31 36 3 0 +32 35 3 0 +33 39 3 0 +34 39 3 0 +35 38 3 1 +36 37 3 0 +37 37 3 0 +38 40 4 0 +39 41 4 1 +40 44 4 0 +41 44 4 0 +42 43 4 1 +43 42 4 0 +44 41 4 0 +45 40 4 1 +46 42 4 0 +47 42 4 0 +48 43 4 0 +49 44 4 1 +50 44 4 0 +51 42 4 0 +52 41 4 1 +53 45 5 0 +54 45 5 1 +55 49 5 0 +56 48 5 1 +57 47 5 0 +58 49 5 1 +59 46 5 1 +60 45 5 0 +61 49 5 1 +62 48 5 0 +63 47 5 1 +64 46 5 0 +65 47 5 0 +66 50 6 1 +67 51 6 1 +68 51 6 0 +69 54 6 1 +70 53 6 1 +71 51 6 0 +72 52 6 1 +73 54 6 0 +74 55 7 1 +75 56 7 1 +76 58 7 0 +77 59 7 1 +78 59 7 1 +79 58 7 0 +80 55 7 1 +81 56 7 1 +82 57 7 1 +83 58 7 1 +84 59 7 0 +85 55 7 1 +86 56 7 1 +87 57 7 1 +88 58 7 0 +89 59 7 1 +90 56 7 1 +91 60 8 1 +92 65 8 1 +93 67 8 1 +94 66 8 0 +95 63 8 1 +96 61 8 1 +97 69 8 1 +98 65 8 1 +99 64 8 1 +100 63 8 0 \ No newline at end of file diff --git a/doc/src/week38/chddata.py b/doc/src/week38/chddata.py new file mode 100644 index 000000000..417dffa6c --- /dev/null +++ b/doc/src/week38/chddata.py @@ -0,0 +1,43 @@ +# 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 +# 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 two arrays with density and energies +chd = pd.read_csv(infile, names=('ID', 'Age', 'Agegroup', 'CHD')) +display(chd) +output = chd['CHD'] +age = chd['Age'] +agegroup = chd['Agegroup'] +numberID = chd['ID'] +display(output) diff --git a/doc/src/week38/chddata.py~ b/doc/src/week38/chddata.py~ new file mode 100644 index 000000000..7dfb6f364 --- /dev/null +++ b/doc/src/week38/chddata.py~ @@ -0,0 +1,42 @@ +# 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 +# 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 two arrays with density and energies +chd = pd.read_csv(infile, names=('ID', 'Age', 'Agegroup', 'CHD')) +output = chd['CHD'] +age = chd['Age'] +agegroup = chd['Agegroup'] +numberID = chd['ID'] +display(output)