1 Introduction

Patients with various chronic diseases or vulnerabilities always need continuous special supervision, especially this is true for the older generation in society. Ambient Assisted Living systems can provide solutions for monitoring the physical conditions of patients or people with vulnerabilities and alert the concerned personalities autonomously on a continuous basis. Among fatal diseases, heart failure is one of the most common phenomena in terms of life-threatening physical conditions. Predicting heart failure of patients under the supervision of ambient assisted livings systems in real-time with reliability can be a daunting task as most of the Ambient Assisted Living systems serve according to the cloud server-based Internet of Things model where the alert notification for the danger prediction may not be available in real-time because of any network bottleneck or unexpected network interruption.

Since heart failure can be considered one of the most fatal occurrences for patients monitored by the Ambient Assisted Living System, it is necessary to find a solution for determining the probability of heart failure in a reliable way in real time. The proposed Deep Edge Intelligence-based heart failure prediction model can provide a solution for determining the probability of heart failure in a reliable way with a relatively less complicated framework for alert notification compared to the central cloud-based Internet of Things model with the available data.

Some existing research works have been done to implement heart disease prediction in Ambient Assisted Livings systems. Qureshi [1] has mentioned that deep learning technologies can provide close to accurate predictions for heart disease detection but there are issues with real-time monitoring and expensive implementation of cloud-based services. Pires [2] has illustrated that Machine Learning methods are capable of detective heart diseases early using the sensor values by implementing a combination of machine learning algorithms. Patro [3] proposed a supervised machine learning-based model using the Internet of Things framework in Ambient Assisted Living systems that provided a decent level of accuracy.

The proposed solution aims to predict heart failure probabilities with the highest accuracy using deep learning and machine learning-based techniques at the edge of the Internet of Things-based Ambient Assisted Living systems. Raspberry Pi will be used as the Edge Intelligent device for the solution. The objective is to implement a deep edge intelligence-based solution to determine the patient’s heart failure probability in real-time without having to forward the data to the cloud server for analysis. The solution also aims to explore the possibilities of the application of different Deep Learning and Machine Learning algorithms and their combination at the edge for heart failure prediction. The research also looks forward to critically evaluating the reliability and accuracy of Heart Disease Prediction with Edge Intelligence.

The proposed solution holds significance because of its novel approach to initiate the deep learning-based prediction of heart failure at the edge of the Internet of Things-based Ambient Assisted Living systems for providing more reliable and simple alert notifications for vulnerable patients monitored by the AAL systems in real-time without the involvement of cloud server-based prediction. This deep edge-based solution can be implemented for monitoring any other chronic diseases as well. This proposed method can reduce some of the data forwarding and analytical burden off the cloud server for more reliability and less network bottleneck which can turn out to be less expensive.

2 Literature review

Several pieces of research have been done related to heart disease prediction for IoT-based medical systems and Ambient Assisted Living systems. Most of them have implemented the server-based approach for machine learning and deep learning model training and prediction because that is the typical way of cloud-based Internet of Medical Things framework. Just a few pieces of literature can be found that have implemented the edge-based approach for any kind of disease prediction at the edge for Ambient Assisted Living systems or Internet of Things-based systems

F Ali [4] proposed method used the feature fusion method by integrating the collected features from various data from the sensor and digital medical records. The system performance is enhanced with some techniques such as Information gain and conditional probability. Finally, an ensemble deep learning model was used to detect heart disease which obtained an accuracy of 98.5%. This approach did not run any feature reduction to handle a large amount of data. So, this method lags in performance, running a large amount of data on a single server.

Devi [5] predicted the risk of heart disease from various clinical data such as age, gender, resting blood pressure, chest pain, fasting blood sugar, cholesterol, resting ECG, exercise-induced angina, maximum heart rate, slope, old peak etc. Various ML-based algorithms were used such as Random Forest, XGBoost, KNN, SVM, Decision Tree and LightGBM. For this server-based method, Random Forest gave 85.81% accuracy to predict heart disease. This method is suitable for doctors as the data is more clinical. But the data pre-processing and running of ML algorithms in a single server is time-consuming. Added to that, the private data of the patients are used here, which violates the privacy-preserving policy.

