VOOZH about

URL: https://www.geeksforgeeks.org/deep-learning/heart-disease-prediction-using-ann/

⇱ Heart Disease Prediction using ANN - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Heart Disease Prediction using ANN

Last Updated : 2 Jul, 2025

Deep Learning is a technology of which mimics a human brain in the sense that it consists of multiple neurons with multiple layers like a human brain. The network so formed consists of an input layer, an output layer, and one or more hidden layers. The network tries to learn from the data that is fed into it and then performs predictions accordingly. The most basic type of neural network is the ANN (Artificial Neural Network). The ANN does not have any special structure, it just comprises of multiple neural layers to be used for prediction. Let's build a model that predicts whether a person has heart disease or not by using ANN.

About the data:

In the dataset, we have 13 columns in which we are given different attributes such as sex, age, cholesterol level, etc. and we are given a target column which tells us whether that person has heart disease or not. We will keep all the columns as independent variables other than the target column because it will be our dependent variable. We will build an ANN which will predict whether a person has heart disease or not given other attributes of the person.

Code: Importing Libraries


Code: Importing Dataset

Data Description:


👁 1-min


Code: Check for null values

Output:

0
age False
sex False
cp False
trestbps False
chol False
fbs False
restecg False
thalach False
exang False
oldpeak False
slope False
ca False
thal False
target False

dtype: bool

Assign Dependent and Independent variable

Code : Split data into Train and Test dataset

Code: Scale the data.

Code: Building the Model

Code : Fitting the Model

👁 Image

Code : Performing prediction and rescaling

Code: Confusion Matrix

👁 2
Confusion Matrix


Code: Accuracy


Output:

87.91208791208791

We will get accuracy approximately around 88%.

Get complete notebook link :

Comment