## Heart Disease Dataset:

This data set dates from 1988 and consists of four databases: Cleveland, Hungary, Switzerland, and Long Beach V. It contains 76 attributes, including the predicted attribute, but all published experiments refer to using a subset of 14 of them. The “target” field refers to the presence of heart disease in the patient. It is integer valued 0 = no disease and 1 = disease.

#### Attribute Information:

    age
    sex
    chest pain type (4 values)
    resting blood pressure
    serum cholestoral in mg/dl
    fasting blood sugar > 120 mg/dl
    resting electrocardiographic results (values 0,1,2)
    maximum heart rate achieved
    exercise induced angina
    oldpeak = ST depression induced by exercise relative to rest
    the slope of the peak exercise ST segment
    number of major vessels (0-3) colored by flourosopy
    thal: 0 = normal; 1 = fixed defect; 2 = reversable defect
    The names and social security numbers of the patients were recently removed from the database, replaced with dummy values.
    

```{r, message=FALSE, warning=FALSE}
library(tidyverse)
library(dplyr)
library(caret)
library(ggplot2)

url <- "https://mlcourseukzn.github.io/PDFLectures/HeartDiseaseDataset.csv"
heartdata <- read.csv(url)

```



## Heart Failure Prediction Dataset:

Cardiovascular diseases (CVDs) are the number 1 cause of death globally, taking an estimated 17.9 million lives each year, which accounts for 31% of all deaths worldwide. Four out of 5CVD deaths are due to heart attacks and strokes, and one-third of these deaths occur prematurely in people under 70 years of age. Heart failure is a common event caused by CVDs and this dataset contains 11 features that can be used to predict a possible heart disease.

People with cardiovascular disease or who are at high cardiovascular risk (due to the presence of one or more risk factors such as hypertension, diabetes, hyperlipidaemia or already established disease) need early detection and management wherein a machine learning model can be of great help.

#### Attribute Information:

    Age: age of the patient [years]
    Sex: sex of the patient [M: Male, F: Female]
    ChestPainType: chest pain type [TA: Typical Angina, ATA: Atypical Angina, NAP: Non-Anginal Pain, ASY: Asymptomatic]
    RestingBP: resting blood pressure [mm Hg]
    Cholesterol: serum cholesterol [mm/dl]
    FastingBS: fasting blood sugar [1: if FastingBS > 120 mg/dl, 0: otherwise]
    RestingECG: resting electrocardiogram results [Normal: Normal, ST: having ST-T wave abnormality (T wave inversions and/or ST elevation or depression of > 0.05 mV), LVH: showing probable or definite left ventricular hypertrophy by Estes' criteria]
    MaxHR: maximum heart rate achieved [Numeric value between 60 and 202]
    ExerciseAngina: exercise-induced angina [Y: Yes, N: No] Oldpeak: oldpeak = ST [Numeric value measured in depression]
    ST_Slope: the slope of the peak exercise ST segment [Up: upsloping, Flat: flat, Down: downsloping]
    HeartDisease: output class [1: heart disease, 0: Normal]

```{r}
url2 <- "https://mlcourseukzn.github.io/PDFLectures/HeartFailurePredictionDataset.csv"
heartfailure <- read.csv(url2)
```


As a data scientist you have been tasked to analyze and predict whether a patient has a heart disease (1) or not (0) using the Heart Disease Data **OR** predict the heart failure (1) or normal (0) using the Heart Failure Data.

Q1: Provide suitable descriptive statistics about the data.

Q2: Provide some visualization plots that describing the distribution of the data.

Q3: Split the data into training and testing sets using 70:30 ratio.

Q4: fit the following models 

    a) Logistic regression
    b) Decision trees
    c) Naive Bayes
    d) Random forests
    
Q5: Compare the models using different evaluation metrics.

Q6: Plot ROC curve for all models, and calculate the AUC.

Q7: Write a brief report on the results. 