M. A. Khan [6] implemented an IoMT scheme where data like patient’s sex, age, chest pain, blood pressure (BP), blood sugar, cholesterol etc. was taken as input. Heart Disease was predicted using MSSO (modified salp swarm optimization) - ANFIS (adaptive neuro-fuzzy inference system). When compared to other approaches, highly precise and accurate outputs have been generated by this particular model. This model does not perform well in terms of computation as the load of the computation lies on a single server.

M.A. Khan [7] proposed a method using the Modified Deep Convolutional Neural Network (MDCNN) for categorizing received sensor data (blood pressure and ECG) as normal or abnormal. The suggested approach demonstrates that the MDCNN obtains an accuracy of 98.2% which is higher than the existing models.

Z. Al-Makhadmeh and T. Amr [8] obtained information about patients’ hearts before and after cardiac disease. The HOBDBNN (higher order Boltzmann deep belief neural network) is used to handle the data. The HOBDBNN approach and IoT-based analysis recognize illness in the heart within 8.5 s and an accuracy of 99.03%, effectively reducing cardiac disease death by decreasing the difficulty of detecting and preventing it. The response time can be decreased by optimizing the feature selection process and deploying the system in an edge-based system.

To create an IoT-enabled ECG monitoring system, R. Lakshmi Devi & V. Kalaivani [5] analyzed the ECG signal. To extract the dynamic properties of the ECG signal, the Pan Tompkins QRS detection algorithm is applied to the ECG signal. To classify cardiac arrhythmia disease, the dynamic and statistical features are applied to the classification procedure. It is helpful for doctors to detect cardiac problems as easily and accurately as possible. Using a single cloud to perform all the feature selection and prediction, this system takes more time to predict heart disease.

Mutlag [9] investigated fog computing in healthcare applications and found the difficulties and challenges. They discovered reaction time and latency are the most critical and challenging to increasing Quality of Service metrics in real-time fog environments. Applying intelligence at the edge comes with pros related to less response time for the system. For this reason, highly efficient real-time accurate predictions have provided a brand-new path for this research.

Gia [10] developed a Low-Cost Health Monitoring (LCHM) methodology to collect health data from patients with heart problems. Also, sensor nodes track and evaluate the ECG in real-time for fast processing of cardiac patients’ data, while LCHM has a longer reaction time, affecting performance. This process uses more energy during data collecting and transmission.

An IoT e-health service was suggested by Ali and Ghazal [11] based on an application that uses SDN (Software Defined Network) to collect data via smartphone voice control and determine patients’ health status. Additionally, this service identifies the type of cardiac attack using a conceptual model based on mobile application. However the application’s performance is not assessed in cloud-based settings.

To diagnose cardiac problems using ECG. Akrivopoulos [12] suggested an ECG-based Healthcare (ECGH) system. However, it has low precision and a slower reaction time in detecting anomalous occurrences since it retrieves data without integrating analytics of data or other approaches of feature extraction. Furthermore, in the case of a significant number of requests, data transmission to the cloud server lags and consumes more energy, degrading system performance.

A Graph-based Attention Model (GRAM) was suggested by Choi [13] for learning healthcare representation that augments digital health data with the hierarchical knowledge found in medical ontologies. To determine the likelihood of a heart attack, GRAM uses predictive analysis and when compared to Recurrent Neural Network (RNN) on a very short dataset, GRAM outperforms RNN when it comes to training precision but on large datasets, the performance is not up to the mark.

A Hierarchical Edge-based Deep Learning (HEDL) was proposed by Iman [14], based healthcare IoT system to evaluate the viability of using the CNN-based classifying model as an instance of deep learning approaches.

