IOT based healthcare application using Generalized Linear model, Random forest and Decision trees

Heart disease has received a lot of attention in medical research as one of the many life-threatening diseases. The diagnosis of heart disease is a difficult task which when automated can offer better predictions about the patient's heart condition so that further treatment can be made effective. The signs, symptoms, and physical examination of the patient are usually used to make a diagnosis of heart disease. Resting blood pressure, cholesterol, age, sex, type of chest pain, fasting blood sugar, ST depression, and exercise-induced angina can all help to predict the likelihood of having a heart attack. Using models like Decision trees, Random forest and GLM to train on the given dataset and view the predicted class - 0 = less chance of heart attack, 1 = more chance of heart attack.

PROCEDURE:

  1. Import the packages Rplot, RColorBrewer, Rattle and randomForest
  2. Download and read the dataset from Kaggle
  3. View the statistics of the variables in the dataset using function “summary”
  4. Analyse the data, specific to resting blood pressure
  5. Using the “cor” function, find the correlation between resting blood pressure and age
  6. Construct a Logistic regression model using GLM and view the output plots
  7. Encode the target values into categorical values
  8. Split the dataset into training and testing data in the ratio 70 : 30
  9. Construct a decision tree model 10.Target variable is categorised based on resting blood pressure, serum cholesterol and maximum heart rate achieved
  10. Plot the decision tree and view the output
  11. Devise a Random forest model based on the relationship between resting blood pressure, old peak and chest pain type
  12. View the confusion matrix and importance of each predictor

Installing the necessary packages

Loading all the necessary Libraries

Loading and Understanding the dataset

Analyze the Correlation between resting BP and age

Constructing the Logistic regression Model

Constructing the Decision Tree Model

Constructing the Random Forest Model