1 Introduction

Coronary heart disease (CHD) is a state of irregular cardiac rhythms arising due to blockage in the coronary arteries and blood vessels that obstructs the supply of oxygenated blood to the different parts of the body. The risk of heart disease increases due to non-detection at an early stage or ignorance of risk factors involved. About 795 thousand people in US [1] suffer from heart stroke and 137 thousand die annually. The most distressing thing is that maximum people die due to first heart stroke itself while the survivors still risk the chance of a second stroke within 5 years. Centers for Disease Control and Prevention (CDC) [1], US reported the death of an American every 40 s while American Heart Foundation (AHA) [2], US has identified that 25% of population die because of CHD.

Fig. 1
figure 1

US mortality rate in 2020

Figure 1 shows the mortality rate of males and females announced by AHA in the year 2020. The mortality rate is highest for people with age more than 75 years but a significant figure is also seen for the age group of 25–34 years. Major factors causing CHD are physical inactivity, overweight, hyperglycemia, hypertension, life style and gene changes, wrong food and sleep habits.

The heart disease can be identified by typical symptoms that include chest pain/angima, swelling or numbness in legs and arms, breath shortness, pain in jaw, neck, throat and high heart rate. In the initial stage, the doctor/medical practitioner may prescribe drugs to control blood glucose, blood pressure or cholesterol before diagnosing actual blockage in the arteries. The standard modes of diagnosing the heart disease are blood tests, chest X-rays, electrocardiogram (ECG), cardiac computerized tomography (CCT) scan, magnetic resonance imaging (MRI), echocardiography, angiography and multiple-gated acquisition scanning (MUGA). Medical diagnosis depends largely upon expertise of doctors which may vary according to their personal experiences, past history of the patient and vague or incomplete medical data.

This has raised the demand for early detection of heart disease through diagnosis modeled on the modern technologies enabling the medical professionals, researchers and computer technologists to develop machine learning (ML) techniques for reliable, quick and digital diagnosis based on the fuzzy, indefinite and uncertain medical data. The use of smart devices such as smart watches, tablets, smart phones, internet of things (IoT) enabled gadgets, smart glass and portable health monitoring devices in day-to-day life can help to improve the disease detection at early stage.

IT professionals and researchers have introduced numerous data-mining classification techniques in the last few years for the prediction of heart disease. Support vector machine (SVM), Naive Bayes (NB), decision tree (DT), K-nearest neighborhood (KNN), logistic regression (LR) and artificial neural network (ANN) are the most popularly and commonly used machine learning (ML) algorithms for improving the accuracy of medical decision support system. However, automatic diagnostic system faces two major problems: overfitting and underfitting of the dataset which arises due to noisy and missing data, and division of training/testing datasets. The damage from these problems results in out of context trends in the final classification.

In order to remove these shortcomings an intelligent multi-layered ANN diagnosis system using back propagation is proposed in the study to enhance the accuracy of the model. Multi-layered ANN has the ability to solve non-linear and complex problems due to its high computational power. The emphasis on the choice of hidden layers and suitable combination of neurons has been made to avoid overfit and underfit of the data. The experiment work is carried over Kaggle and Statlog dataset. The performance on three transfer functions: log-sigmoid, linear and tan-hyperbolic in the hidden layers make it possible to analysis the best performance. The highlights of the paper are as follows:

  • Demonstrates the latest advances for the design of heart disease diagnose model.

  • Describes various combinations of neurons in different hidden layers.

  • Explains achievements in the various phases of training/testing the system and analyzes related work using three transfer functions.

  • Correlates mean squared error (MSE), accuracy and number of hidden layers.

  • Evaluates the study using two data sets, Kaggle and Statlog, to formulate realistic model.

Fig. 2
figure 2

The architecture of ANN

Table 1 Table of abbreviations of symptoms
Fig. 3
figure 3

The Block diagram of the proposed system

2 Study environment and background theories

ANN is one of the most famous ML adaptive model being used in the prediction of heart disease. ANN [3] or, simply, Neural Network is the simulation of decision making ability of human brain. Neural Network imitates the activity performed by neurons of brain.