S. Tuli [15] developed HealthFog, a novel framework, which uses devices for edge computing and a technique using integrated ensemble-based deep learning to aid practical applications of cardiac disease diagnostics automatically. This HealthFog design was suitable for multiple operation modes, providing enhanced Quality of Service and excellent prediction accuracy for a variety of user specifications in numerous fog computation applications. The present model training technique employs separate training for each worker node and is thus costly.

K. Butchi Raju [16] suggested a paradigm which combines Edge-Fog-Cloud computing to give precise and timely results. Patients’ information is acquired using medical sensors such as respiration rate sensors, glucose level sensors, oxygen level sensors, temperature sensors, EMG sensors, ECG sensors and EEG sensors. Then Feature Extraction is implemented to the Signal and Data. The captured features are sent into the diagnostic system via an Optimized CCNN (Cascaded Convolution Neural Network). The Galactic Swarm Optimization algorithm is used to optimize the CCNN hyperparameters (GSO). The precision of the proposed GSO-CCNN is 3.7%, 3.7%, 7.6%, 3.6%, 48.4%, 67.9%, 10.9%, 33% and 7.6% higher than GWO-CCNN, PSO-CCNN, DHOA-CCNN, WOA-CCNN, RNN, DNN, CNN, LSTM, and CCNN, respectively, according to the performance analysis. The proposed system’s comparative analysis ensures its superiority over traditional models. But this paradigm can be enhanced for use in real-time applications.

Ancy Jennifer [17] proposed an edge-based method to detect heart disease, on the edge. They collected patients’ ECG, temperature, Pulse rate and accelerometer sensors to get patients’ heart rate, temperature, oxygen level and position respectively. The dataset was examined with naive Bayes, a support vector machine, a decision tree and the KNN algorithm. After running the system under various conditions, it achieved 88% accuracy. This edge-based system was clinically less accurate as the research was not done on proper clinical data. So, this system may suffer while properly guiding the doctors to detect the heart disease of the patients.

In the paper [18], an IoT cloud-based smart healthcare system has been proposed. In the paper, a new Bi-LSTM model has been proposed to predict heart disease using deep learning. Before applying the Bi-LSTM, a fuzzy inference system has been applied to the heart disease prediction data. They used the UCI machine learning repository’s Cleveland and Hungarian dataset which consists of 303 and 294 datasets. They used a tool to increase the number of data point up to 100,000. Their proposed model achieved 98.86% accuracy with a precision of 98.90% and recall of 98.81%. This paper tries to implement smart health care with a great deep-learning model. But as there are a huge number of synthetic data, the accuracy of the model is still questionable. Also they did not apply the system in the edge, so there is a gap in that literature.

A lightweight CNN-based model has been proposed in [19] which predicted both Heart Disease and Chronic Kidney disease. Their proposed model used 1D-CNN to detect heart disease using the Cleveland dataset which has 303 data points with 76 attributes. They used 14 subsets of them. Their proposed model performed an average accuracy of 94.09% with a precision of 91.7% and recall of 91.82%. Their area under the curve is 91.82%. This model is a great implementation of lightweight CNN but their architecture shows no indication of applying it to the edge.

The paper [20] proposed a healthcare monitoring system with edge clouding. They used image dataset and CNN model to predict heart disease in real-time. Their proposed model achieved an accuracy of 99.23%. Their average response time is less than 45 s which is a bit higher for a real-time edge-based system. But this seems reasonable with this much accuracy in the heart disease prediction system.

Kumar et al. proposed an algorithm named RF-LRG in the paper [21]. Their architecture showed an android base UI to be implemented on the edge and in the cloud they will store running models for delay processing. They also used the Cleveland Heart Disease dataset and split the dataset into 80-20 Train-Test set. They used three ML models Logistic Regression,K-Nearest Neighbour and Random Forest Classifier algorithm. Their proposed RF-LRG algorithm is a fusion of two ML algorithms, Random Forest and Logistic Regression Grid. Their proposed algorithm achieved an accuracy of 82.96% which has a precision, recall and f1-score of 84%, 84% and 83% respectively. This literature is a great start with edge enabled system for heart disease prediction. But they did not implement any deep learning techniques. A deep learning technique with the same architecture may have given a better performance in the edge cloud-based heart rate prediction system.

