Heart Disease Prediction Model

NOCODING AI
NOCODING AI

--

This tutorial uses the Heart Disease dataset provided by the Kaggle Datasets to implement an artificial intelligence model that predicts heart disease with no coding AI.

Experience nocoding AI

https://www.nocodingai.com

Introduction

In this tutorial, we train models that predict “heart disease” through patient medical data.
To this end, we will go through the following steps.

Load the original data required for training.
The loaded data is processed through a data preprocessor.
Define the architecture of the model.
The model is trained and trained to deduce whether there is heart disease or not.

Learning

  • How to preprocess data in nocodingAI
  • How to Define Artificial Intelligence Model Architecture in NodingAI
  • a method of reasoning using a model trained in nodingAI

A necessary thing

latest version of chrome web browser or other latest browser
Be familiar with the basic usage of nocodingAI.
If you need to introduce or learn basic usage, please refer to the nocodingAI Getting Started Guide.

데이터 다운로드

The dataset to be used in this tutorial is the HeartDisease dataset.
The HeartDisease dataset is a collection of information on heart disease patients at the Hungarian Heart Disease Research Institute, Zurich University Hospital in Switzerland, Basel University Hospital in Switzerland, and VA Medical Center, with their names and resident registration numbers deleted.

Please go to the link below, examine the data carefully, and click the download button to get the ‘heart.csv’ file.

This is medical data including age, gender, presence of angina, resting blood pressure, cholesterol level, blood sugar level, electrocardiographic results, and maximum heart rate. For more details, please check the link above.

Import Data

First, please access the NOCODING AI page and sign up and log in.

Then, select Data Cleaner from the left menu and click on Create New.

In Create Dataset, please enter a name and description for the dataset and change the Data type to CSV. Click on Empty Dataset to create an empty dataset.

By using Drag and Drop, you can import ‘heart.csv’ and the data will be imported as shown below. You can preview the data and also change the name of the columns.

The data provided by Kaggle is already cleaned, so there is no need to make any modifications.

If there is a need to remove null values or zeroes from the data, you can use the Preprocessing tool to clean the data.

Press the floppy disk shaped save button to save the dataset.

Create Model Architecture

In this section, we will introduce how to configure the model architecture. The model architecture represents the structure that ‘what functions are executed when the model runs’ or ‘the algorithm that the model uses to calculate the answer’.

In the model designer, click on Create Model, enter the model name and select Empty Model to create an empty model.

On the left side of the model designer screen, there is My Datasets where you can find the datasets you created. Click on it and set the ratio of the data used for Training and Validation in the dataset. The default value is 9:1. Let’s make it 8:2.

Move to the Layers tab. You will see the Keras Layers provided for creating layers.

Scroll down the mouse wheel to find Input/Output and place Input Layer and Output Layer.

In the shape of the Input layer node, enter 13. This is because we will use 13 columns from the Heart Disease Dataset as input values.

Next, we will add a Dense Layer from the Basic group. Dense Layer is a layer used in multi-layer perceptron networks, which connects both input and output. Even if you don’t know about it, you can think of it as a layer that transforms the input shape into the specified number of units.

First, create 7 Dense Layers and then connect them from Input to Output in the middle.

Click on Advanced for each node and set the parameters as follows.

  • Set the first Dense Layer to units: 20, activation: relu.
  • Set the second Dense Layer to units: 40, activation: relu.
  • Set the third Dense Layer to units: 60, activation: relu.
  • Set the fourth Dense Layer to units: 40, activation: relu.
  • Set the fifth Dense Layer to units: 20, activation: relu.
  • Set the sixth Dense Layer to units: 10, activation: relu.
  • Set the last Dense Layer to units: 1, activation: sigmoid.

The reason why the units in the last Dense Layer is 1 is because it only indicates whether there is heart disease or not. This model classifies heart disease as a probability.

The activation function is used for backpropagation training and extracting feature values in deep learning. Here, we put in the specified values

The model architecture is now ready. Press the save button to save the created model architecture and prevent it from disappearing.

Press ‘Start Training’. A pop-up window will appear where you can set the training parameters as shown below.

In this section, we will set the training parameters. Since the input type is CSV, we will change the InputType and OutputType to text. We will set the optimizer to ADAM, the loss to binaryCrossentropy, and the metrics to accuracy. The learning rate is set to 0.001. This value should not be too low or too high, as a low learning rate will cause the training time to be too long, and a high learning rate may prevent the training from progressing at all.

In this step, we set the number of times we will train the entire dataset, known as epochs, to 200. The batch size determines how many data points will be used in one training iteration; a larger batch size uses more memory. A suitable batch size is needed, we set it to 32. We select 13 data points from the xColumn as the training data and one data point from the yColumn as the result label.

Select the target column as the y value (label) and set the rest as the x value (input values), and then click OK.

It takes quite a long time, so use a GPU with faster speed.

Training has started. You can see the current situation by clicking on Training Results. The status shows that it is starting training. GPU usage GREDIT is deducted after training starts. After waiting for a little while, training will begin.

You can check the training graph by clicking on the Training Graph button.

After training, use the trained model to create a web app from the App Builder menu.

Creating a web app

Create a Blank Project by entering a Title and Description, just as before.

This is the default screen

First, select the model you want to connect to. In the AI Models group, select the model we just trained. Select the model named Heart Disease, and the model details will appear in the right tab. You can view the graph and select the desired epoch with the desired value

We will select the 192nd epoch as it has an accuracy of 0.9461.

We will now add a Title and Text element from the Element group and place them on the screen. Then, we will customize the content of the elements in the right-hand side Customizing tab.

Drag and drop Input(Text) and Output(Rows) from the Input group onto the screen to place them.

In the model details, select the component ID for the text that will go into the Input and the component ID for the output to automatically convert it to the appropriate data.

Now let’s press the Publish button to deploy the web app.

If successful, a web address will appear as shown below.

Copy the URL and open it in a new window.

Enter the values of the existing data to perform the inference.

If you have data that can be verified, you can try inferencing by entering one by one.

That’s it. You don’t have to know about a single word of code.

Happily use nocodingAI. thanks.

--

--