A Neural Network, depicted in Fig. 2, mainly comprises three layers explained as under:

  1. (i)

    The input layer receives the inputs and passes the same to second layer without processing. This layer has n neurons \(a_{1},\ldots , a_{n}\) that are connected to every neuron of the second layer as explained ahead.

  2. (ii)

    The second layer, known as hidden or processing layer, has p neurons \(z_{1},\ldots ,z_{p}\) that are connected to synapses to input neurons where \(w_{ij};\ 1\le i\le n,\ 1\le j\le p\) denote the weight of the arc between ith input neuron and jth hidden neuron. Thus, the input to each hidden neuron is the weighted sum of the outputs of the input neurons and second layer performs intermediary calculations using the summation and transfer function. All the hidden neurons are connected to each of the output neurons with weights \(v_{ij};\ 1\le i\le p,\ 1\le j\le m\) for arc between ith hidden neuron and jth output neuron.

  3. (iii)

    The output layer with m neurons, \(y_{1},y_{2}\) and \(y_{m}\), receive inputs from the hidden layer neurons as sum of products and apply transfer function

Fig. 4
figure 4

Data-flow diagram of the proposed methodology

Table 2 Attainment of evaluation metrics in three layer ANN architecture

Additionally there are two bias nodes, \(b_{1}\) and \(b_{2}\) that are connected to the hidden and output layers respectively with the weights \(w_{01}, \ldots , w_{0p}\) and \(v_{01}, \ldots , v_{0m}\). Bias performs as an interceptor in a linear equation. It adjusts the output alongwith the weighted sum of the inputs to the neurons, resulting in convergence of thereby determining the best fit for the given data.

Artificial Neural Network is applicable in various disciplines [4] including science, computing, engineering, agriculture, environmental, technology, mining, arts, climate, business, nanotechnology etc. In health-care and medicine [5], ANN is being applied extensively in general practice, internal medicine, invasive medicine, intensive care, anaesthesia and surgery. Apart from these, ANN is also being utilized in neuro [6], radiation medicine [7], forensic [8], dental science [9], dermatology [10], urology [6], ophthalmology [11], gynaecology [12], paediatry [13], gerontology [14], oncology [15], endocrinology [16] and cardiology [17]. The expanse of ANN is being leveraged to devise new solutions to the complex health care problems through the huge database of patients. It is not only an effective tool in classification of medical and health science diagnoses problems but beneficial for solving many other prime problems like prediction of signals/factors, signal enhancement and its identification.

Table 3 Attainment of evaluation metrics in four layer ANN architecture