3 Methodology

The proposed system mainly comprises processes from data collecting and processing to generate a prediction and the edge and building embedded notification system as well as the server notification system.

3.1 Data collection

A publicly available dataset from Kaggle with Open Database License called “Heart Failure Prediction Dataset” has been used for the proposed edge intelligent system. The dataset consists of real medical data collected from 5 different sources and 11 medically critical parameters are available in the data. The sources are the Hungarian Institute of Cardiology (Budapest), University Hospital, Zurich, University Hospital (Basel), V.A. Medical Center (Long Beach) and Cleveland Clinic Foundation. The 11 medically relevant parameters are Age, Sex, ChestPainType, RestingBP, Cholesterol, FastingBS, RestingECG, MaxHR, ExerciseAngina, Oldpeak, ST_Slope and they are labelled with a parameter called HeartDisease. 918 observations are available in the dataset without any duplications. The description of all the parameters is provided in Table 1 below.

Table 1 Dataset Parameters and their description

3.2 Data preprocessing

Fig. 1
figure 1

Correlation Matrix generated for every parameter and the label

After data collection, processes related to measuring the correlation and significance of the parameters in the output generation have taken place. Figure 1 demonstrates the correlation between all the parameters. From the correlation values, it seems that most of the parameters are well connected with the label value and do not have significant dependency among them. Although, the parameter called RestingECG has a significantly less relation with the label. This parameter can be discarded while making the prediction models but has been kept while training the models just to feed some extra data points to the models.

Figure 2 illustrates the distribution of values of all the parameters. From these distributions, it seems that the values of all the parameters are close to normally distributed.

Fig. 2
figure 2

Distribution of Parameter Values

To process the data further, visualization has been done for each attribute to see how each attribute is distributed. As there are two classes for Gender, both classes have been plotted using different parameters against the genders and the value of mean and median have been generated.

Fig. 3
figure 3

Distribution of Parameter Values

Figure 3 shows the distribution of age of different sex groups. It can be observed that the mean age of both Genders is close enough. So this proves an equal distribution of the parameter.

Fig. 4
figure 4

Distribution of Parameter Values

Figure 4 shows the distribution of restingbp of two gender groups. Some outliers can be seen from the figure. Apart from that the mean and median are almost the same, indicating equal distribution of data. The outliers will be handled at the later part of the data pre-processing.

Fig. 5
figure 5

Distribution of Parameter Values

Figure 5 shows some outliers like RestingBP. But here the data distribution for the male does not seem distributed equally.

So from the above figures, some outliers in the distributions can be seen. To understand the outliers of each class better and find outliers for each parameter, the distributions have been plotted.

Fig. 6
figure 6

Distribution of Parameter Values

Figure 6 shows some outliers of MaxHR of the people. 1 per cent of the outliers from both sides has been filtered. In the x-axis, it represents the number of samples. It shows 18 outliers.

Fig. 7
figure 7

Distribution of Parameter Values

Figure 7 shows the outliers clearly. The very low RestingBP and the very high RestingBP pollute the data to feed into ML algorithms. So, these outliers have to be removed from the dataset.

Fig. 8
figure 8

Distribution of Parameter Values

Figure 8 also shows 9 outliers. It shows very high cholesterol levels for some of the patient’s data which we need to remove.

After analysing the outliers of all the parameters, it can be observed that the highest amount of outliers have been caused by the MaxHR parameter and those 18 outlier rows have been removed from the dataset. Finally, the filtered dataset has ended up with 900 data points.

3.3 Setup and preparation of Raspberry Pi as an edge device

Raspberry Pi is a lightweight computational device with limited processing capabilities compared to typical mainframe generic computers. Raspberry Pi 4 Model B has been used for this proposed solution. This particular model of Raspberry Pi has a quad-core 64-bit ARM processor with a clock speed of 1.5 GHz. It has Wi-Fi and Bluetooth connectivity for data receiving and broadcasting and these features make Raspberry Pi a perfect device to use as an edge device in an Internet of Things-based framework.

