44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
# 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)
|