TECH

## Machine Learning Project: Heart Disease Prediction System (HDPS) using Logistic Regression from Scratch

#### This article will provide you with a complete Machine Learning Project named Heart Disease Prediction System which uses Logistic Regression algorithm from Scratch.

BY RABINDRA THAPA
05 FEB 2022 • 4 MIN READ
Heart Disease Prediction System Homepage

Heart Disease Prediction System (HDPS) is a web-based Machine Learning Project with a user-friendly interface that is built with Django. It predicts whether the patient has heart disease or not using Machine Learning (ML) Algorithm Logistic Regression.

#### Features of HDPS

• Predict Heart Disease with probability
• Login/Signup System (Exclusive Features after Signup)
• Implementation of Logistic Regression from Scratch
• Simple and clean User Interface
• Separate dashboard for Admin and User
• Send feedback to the system
• FREE!

#### Tools and Technology Used to build HDPS

Front-End Tools

• HTML (defines the meaning and structure of web content)
• CSS (presentation and design of web pages)
• Materialize CSS (Modern responsive CSS framework based on Material Design)
• Javascript (To convert a static web page into an interactive)
• jQuery (Fast, small, and feature-rich JavaScript library)

Back-End Tools

• Python (Libraries: NumPy, pandas, sklearn)
• Django (python based web framework)

Note

• NumPy is used to manipulate a large collection of high-level mathematical functions
• panadas is used for data manipulation and analysis.
• sklearn is a very popular machine learning library

For HDPS Demonstration follow this video

HDPS Project Demonstration Video

For Explanation of HDPS follow this video

HDPS Project Explanation Video

#### Algorithm Used

To train the model, the Machine Learning algorithm Logistic Regression is used. You can easily import Logistic Regression from scikit-learn library, but the project has implemented Logistic Regression right from scratch.

Logistic regression is a supervised learning classification algorithm used for predicting the categorical dependent variable using a given set of independent variables.

Logistic regression predicts the output of a categorical dependent variable. Therefore the outcome must be a categorical or discrete value. It can be either Yes or No, 0 or 1, true or False, etc. but instead of giving the exact value as 0 and 1, it gives the probabilistic values which lie between 0 and 1

Logistic regression basic concept

In HDPS data is extracted from the patient which includes different 13 parameters like blood pressure, age, sex, etc. This data is then fed to the trained model which provides the outcome in the form of probability ranging value 0-1.

13 different attributes include :

13 different attributes of HDPS

For source code please refer to this GitHub Repo.

#### Detail process design of HDPS

All Machine Learning algorithm needs training to predict the result. Firstly, the model is trained with data set, which was collected from the Kaggle UCI repository. After training our model the model now becomes ready to take input and process it.

Process Design of HDPS

The input is given to the trained model. The model classifies data based on probability, a value greater than 0.5 is considered to have a high probability of heart disease, and a value less than 0.5 has less probability of having heart disease. The result is then displayed to the user.

#### Accuracy of the system

The accuracy of a system is given by the number of correct predictions by the total number of predictions made multiplied by 100.

The accuracy of HDPS is 71.287% which is not that high due to the low number of datasets and implementation of the algorithm from scratch.

Accuracy of Heart Disease Prediction System (HDPS)

True Positive: True Positive are those examples that were actually positives and were predicted as positives. True Positive of our model was 29.

False Positive: False Positives also known as Type 1 error are those examples that were actually negatives but our model predicted them as positive. False Positive of our model was 6.

False Negative: False Negatives also known as Type 2 error are those examples that were actually positives but our model predicted them as negative. False Negative of our model was 23.

#### Limitations of HDPS

• Uses only one ML algorithm
• User should know the exact values of 13 attributes
• HDPS only predicts overall Heart Disease not the specific type of Heart Disease
• Needs an Internet connection to work.