For the setup of Raspberry Pi to use as an Edge device, an operating system is mostly needed. Raspbian operating system has been used in the Pi for this solution. It is a free-to-use operating system mainly based on Linux Debian. For the operating system installation purpose, the memory card of the Raspberry Pi has been loaded with the files of the operating system. Then the installation process has been continued in the Raspberry Pi itself.

For preparing the Raspberry Pi to run the prediction models, several tools and python libraries have been required. A tool called Miniconda, which is a low-performance version of Anaconda has been installed in the Raspberry Pi for training and running the prediction models on the Jupyter Notebook. Python libraries called Numpy, Pandas, and Scikit-learn has also been added to the python environment for developing and executing the prediction models.

For getting the Raspberry Pi connected as an edge device with the Internet of Things framework, the Microsoft Azure server platform has been implemented in this proposed solution. The Raspberry pi has been connected to the server using its own security key generated for this. The data sent from the Raspberry Pi to the server can be overserved through different platforms like the Microsoft Visual Studio Code. Figure 9 shows the created IOT server hub and the registered Raspberry Pi as an edge device on the Microsoft Azure server. The IoT server hub developed for this proposed solution is named “edge-rpi” and the registered edge Raspberry Pi is named “rpi-test”.

Fig. 9
figure 9

IoT Server Hub and Registered Edge Device on the Azure Platform

3.4 System design

The proposed solution mainly consists of three different stages from sensors generated data to the intelligent predicted notification. Firstly, the Raspberry Pi is interfaced with various sensors for collected the sensor-generated data. After collecting the sensor data, primary processing and prediction are done at the edge in real-time using the Raspberry Pi with an already trained model. The prediction output and notification are then forwarded to the cloud server which is in this case the Microsoft Azure-based IoT hub. Further analysis can be done there. Prediction notifications are also available in real-time using the embedded-based advantage of Raspberry Pi. Figure 10 illustrates the proposed solution system design with 3 principal stages. For the proposed system, LED lights have been used for notifying the real-time predictions as just a prototype. Following this framework, even if the network gets disrupted for any unwanted reasons, the prediction process will not be hampered, and real-time prediction notification will be continuing at the embedded side. So, from the initial sensor-generated data collection to the notification generation after prediction, the edge device, in this case, the Raspberry Pi is responsible for implementing most of the objectives including sensing and making sense of the data in real-time without the necessity of server-based processing at this Internet of Things based framework.

Fig. 10
figure 10

Three Key Stages of Proposed Edge Intelligence Solution

4 Prediction model architecture

4.1 Machine learning models

4.1.1 Random forest

The Random Forest (RF) classifier is a supervised machine learning algorithm which has been used here for heart disease prediction. In 1995, Tin Kam HO of Bell Labs proposed it. Several decision trees make up a random forest where each of the decision trees provides a vote indicating the object’s class decision. For hyperparameter tuning in this algorithm, the algorithm has been tuned with the following values:

n_estimators: estimates the number of trees in the forest. A greater number of trees gives better accuracy. For the proposed prediction model, the value of n_estimator has been set to 20. As 918 data points are available in the dataset to feed in the random forest, setting a very high value of the number of decision trees, makes the model over-fitted. Setting up a lower value gives a lower accuracy in this prediction model.

random_state: sets the sampling of features to be considered while determining the optimal split at each node. The default value of random_state is set to none, which gives different results even with the same data and parameters. But setting the random_state parameter with an individual value (1 in our case) gives the same result.

max_depth:indicates the tree’s deepest point. If the value of max_depth is not set, the trees’ depth is grown fully. this value has been set to 6, as the dataset is not a very large one. For our model, this is the optimal value.

4.1.2 K- nearest neighbour