Back propagation is a supervised learning technique to efficiently train ANN. The aim of back propagation is to minimize the calculated error of the output using gradient descent or delta rule. It basically performs three phases of propagation: forward phase, backward phase and finally, substituting the obtained values together and computing the updated biases and weights. Fine-tuning of the biases and weights reduces error in the cost function and improve model confidence by generalizing. This technique follows the listed steps:

  • Step 1. Normalize of the input and output w.r.t their maximum values.

  • Step 2. Assign random weights to each neuron of the hidden and output layer of the network.

  • Step 3. Give an input unit \(a_{i},\ 1\le i\le n\) to each input neuron that passes it to the intermediate layer.

  • Step 4. Each hidden neuron \(z_{j},\ 1\le j\le p\) sums its weighted input signals through

    $$\begin{aligned} z_{inj} = w_{oj}+n\sum _{i=1}^{n}a_{i}w_{ij} \end{aligned}$$
    (1)
  • Step 5. Compute the output signal and send it to all the units in the output layer.

    $$\begin{aligned} z_{j}=f(z_{inj}),\ \text {where } f \text {is a transfer function} \end{aligned}$$
    (2)
  • Step 6. Each output neuron \(y_{k},\ 1\le k\le m\) sums its weighted input signals.

    $$\begin{aligned} y_{ink} = v_{ok}+n\sum _{j=1}^{p}z_{j}v_{jk} \end{aligned}$$
    (3)
  • Step 7. Compute the output signal and send it to all the units in the output layer.

    $$\begin{aligned} y_{k}=f(y_{ink}),\ \text {where } f \text { is a transfer function} \end{aligned}$$
    (4)
  • Step 8. Each output unit receives a target pattern corresponding to the input training pattern and compute its error term

    $$\begin{aligned} \delta _{k}=(t_{k}-y_{k})\acute{f}(y_{ink}) \end{aligned}$$
    (5)
  • Step 9. Calculate its weight correction term

    $$\begin{aligned} \Delta v_{jk}=\alpha \delta _{k}z_{j} \end{aligned}$$
    (6)

    where \(\alpha \) is the learning rate.

  • Step 10. Calculate its bias correction term

    $$\begin{aligned} \Delta v_{ok}=\alpha \delta _{k} \end{aligned}$$
    (7)

    and sends \(\delta _{k}\) to units in the layer below.

  • Step 11. Sum the delta inputs of each hidden neuron \(z_j\)

    $$\begin{aligned} \delta _{inj}=\sum _{k=1}^{m}\delta _{k}v_{jk} \end{aligned}$$
    (8)
  • Step 12. Compute

    $$\begin{aligned} \delta _{j}=\delta _{inj}f'(z_{inj}) \end{aligned}$$
    (9)
  • Step 13. Calculate its weight correction term

    $$\begin{aligned} \Delta w_{ij}=\alpha \delta _{j}a_{i} \end{aligned}$$
    (10)
  • Step 14. Calculate its bias correction term

    $$\begin{aligned} \Delta w_{oj}=\alpha \delta _{j} \end{aligned}$$
    (11)
  • Step 15. Update each weight of the network by

    $$\begin{aligned} v_{jk}(\textrm{new})= & {} v_{jk}(old) + \Delta v_{jk} \end{aligned}$$
    (12)
    $$\begin{aligned} w_{ij}(\textrm{new})= & {} w_{ij}(old) + \Delta w_{ij} \end{aligned}$$
    (13)
  • Step 16. Repeat steps 4–15 until the weights converge.

Fig. 5
figure 5

Testing accuracy in three layer model

Fig. 6
figure 6

Mean squared error of the best performance in three layer model

3 Related work

Researchers have worked on various ML models based on ANN or hybridized with ANN, convolutional neural network (CNN), recurrent neural network (RNN), radial Basis function (RBF), multi-layered perceptron neural network (MLPNN), back propagation neural network (BPNN), recurrent fuzzy neural network (RFNN) and long short term memory (LSTMNN) for automatic heart disease diagnosis. They have used several ensemble techniques to enhance the accuracy rate and analyzed the performance of the models through the MSE, receiver operator characteristic (ROC) curve, area under curve (AUC) and F1-score. Some of the related articles from 2010 to 2021 have been reviewed here.

Fig. 7
figure 7

Testing accuracy in four layer model

Fig. 8
figure 8

Mean squared error of the best performance in four layer model

In 2019, Khourdifi and Bahaj [18] proposed classification and prediction of heart disease using ANN. The dataset consisting of 10 clinical attributes of 300 patients was taken from Sahara Hospital of Aurangabad. The neural network was trained and tested by RBF in MATLAB, and yielded 97% accuracy.

Atkov et al. [19] created MLPNN in the year 2012. The paper presented a hybrid approach of genetic algorithm (GA) and ANN which are supposed to be suitable and supportive for non-linear and complex problems. It achieved an accuracy of 93% using genetic and non-genetic factors. The experimentation was done on 487 patients of Central hospital, Russia through NeuroSolutions tool of version 5.0.

Table 4 Attainment of evaluation metrics in five layer ANN architecture

An intelligent system to predict cardiovascular disease was explained in 2013 by Amma [20]. The study made an emphasis on amalgamation of multi-layered feed-forward ANN with back propagation and GA. A dataset of 303 patients from UCI, California, having thirteen attributes was used for training and testing the system, respectively. The three layers of ANN consisted of thirteen, seven and one neuron respectively. The evaluation of weights of neural network yielded 94.17% accuracy.

