Heart Disease Prediction: Machine Learning

3–4 minutes

read

This machine learning exercise is to predict whether a person is healthy or at risk of heart disease. It starts with collecting heart-related data such as age, blood pressure, and cholesterol levels. After cleaning and preparing the data through preprocessing, it’s split into training and testing sets. A logistic regression model is then trained to recognize patterns in the data. Once trained, the model can take new patient information and accurately predict if the individual is likely to be healthy or may have heart disease — helping enable early warning and better health decisions.

Work Flow : Heart Data >> Data Pre processing >> Train Test Split>> Logistic Regression

New Data >> Trained Logistic Regression >> Healthy or heart Disease

  • # loading the csv data to a Pandas dataframe

link to practice the dataset :

https://www.kaggle.com/datasets/johnsmith88/heart-disease-dataset

  • # print first 5 rows of the dataset
  • # print last 5 rows of the dataset
  • # find the shape of the datset
  • # find the info of the dataset
  • #checking for missing values
  • # statistical measures about the data
  • # checking the distribution of Target Variable
  • 1 –> Defective heart
  • 0 –> Healthy heart
  • # training the LogisticRegression model with Training Data
  • # accuracy on training data
  • # accuracy on test data
  • # change the input data to a numpy array
  • # reshape the numpy array as we are predicting for only on instance

Disclaimer: All information provided on www.academicbrainsolutions.com is for general educational purposes only. While we strive to provide accurate and up-to-date information, we make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability, or availability of the information contained on the blog/website for any purpose. Any reliance you place on such information is therefore strictly at your own risk. The information provided on www.academicbrainsolutions.com is not intended to be a substitute for professional educational advice, diagnosis, or treatment. Always seek the advice of your qualified educational institution, teacher, or other qualified professional with any questions you may have regarding a particular subject or educational matter. In no event will we be liable for any loss or damage including without limitation, indirect or consequential loss or damage, or any loss or damage whatsoever arising from loss of data or profits arising out of, or in connection with, the use of this blog/website. Our blog/website may contain links to external websites that are not provided or maintained by us. We do not guarantee the accuracy, relevance, timeliness, or completeness of any information on these external websites. Comments are welcome and encouraged on www.academicbrainsolutions.com is but please note that we reserve the right to edit or delete any comments submitted to this blog/website without notice due to: Comments deemed to be spam or questionable spam, Comments including profanity, Comments containing language or concepts that could be deemed offensive, Comments that attack a person individually.By using www.academicbrainsolutions.com you hereby consent to our disclaimer and agree to its terms. This disclaimer is subject to change at any time without prior notice

Leave a comment