K nearest neighbour (KNN) was first applied in 1970. This is a straightforward algorithm that analyzes all cases. If new cases come, it classifies them based on similarity. It is also known as memory-based classification since the training samples must be kept in memory at all times. The KNN algorithm has two simple steps: Step 1: Discover the K training instances that are the most similar to the unknown instance.Step 2: Choose the most common classification for these K instances.

n_neighbours: This parameter is set to select the number of neighbours’ votes those are being taken into account, for this classification. This is the most challenging parameter, as the number of neighbours can vary for different types of classification problems and different types of data. To define the optimal value of k, it has been started with a random number of k at first, which is 3. Then the value of k has been increased and the error rate has been evaluated. It has been found that the best outcome has been generated where the number of neighbours, k = 5. So, for this KNN classifier, n_neighbours have been set to 5.

4.1.3 Support vector machine

In 1992, Vladimir Vapnik developed Support Vector Machine, a supervised learning algorithm for analysing data for classification, developed at AT &T Bell Laboratories. As the dataset is labelled, SVM has also been implemented to predict heart disease. SVM gives better results when the dimensionality of the data is high, and the data points are not that much. It also saves memory by using support vectors. Support vectors are a subset of training points in the decision function. Different kernel functions can be provided which makes support vector machine rule over other algorithms. The classes SVC, NuSVC and LinearSVC are used for binary classification.

SVC is C-Support Vector Classification, several parameters can be set for this model. The larger the number of C, the smaller the margin is, and the bad classification rate gets lower. But a very small margin overfits the model. So, a default value of 1.0 has been used for C to implement the SVC model.

The value of the kernel has been kept low as the default value ‘rbf’, which is Radial Basis Function. This kernel works similarly to KNN. But it works better than KNN by overcoming the intricacy of space. It draws a regression line and helps in our binary classification model to predict cardiac disease.

figure a

Algorithm 1 shows a generic algorithm which has been followed for all three machine learning models. Here, the data is normalized because machine learning algorithms work better with normalized data. 10-fold cross-validation has been conducted. Other parameters of Random Forest Classifier, K-Nearest Neighbour and Support Vector Machine algorithms have been described in detail in the chapters 4.1.1, 4.1.2 and 4.1.3.

4.2 Proposed deep learning based oversampled quinary feed forward network (OQFFN) technique

Algorithm 2 shows the steps followed to implement the proposed deep learning model. After taking the data as input, oversampling has been conducted as the data of the two classes were imbalanced. The oversampling has been implemented using the Random Oversampling Technique which resulted in equal numbers of positive and negative classes.

For generating new samples using the Random Oversampling technique, the following algorithm has been followed:

$$\begin{aligned} D_{gen} = \theta (D_{nx} - D_x) + D_x \end{aligned}$$
(1)

Here, Dgen corresponds to the newly generated sample considering a sample Dx and one of the nearest neighbours Dnx where \(\theta\) is just a random number between 0 and 1.

figure b

The dense layers are fully connected layers. The number of units and other parameters are conducted through hyper-parameter tuning. An Architecture of the deep learning model has been shown in Fig. 11. After training the model with the dense layers, we evaluated the model with some known metrics like accuracy, precision, recall, f-score with the true-positive, true-negative, false-positive and false-negative values.

Fig. 11
figure 11

Architecture of proposed oversampled quinary feed forward network

5 Results and discussion

5.1 Performance evaluation metrics

To evaluate the models we used some well known evaluation metrics. We measured the True-positives, True-negatives, False-positives and False-negatives for each of the models on the test dataset.

  • True-Positive (Truepos): If the model predicts the true or positive class correctly.

  • True-negative (Trueneg): If the model predicts the false or negative class correctly.

  • False-positive (Falsepos): If the model predicts the true or positive class incorrectly.

  • False-negative (Falseneg): If the model predicts the false or negative class incorrectly.

With these value we have computed accuracy, precision, recall and f1-score.

5.1.1 Accuracy

Accuracy is defined by how much of the test data points is predicted correctly among all the test data points. It is calculated as a percentage.