Fig. 9
figure 9

Testing accuracy in five layer model

Fig. 10
figure 10

Mean squared error of the best performance in five layer model

Fig. 11
figure 11

Testing accuracy in six layer model

Shao et al. [21] claimed classification of heart disease using various hybrid models of linear regression (LR), multivariate adaptive regression splines (MARS), ANN, rough set (RS) techniques in 2014. A dataset of 899 UCI patients, 60% for training and 40% for testing, with thirteen atributes was used. Using wald forward method in RESE software, single ANN technique yielded 76.79% accuracy with thirteen input nodes and hybrid MARS-ANN, LR-ANN and RS-ANN achieved 82.14%, 78.57% and 79.50% accuracy using six, twelve and ten input variables, respectively. Type-I and II error of best performance of MARS-ANN was recorded as 0.11 and 0.22 which were smaller than the models designed without ANN.

Table 5 Attainment of evaluation metrics in six layer ANN architecture

Feshki and Shijani [22] proposed selection of best features, using Particle Swarm Optimization (PSO), in the diagnosis system that are relevant with respect to time, cost and accuracy. Feature division of thirteen basic clinical attributes out of 76 features of Cleveland clinic foundation (CCF) dataset was made to design a diagnosis model at the minimum cost and time. BPNN within the PSO was implemented to extract eight features to test 303 patients to attain an accuracy of 91.94%.

A heart disease diagnosis model was presented by Uyar and Alhan [23] in 2017 utilizing GA-based RFNN involving thirteen input, seven hidden and one output neurons. The implementation on data of 297 CCF patients resulted in sensitivty (100%), specificity (95.54%), accuracy (97.78%), precision (96%), probable misclassification error (2.22), root mean square error (0.0222) and F1-score (0.9796).

An automated medical diagnosis system developed by Karayilan and Kiliç [24] in 2017 depicted BPNN using fourteen input parameters. The system included thirteen input neurons and two output neurons while in the hidden layer, three to twelve neurons were tested. The best accuracy of 95.55% was achieved at eight and eleven neurons in the hidden layer.

Gawande and Barhatte [25] in 2018 proposed a diagnostic model to predict heart disease using abnormalities in ECG waveforms. ECG signals of 340 patients of Massachusetts Institute of technology and Boston Israel Hospital (MIT-BIH) database were taken as input parameters. The data trained by CNN, consisting of total seven layers and sigmoid transfer function, revealed abnormalities of signals and illustrated the same in GUI form. The accuracy of the model was near 99%.

A smart clinical diagnostic model for heart was presented by Costa et al. [26] in 2019. The model utilized BLPNN to train 80% of the data taken from CCF and V. A. medical center comprising of thirteen clinical parameters. The testing of 20% data gave 90.74% accurate results using sigmoid transfer function with a learning rate and Nesterov’s momentum of 0.28 and 0.15 respectively. The number of neurons in respective three layers were thirteen, six and one yielding AUC-score of 0.94, F1-score, precision and recall of 0.91.

Latha and Jeeva [27] came up with another heart risk diagnosis study combining the classification and ensemble techniques on a CCF data of patients in the age group of 29-79 segregated through NB, Bayes Net, C4.5 DT and MLPNN. Further, bagging, boosting and stacking ensemble techniques were employed to improve the accuracy. Finally, best accuracy of 80.53% and 84.16% was obtained using ANN and NB, respectively.

Muhammad et al. [28] demonstrated an adaptive computation model for an early early detection of heart disease. FCBF, maximum relevance minimum redundancy (MRMR), Least Absolute Shrinkage and Selection Operator (LASSO) and relief algorithms were applied to select features from a thirteen-parameters dataset taken from CCF and HIC. A 94.41% accurate result was achieved using ANN of thirteen, twenty and two neurons in three layers.

Fig. 12
figure 12

Mean squared error of the best performance in six layer model

Table 6 Attainment of evaluation metrics in seven layer ANN architecture

Recently, Shorewala [17] explored early prediction of heart disease employing various classification techniques including LR, SVM, RF, KNN, NB, MLPNN and DT. The model was tested on cardiovascular dataset of 70,000 patients wherein the feature selection was made using LASSO and bagging, boosting, and stacking ensemble techniques. DT achieved the highest accuracy of 74.8% and outperformed all other models.

In 2021, Shihab et al. [29] came up with a promising, supportive and feasible system revealing smart medical decisions of heart failure through RNN and LSTM combining with IoT. Firstly, 15,000 ECG signals are collected from Py-serial library by Arduino. Then extraction of features from ECG signals was made and passed as input parameters for RNN and LSTM. The network was trained by back propagation algorithm using sigmoid transfer function. The system was tested on twenty people of Chattogram and yielded probable results.

Based on the critical analysis of the related work and comparative analysis of various NN models, the proposed study has employed BPNN due to its advantages. ANN based on back propagation can learn any non-linear function due to the application of all transfer functions. It enables the network to learn all the complex relationships between input and output parameters. It is fast, easy and simple to learn. In addition to this, there are no parameters to set other than the input number. This makes it possible to build a rigorous mathematical model. While CNN and RNN deals with major challenges like exploding gradient, class imbalance and overfitting. The application of these two NN require a huge amount of data and rate of convergence of these techniques is very slow. Furthermore, many iterations are required for MLPNN to learn to solve very simple logic problems.

4 Research methodology

The diagnosis of heart disease consists of input parameters that are the risk elements and are extracted from the dataset of thirteen clinical attributes, described in Table 1, of confirmed or suspected heart patients. The data is divided into two sets for training and testing and the classification of ‘Presence’ or ‘Absence’ of heart disease is made through the multi-layered ANN with back propagation algorithm as manifested in Fig. 3.

Fig. 13
figure 13

Testing accuracy in seven layer model

Fig. 14
figure 14

Mean squared error of the best performance in seven layer model

A diagnosis system (Fig. 4) is developed by training the network using different hidden layers and transfer functions, viz. Log-sigmoid Eq. (14) (logsig) [30], Linear (purelin) Eq. (15) and Tan-hyperbolic Eq. (16) (tansig) [31].