$$\begin{aligned} Accuracy = \frac{True_{pos}+ True_{neg}}{True_{pos}+ True_{neg} + False_{pos} + False_{neg}} \end{aligned}$$
(2)

5.1.2 Precision

Precision is defined by the amount of positive predicted data among all the positive classes data. Here, precision measures the positive heart disease classes among all the positive heart disease classes.

$$\begin{aligned} Precision = \frac{True_{pos}}{True_{pos} + False_{pos}} \end{aligned}$$
(3)

5.1.3 Recall

The recall is defined by how many positive classes are predicted.

$$\begin{aligned} Recall = \frac{True_{pos}}{True_{pos} + False_{neg}} \end{aligned}$$
(4)

5.1.4 F1-score

F1 score uses both the precision and recall. So we can get a more intense look at the accuracy with F1-score.

$$\begin{aligned} F1-score = \frac{2 * Precision * Recall }{Precision + Recall} \end{aligned}$$
(5)

5.2 Achieved results

After the system implementation, the edge device Raspberry Pi acted as an intelligent entity for the prediction before sending the notification back to the server while collecting the data from the sensors. For this prototype, five sample data have been used to simulate the prediction with the edge device as the collected sensor data. The Raspberry Pi also sends the real-time notification as an Embedded device for the actuators to perform an action, in this case, it’s the LED notification lights. Figure 12 demonstrates the prototype of the Raspberry Pi-based Edge Intelligence system.

Fig. 12
figure 12

Prototype of Proposed Edge Intelligence System

For this particular prototype of the solution, two LED lights have been used to indicate two different notifications. The blue LED light blinks for three seconds to indicate that there is a probability of heart disease for the collected sensor data for one particular patient. The opposite case is applicable for the yellow LED light. It blinks for three seconds in the case of no probability of heart disease according to the prediction model.

The Microsoft Azure server has been used as the cloud end for the edge Raspberry Pi. The predicted outcome from the Raspberry Pi has been sent to the Azure server for each of the predictions done at the edge with the collected data for each patient. The Raspberry Pi sends data to the cloud in JSON format with one variable called “pred”. This variable contains the value of 0 or 1. 0 means no probability of heart disease for the collected data of the particular patient according to the predictive model and 1 means the probability of heart disease from the perspective of the same scenario. Figure 13 shows the prediction notification sent to the Microsoft Azure server from the edge Raspberry Pi through the Visual Studio Code Interface.

Fig. 13
figure 13

Prediction Notification Sent to Azure Server from Edge Device

As multiple machine learning-based prediction models and a deep learning-based model have been implemented to achieve the highest accuracy with efficiency and to compare the performance of these models to find out the best one, it seems that every model has performed closely but the proposed deep learning-based OQFFN Model yielded in a bit better result in terms of performance. Although, the time needed for performing a prediction varied from algorithm to algorithm and varied from Server to Edge. Table 2 shows the test accuracy levels for the several different prediction models with the Random Forest, K-nearest Neighbour, Support Vector Machine and Proposed Deep Learning-based OQFFN algorithms.

Table 2 Evaluation Metrics for all Prediction Models

So, the proposed deep learning-based OQFFN Algorithm has produced the highest accuracy and the Model with K-nearest Neighbour (KNN) has yielded comparatively the lowest accuracy in this prediction. The confusion matrix for each of the prediction models has also shown very acceptable results in terms of the accurately predicted numbers from the test data set consisting of 270 data rows.

From the confusion matrix, it can be understood that the distribution between the actual value and the predicted value is slightly different for each of the models and the proposed OQFFN resulted in the most accurate predictions. Table 3 illustrates the True-negative, False-positive, False-negative and True-positive values for all the prediction models.

Table 3 Prediction Performance for all Prediction Models

Figure 14 illustrates the distribution of the actual values versus the predicted values for the proposed deep learning-based OQFFN model.

Fig. 14
figure 14

Distribution of Actual Values Vs Predicted Values of Proposed OQFFN Model