$$\begin{aligned} \phi (z)= & {} \frac{1}{1+\exp (-z)},\ z\in R \end{aligned}$$
(14)
$$\begin{aligned} \phi (z)= & {} \left\{ \begin{array}{ll} z &{} \text{ if } z\ge 0\\ -z &{} \text{ if } z\le 0 \end{array} \right. \end{aligned}$$
(15)
$$\begin{aligned} \phi (z)= & {} \frac{1-\textrm{exp}(-2z)}{1+\textrm{exp}(-2z)}, \ z\in R \end{aligned}$$
(16)
Table 7 Attainment of evaluation metrics in eight layer ANN architecture

Finally, the trained system is tested and accuracy is evaluated at each layer using the said transfer functions. The MSE Eq. (17) [32], is computed that shows the cumulative squared error between the actual and estimated value.

$$\begin{aligned} \textrm{MSE}=\frac{1}{n}\sum _{i=1}^{n}(y_{i}-\hat{y_{i}})^{2} \end{aligned}$$
(17)

where n is the number of data points, \(y_{i}\) and \(\hat{y_{i}}\) represents observed and predicted values, respectively. The MSE of the best performance case is plotted to diagnose the system efficiently.

5 Experimental work

The implementation is carried out on Kaggle heart disease dataset of 1025 patients having thirteen clinical input parameters and two classes of output, 1 for ‘Presence’ and 0 for ‘Absence’. After normalizing the data, it is segregated for training and testing processes. The observation of the experiments are recorded in ‘nntool’ toolbox of MATLAB R2015a.

5.1 Training of neural network via log-sigmoid transfer function

Neural network is trained by back propagation technique using hidden layers varying from two to seven and log-sigmoid transfer function. Average and variance of accuracy of each model is also computed to check the spread of data. The data includes iterations, time elapsed during training period and accuracy respectively along with validation. Table 2 present the data for neurons of two hidden layers. Figures 5 and 6 show the local maximum records of accuracy and validation respectively.

Fig. 15
figure 15

Testing accuracy in eight layer model

Fig. 16
figure 16

Mean squared error of the best performance in eight layer model

Table 8 Attainment of evaluation metrics in three layer ANN architecture
Fig. 17
figure 17

Testing accuracy in three layer model

Evaluation metrics attained in four layer architecture are presented in Table 3. Accuracy bar graph and best validation performance achieved at the combination set of 11, 10 and 9 neurons are depicted in Figs. 7 and 8, respectively.

Fig. 18
figure 18

Mean squared error of the best performance in three layer model

Table 9 Attainment of evaluation metrics in four layer ANN architecture

The best accuracy of log-sigmoid transfer function is obtained in five layer ANN architecture (Table 4) with training and testing accuracy are 98.57% and 94.73%, respectively and Figs. 9 and 10 represent accuracy of experimental tasks at distinct set of neurons and validation performance having MSE 0.029799 at 24th iteration.

The best performance of Table 5 is achieved at 28th iteration having 86.91 and 88.99% as training and testing accuracies. The local accuracy rate of five hidden layers is depicted in Fig. 14 and validation performance having MSE 0.15285 at 22th iteration is shown in Fig. 12.

Evaluation metrics attained in seven layer architecture are presented in Table 6. Accuracy bar graph and best validation performance achieved at the combination set of 10, 11, 9, 8, 7 and 10 neurons are depicted in Figs. 13 and 14 respectively

Fig. 19
figure 19

Testing accuracy in four layer model

Fig. 20
figure 20

Mean squared error of the best performance in four layer model

The experimental records obtained in using eight hidden layers are shown in Table 7, and Figs. 15 and 16 illustrates graphical representation of accuracy of each record and validation execution corresponding to the maximum accuracy of 83.33% with the substitution of 12, 10, 9, 8, 7, 11 and 5 neurons in respective hidden layers.

5.2 Training of neural network via linear transfer function

Table 10 Attainment of evaluation metrics in five layer ANN architecture

Neural network is trained by back propagation technique using hidden layers varying from two to seven and linear transfer function. Average and variance of accuracy of each model is also computed to check the spread of data. The data includes iterations, time elapsed during training period and accuracy respectively along with validation. Table 8 present the data for neurons of two hidden layers. Figures 17 and 18 show the local maximum records of accuracy and validation respectively.

Fig. 21
figure 21

Testing accuracy in five layer model

Fig. 22
figure 22

Mean squared error of the best performance in five layer model

Evaluation metrics attained in four layer architecture are presented in Table 9. Accuracy bar graph and best validation performance achieved at the combination set of 10, 8 and 7 neurons are depicted in Figs. 19 and 20 respectively.

The experimental records obtained in using four hidden layers are shown in Table 10, and Figs. 21 and 22 illustrates graphical representation of accuracy of each record and validation execution corresponding to the maximum accuracy of 80.58% with the substitution of 12, 10, 8 and 7 neurons in respective hidden layers.

The best performance of Table 11 is achieved at 7th iteration having 72.27 and 81.90% as training and testing accuracies. The local accuracy rate of five hidden layers is depicted in Fig. 23 and validation performance of blending 10, 9, 9, 8 and 8 neurons in respective layers with MSE 0.122 at 5th iteration is shown in Fig. 24.

The blending of 9, 8, 6, 5, 7, 3 and 5 neurons in respective six hidden layers of Table 12 marked 73.53% and 76.21% as training and testing accuracies. The illustration of accuracy records achieved at different combinations and best validation execution corresponding to the best accuracy is shown in Figs. 25 and 26.

Table 11 Attainment of evaluation metrics in six layer ANN architecture

The best accuracy of linear transfer function is obtained in the eight layer ANN architecture model shown in Table 13 where training and testing accuracy are 81.24% and 86.72%, respectively. Figures 27 and 28 represent accuracy of experimental tasks at distinct set of neurons and validation performance having MSE 0.083134 at 14th iteration.

Fig. 23
figure 23

Testing accuracy in six layer model

Fig. 24
figure 24

Mean squared error of the best performance in six layer model

Table 12 Attainment of evaluation metrics in seven layer ANN architecture

5.3 Training of neural network via tan-hyperbolic transfer function

Neural network is trained by back propagation technique using hidden layers varying from two to seven and tan-hyperbolic transfer function. Average and variance of accuracy of each model is also computed to check the spread of data. The data includes iterations, time elapsed during training period and accuracy respectively along with validation. Table 14 present the data for neurons of two hidden layers. Figures 29 and 30 show the local maximum records of accuracy and validation respectively.

The best validation performance for which the testing accuracy is the highest is presented in figs.

The best achievement of Table 14 is presented at 23rd iteration with 99.20% and 90.19% training and testing accuracy with best validation performance 0.040924 at 21st iteration shown in Fig. 30.

Evaluation metrics attained in four layer architecture are presented in Table 15. Accuracy bar graph and best validation performance achieved at the combination set of 12, 11 and 9 neurons are depicted in Figs. 31 and 32, respectively.

The experimental records obtained in using four hidden layers are shown in Table 16, and Figs. 33 and 34 illustrates graphical representation of accuracy of each record and validation execution corresponding to the maximum accuracy of 94.76% with the substitution of 10, 8, 6 and 5 neurons in respective hidden layers.

Fig. 25
figure 25

Testing accuracy in seven layer model

Fig. 26
figure 26

Mean squared error of the best performance in seven layer model

Table 13 Attainment of evaluation metrics in eight layer ANN architecture

The best performance of Table 17 is achieved at 50th iteration having 99.06 and 97.60% as training and testing accuracies. The local accuracy rate of five hidden layers is depicted in Fig. 16 and validation performance having MSE 0.021406 at 44th iteration is shown in Fig. 36.

The overall maximum accuracy of tan-hyperbolic transfer function is obtained in the seventh layer ANN architecture model shown in Table 18 where training and testing accuracy are 97.247% and 99.92%, respectively. Figures 37 and 18 represent accuracy of experimental tasks at distinct set of neurons and validation performance having MSE 0.027839 at 37th iteration.

The blending of 12, 10, 9, 8, 7, 11 and 5 neurons in respective seven hidden layers of Table 19 marked 93.78% and 95.79% as training and testing accuracies. The illustration of accuracy records achieved at different combinations and best validation execution corresponding to the best accuracy is shown in Figs. 39 and 40.

6 Comparative analysis of hidden layers of ANN and transfer functions

Accuracy of two, three, four, five, six and seven hidden layers with distinct pair of neurons has been computed for log-sigmoid, linear and tan-hyperbolic transfer functions of neural network. The computational and comparative analysis of the study is highlighted in the Figs. 4142434445 and 46 revealing that at each layer tan-hyperbolic transfer function comes out with maximum accuracy of 90.19% (Fig. 41), 98.18% (Fig. 42) , 94.76% (Fig. 43), 97.6% (Fig. 44), 99.92% (Fig. 45) and 95.79% (Fig. 46) from three to eight layer ANN architecture respectively.

7 Results and discussion

Figure 47 plots the maximum accuracy corresponding to the number of hidden layers where each layer represents the best accuracy achieved for log-sigmoid, linear and tan-hyperbolic transfer functions of neural network.

It can be easily observed that the best performance is yielded corresponding to tan-hyperbolic transfer function in each layer and best accuracy of 99.92% is achieved in six layer model of ANN.

The performance of the proposed diagnosis system has been evaluated through some performance metrics and also validated through the k-fold method. Further more, the results of the proposed system have been compared with the other models and datasets.

7.1 Performance metrics

The confusion matrix [33] and the performances of the evaluation metrics [34] are tabulated in Tables 20 and 21 respectively with AUC 0.90 as plotted in Fig. 48.

Fig. 27
figure 27

Testing accuracy in eight layer model

Fig. 28
figure 28

Mean squared error of the best performance in eight layer model

Table 14 Attainment of evaluation metrics in three layer ANN architecture

7.2 Cross-validation k-fold method

Cross-validation is one of the best and popularly used to test the performance of the results that randomly partitions a dataset into k-subsets where \((k-1)\) subsets are used for training purpose to test each of the kth subset. A single value obtained by taking the average of k-MSE demonstrates the performance of the method. The performance of the current proposal has been analyzed through 5-fold and 10-fold methods, presented in Table 22, to strongly support the claim about the correctness of the procedure.

Fig. 29
figure 29

Testing accuracy in three layer model

Table 15 Attainment of evaluation metrics in four layer ANN architecture
Fig. 30
figure 30

Mean squared error of the best performance in three layer model

Fig. 31
figure 31

Testing accuracy in four layer model

7.3 Results of the proposed study on other datasets and comparison with the similar researches

The proposed study has also been implemented on Statlog dataset of 270 patients in which 189 and 81 patients are used for training and testing respectively and correctly identified the presence or absence of disease with an accuracy of 89.11%. The comparative results with the similar techniques are presented in Table 23.

Fig. 32
figure 32

Mean squared error of the best performance in four layer model

Table 16 Attainment of evaluation metrics in five layer ANN architecture
Fig. 33
figure 33

Testing accuracy in five layer model

Fig. 34
figure 34

Mean squared error of the best performance in five layer model

Table 17 Attainment of evaluation metrics in six layer ANN architecture
Fig. 35
figure 35

Testing accuracy in six layer model

Fig. 36
figure 36

Mean squared error of the best performance in six layer model

Table 18 Attainment of evaluation metrics in seven layer ANN architecture
Fig. 37
figure 37

Testing accuracy in seven layer model

Fig. 38
figure 38

Mean squared error of the best performance in seven layer model

Table 19 Attainment of evaluation metrics in eight layer ANN architecture
Fig. 39
figure 39

Testing accuracy in eight layer model

Fig. 40
figure 40

Mean squared error of the best performance in eight layer model

Fig. 41
figure 41

Comparative analysis of three layer ANN architecture

Fig. 42
figure 42

Comparative analysis of four layer ANN architecture

Fig. 43
figure 43

Comparative analysis of five layer ANN architecture

Fig. 44
figure 44

Comparative analysis of six layer ANN architecture

Fig. 45
figure 45

Comparative analysis of seven layer ANN architecture

Fig. 46
figure 46

Comparative analysis of eight layer ANN architecture

Fig. 47
figure 47

Hidden layers versus accuracy

Table 20 Confusion matrix
Table 21 The Outcomes of the proposed model for diagnosis of the heart disease
Fig. 48
figure 48

Receiver operating characteristic curve

Table 22 Cross-validation
Table 23 Comparison of the proposed study with the similar method

8 Conclusion and future scope

The aim of this experimental work is to develop an ANN-Back Propagation based diagnostic model for the prediction of heart disease through comparison study of hidden layers and transfer functions. The best performance is yielded by tan-hyperbolic transfer function in each layer with an accuracy of 99.92% in seven-layer (six hidden layers) model of ANN. The proposed study attained an accuracy of 99.92% using Kaggle heart disease set. The performance was also validated through its test on Statlog dataset. The consistency of the system has been measured in terms of specificity (88.96%), sensitivity (95.45%), accuracy (92.20%), precision (0.89), f-score (0.92), AUC (0.90) and k-fold cross validation resulting in an overall accuracy of 92.88%. Further increase in the number of hidden layers reduces the accuracy of the proposed system. The results have been validated through the evaluation metrics and justified by computing statistics such as the values of accuracy, validation performance, average, variance and MSE. The results achieved during the proposed technique are highly accurate, encouraging researchers/ scholars to further explore mass adoption of this approach in the benefit of early and cost-effective heart disease diagnosis. In future, model can be tested on large scale datasets using SVM or other latest ML techniques.