For the real-time prediction at the edge, since the prediction models selected are very lightweight, the prediction time for any sample sensor value data is quite similar to the prediction time using the server or typical computer. So, prediction at the edge device has not caused any severe delay compared to the prediction at the server or typical mainframe computer. For comparison purposes, a typical mainframe computer with Intel 11th Gen Core-i5 processor has been used with a clock speed of 2.7GHz. Table 4 demonstrates the prediction time comparison for one particular sample data between the server/mainframe computer and the edge Raspberry Pi using three prediction models.

Fig. 15
figure 15

ROC curve of SVM and proposed OQFFN model

The receiver operating characteristic (ROC) curve helps to show the classification model’s effect at all verge of classification. As, from the machine learning models SVM worked the best, a comparison has been conducted using the ROC curve of the SVM model and the proposed OQFFN model. In the X-axis of ROC curve False-positive rate and in the Y-axis True-positive rate is plotted. The area under the curve (AUC) indicates the ability of the model to predict patients with heart disease and not with heart disease properly. The close the value of AUC is close to 1, the better the model is. From Fig. 15, it can be seen that the AUC of SVM is 0.735 whereas the AUC of the proposed OQFFN model is 0.923 which is very close to 1. So, the proposed deep learning model works significantly better than the best machine learning model.

Table 4 Prediction Time between Server Vs Edge for Different Prediction Models

From the comparison between the server and edge prediction time, it can be said that because of the insignificant difference between the server and edge prediction time, the edge Raspberry Pi has still managed to generate efficient real-time prediction without the analytical contribution from the server. Another fact is that considering all the performance matrices, the prediction model using the proposed deep learning-based OQFFN algorithm has outperformed other prediction models. The OQFFN prediction model has produced the highest accuracy which is about ninety per cent and the prediction time at the edge is basically indicating the real-time instant output which is less than half a second. The advantage of this prediction of heart disease at the edge is that it can function even if the network gets interrupted and provide real-time notification via the local embedded notification system in any ambient assisted living environment.

5.3 Comparison between recently existing literature and proposed technique

Fig. 16
figure 16

Comparison between proposed OQFFN and RF-LRG [21]

The Fig. 16 shows that after comparing the proposed OQFFN model with the latest RF-LRG model suggested by [21], the proposed model achieved better accuracy, precision, recall and f1-score. Data pre-processing steps and layered deep learning architecture caused this significant improvement in the proposed model.

6 Conclusion

In the Internet of Things-based Ambient Assisted Living environments, detecting the probability of heart diseases in real-time through machine learning-based techniques with the server-based approach can be considered a typical one. Adding the deep edge intelligence to this story of detecting heart disease in ambient assisted living environments excluding the primary prediction analysis on the server, brings more reliability with a less complex framework by reducing the effect of any probable network failure and network bottleneck. The proposed deep edge intelligence-based technique called OQFFN provides a real-time approach and prediction model to detect the probability of heart disease without having to forward the collected sensor data to the server for primary predictive analysis with a decent amount of efficiency and accuracy. The proposed solution also proves to be more reliable as it is tolerable of any kind of network interruptions because it can provide embedded alert notifications of any probable heart disease from the collected sensor data without the dependence on constant network stability for server-based analysis.

Although the proposed predictive solution at the edge is providing highly accurate and real-time prediction of heart disease probability, the system is still incapable of doing further analysis of the pattern or detailed specification of various kinds of heart diseases because those models require intensive processing capabilities to run more complex deep learning algorithms. The limited processing capabilities of the edge devices still create a big hindrance to operate with more densely layered deep learning algorithms in real-time where any advanced analysis from a big chunk of data is necessary.

In future, distributed prediction models can be developed considering intelligent resource allocation of the whole model at the edge and at the server. More data-intensive layered deep learning-based models can be implemented for further analysis of heart diseases to determine the exact type and cause of the disease. Techniques like Federated Learning can be used to protect the privacy of the sensor data used for disease prediction in a better way.