Machine Learning-Based Asthma Risk Prediction Using IoT and Smartphone Applications

In this paper, we present an asthma risk prediction tool based on machine learning (ML). The entire tool is implemented on a smartphone as a mobile-health (m-health) application using the resources of Internet-of-Things (IoT). Peak Expiratory Flow Rates (PEFR) are commonly measured using external instruments such as peak flow meters and are well known asthama risk predictors. In this work, we find a correlation between the particulate matter (PM) found indoors and the outside weather with the PEFR. The PEFR results are classified into three categories such as ‘Green’ (Safe), ‘Yellow’ (Moderate Risk) and ‘Red’ (High Risk) conditions in comparison to the best peak flow value obtained by each individual. Convolutional neural network (CNN) architecture is used to map the relationship between the indoor PM and weather data to the PEFR values. The proposed method is compared with the state-of-the-art deep neural network (DNN) based techniques in terms of the root mean square and mean absolute error accuracy measures. These performance measures are better for the proposed method than other methods discussed in the literature. The entire setup is implemented on a smartphone as an app. An IoT system including a Raspberry Pi is used to collect the input data. This assistive tool can be a cost-effective tool for predicting the risk of asthma attacks.


I. INTRODUCTION
Asthma is a chronic airway inflammatory condition that is known to occur as episodic wheezing, tightness of the throat, cough and shortness of breath. A rapid deterioration in these symptoms is an asthma attack, which can be fatal. Other serious non reversible airflow restriction in lungs includes respiratory chronic obstructive pulmonary disease (COPD) that involve emphysema and chronic bronchitis. The qual- The associate editor coordinating the review of this manuscript and approving it for publication was Jerry Chun-Wei Lin . ity of life of individuals of all ages is compromised by asthma because it restricts social, emotional and physical aspects of life. Globally, around 300 million people suffer from asthma [1]. Throughout the United States, nearly 17.7 million adults and 6.3 million children had been diagnosed with asthma in 2014 [1]. Asthma and COPD exacerbation prompt around two million visits to the emergency departments (EDs) annually in the United States. In the UK, asthma attacks cause 2.21 deaths per 100,000 people [2]. In South Korea, hospital admission rates for asthma patients are 98.5 per 100,000 people [3]. Health forecasting is one of the least developed branches of forecasting science. Forecasting health risks and integrating it into the individual's lifestyle can affect positively the quality of life of people. Environmental health has a major role to play in asthma attacks. Indoor air pollution and weather can be important factors for predicting asthma. Non-invasive techniques used today for diagnosing and controlling asthma do not fully characterize the degree of inflammation of airways and require expensive equipment that patients cannot easily afford [1]. Therefore, effective predictive modeling may help provide accurate guidance for patients to seek proper care or take medications to prevent from becoming ill and to assist them in preparing their mobility strategy.
Despite extensive research that shows a correlation between indoor air pollution and aggravation of asthma [4]- [6], providing a personalized risk assessment in real-time based on indoor air quality is still at an infant state. In [7], [8], a static relationship between the indoor air quality and the asthma attack is shown. However, these cannot be used for real-time assessment. In [3], a pilot study has been done to explore the relationship between indoor air quality and weather with peak expiratory flow rate (PEFR) measurements using deep learning models. PEFR of 14 pediatric asthma patients were collected regularly and corresponding air quality and weather data were monitored to find the correlation.
A variety of new healthcare technologies such as translational biology, medical imaging, bio-sensing, medical device processing, hearing aid systems, have been the subject of deep learning [9]- [13]. Deep learning has been comparatively less in use in predicting asthma and other respiratory disorders compared to other diseases. The majority of existing ML algorithms have been developed to predict asthma risks in clinical settings using historical data [14]. The better performance of deep learning models depends on the availability of large amount of data. To collect the data in real-time, cost-effective and portable sensors are required. Integration of these models with the internet-of-things (IoT) can play a vital role in the predictability of asthma attacks using deep learning models and the usability of the platform in real-world conditions. This paper is an extension of the study presented in [3]. However, in this work, a different neural network architecture is used to predict the risk of asthma. The asthma risk prediction model is implemented here on a smartphone (edge device). The key contribution in this paper is the development of a novel m-health tool that includes various sensors, an edge device and a machine learning model that operate in real-time using IoT protocols.
In the proposed method, the risk of an asthma attack is predicted using an air quality monitoring system and the weather report. The particulate matters PM2.5 and PM10 data are collected from an indoor air quality sensor. The temperature and the humidity of the patient's current location are collected from the weather report. The data collected in [3] is used here for developing a convolutional neural network (CNN) for predicting asthma. The PEFR readings collected in [3] are used as the labels in the training of the neural network here. The entire system is made up of a Raspberry Pi sensor platform and an edge device integrated using IoT protocols. We have chosen smartphones as our edge device because it is ubiquitous and has significant processing power. A shallow learning approach is used to implement the neural network model on a smartphone in order to match its processing capability.
The rest of this paper is organized as follows. Review of literature on studies related to ML applications to various diseases are mentioned in section 2. A detailed description of the proposed method is presented in section 3. The integration of the sensor platform and the smartphone is explained in section 4. Experimental results are shown in section 5 and conclusions are drawn in section 6.

II. RELATED WORK
This section reviews numerous experimental studies in which neural networks are used to predict health conditions and diseases. A ML-based heart disease prediction method using IoT is explained in [15]. In [16], a CNN-based prediction of chronic disease outbreak in disease-frequent communities is discussed. Parkinson's disease, which is a chronic neurodegenerative disorder is predicted using DNN models in [17], [18]. Studies in [19], [20] show that Alzheimer's disease, which is a cognitive impairment, can be diagnosed using artificial intelligence and CNN-based supervised learning. Recently, detection of Covid-19 cases using X-ray image classification based on DNNs has been demonstrated. [21]. Diabetic retinopathy is a diabetes complication that can affect eyes. Recently, a DNN-based prediction of diabetic retinopathy is shown in [22]. Severe Asthma prediction algorithms based on support vector machines: Naïve Bayesian classifiers and Random forest classifiers are explained in [23]- [25]. Liver metastases detection using fully convolutional networks (FCN) is explored in [26].

III. PROPOSED ASTHMA PREDICTION METHOD
In this section, we discuss the proposed asthma risk prediction method. The data and the deep learning network used for the model training are discussed. The block diagram of the proposed system is shown in figure 1. The weather data and the indoor air pollution characterized by PM2.5 and PM10 data are the input to the Deep learning model and the peak expiratory flow rate (PEFR) provides the labels used in training the model.

A. PEAK EXPIRATORY FLOW RATE (PEFR)
Pulmonary function test (PFT) is recommended to diagnose and manage respiratory problems [27]. However, it is difficult to collect PFT data using home-based self-tests. The Peak-flow meter has been a boon in home-based self-tests and is widely used to measure the degree of airway obstruction of asthma patients. Measuring PEFR is fairly straightforward, even for patients at home, using a compact portable peak-flow meter [28]. A research group has recently used weekly PEFR records to predict asthma deterioration in children using deep learning models [3]. This research group had conducted a pilot study that collected the PEFR data of 14 pediatric asthma patients. The PEFR values that were reported twice daily were interpolated over a period of 24 hours at an interval of 10 minutes [3]. The best value in each of the PEFR trials were recorded. The interpolated PEFR values have been categorized into three categories: ''green'' (when the reading is above 80% of the best peak flow; normal exacerbation), ''yellow,'' (when the reading is between 50% and 80% of the best peak flow; moderate exacerbation), and ''red'' (when the reading is below 50% of the best peak flow; significantly exacerbated). These categories are used as the output labels for our neural network modeling.

B. INDOOR AIR MONITORING AND WEATHER DATA
Around the same time-frame when the PEFR data were collected, low-cost sensors mounted at each patient's home, measured the particulate matters PM2.5 and PM10, and temperature and relative humidity every 10 minutes. Then, the indoor particulate matters data, weather data and the PEFR data were correlated for every 10 minutes timeinterval.

C. CONVOLUTIONAL NEURAL NETWORK BASED PREDICTION
The proposed convolutional neural network makes a regression-based decision that estimates the PERF readings. CNNs take a matrix or an image as input and process it across the network. Although the CNNs are commonly used for image classification tasks, there are several studies in disease prediction [19], [20], [26] and speech processing domains [12], [29] where they accept raw values of inputs in the form of a matrix or an array for CNN processing. So, in the proposed method, we consider CNNs with a matrix input for predicting the risk of asthma.
The proposed convolutional neural network (CNN) architecture has 4 hidden layers comprising of 2 convolutional layers, and 2 fully connected layers. The same network has been used in IoT implementation and experimental evaluations. The input layer has 4 features and the size of the input layer is 4 × 1. The first and the second convolutional layers use 64 feature maps to avail superior learning of the input features. The kernel for both convolution layers has a size of 1×1. The convolution is done with one stride on both the first and the second convolution layers. The fully-connected layers have 128 neurons. All the activation functions are ReLU and the output layer with the linear activation function has one neuron. The resulting network has around 1.5 million learnable parameters. The CNN loss function is the mean squared error and was minimized using Adam Optimizing Algorithm [30]. A batch normalization with truncated normal distribution with a zero mean and a standard deviation of 0.05 was done on all training vectors that contained all weights and biases for all nodes and kernels. The model was trained for 10 epochs. The performance of the model was estimated using a 10-fold cross-validation with a single fold leave out. Table 1 shows the details of the architecture of the proposed model and figure 2 shows the architecture diagram.

IV. IoT AND SMARTPHONE IMPLEMENTATION
In this section, we discuss the tools and the steps involved in IoT implementation. The real-time data collection, the utilization of the data and the smartphone app are explained in this section.

A. OVERALL PROCEDURE
For real-time prediction of asthma risk, we use an IoT platform, sensors and a smartphone. Raspberry Pi is used to collect the air quality data from an air quality monitor. The weather data is collected from an open source data provider in the web. The data collected on the raspberry pi and the weather data are hosted on a secured server. This data is then  utilized by the smartphone. The smartphone app which is bundled with the trained neural network model, fetches the required input data for the model from the server and predicts the risk for asthma. We discuss below each block of the IoT implementation. The pseudo code for the algorithm is shown under Algorithm 1 in the next page. The overall workflow of the tool is depicted in Algorithm 1 using two stages: the data processing stage on the Raspberry Pi and the real-time stage on the smartphone.

B. AIR QUALITY SENSOR
We use SDS011 air quality sensor to monitor the particulate matter in real-time. The sensor is directly attached to a Raspberry Pi via a wired connection. SDS011 air quality sensor is a small, portable and an accurate sensor to measure PM2.5 and PM10. The sensor is connected to the USB port and the drivers are provided by the device manufacturer for efficient working of the sensor with the raspberry pi. The measuring range of the sensor is 0.0 − 999.9µg/m 3 which is a wide range to monitor the particulate matters. How the sensor is connected to the raspberry pi is shown in figure 3.

C. WEATHER DATA
The weather data is accessed from an open source called Openweathermap [31]. This website provides an API for accessing the weather of any location. The service also provides an API for accessing the weather data of both the past and the future time which would be useful for computing the cumulative behavior of the asthma patients with respect to the weather condition. A Python API is used in the raspberry pi to collect the temperature and the humidity based on the patients' locations.

D. DATA HOSTING
Once the particulate matter data and the weather data are collected on the raspberry pi, they are hosted on a secured server VOLUME 9, 2021 for communicating to raspberry pi. Although, raspberry pi can connect with a smartphone via low latency Bluetooth, in the proposed method the connection is done over the internet so that the range of monitoring is longer. To overcome the same limitation of shorter bluetooth range, the data is hosted over the internet server ngrok IP instead of in a local server. We use a software tool called ngrok [32] to expose the local port. This ensures a safe and a secure hosting of the data in addition to the advantage that any person (example: personal physician) who is not even on the same network can access and monitor the patient's indoor air quality and health condition. Data hosting is shown in figure 4.

E. SMARTPHONE IMPLEMENTATION
The offline trained neural network model is implemented on a iPhone 11 smartphone to predict the risk of an asthma attack in real-time. The offline model is trained in TensorFlow, an open end-to-end ML platform [33]. We use TensorFlow software as it provides C++ APIs to implement the inference only model on embedded devices. Tensorflow comes with a Tensorflow-Lite version of converter and interpreter to enable running the models on edge devices. We use these software tools to implement it on a smartphone and the smartphone implementation is done using C++. The graphical user interface (GUI) is developed using objective-C. Figure 5 shows the GUI of the smartphone app that we have developed. The smartphone takes the URL of the secured IP address generated from the Ngrok server as input. The data that is hosted on the server which forms the input to the neural network model is displayed on the smartphone. The data values displayed are passed on to the trained neural network model which is in.tflite format. This inference only model generates the estimated PEFR value as the output. The estimated PEFR value should be compared to the best peak flow reading of the individual at that time to assess the risk of an asthma attack. Therefore, the GUI asks for the PEFR value of the patient at that time. Once the best PEFR value of the peak flow trials at that time is entered, the risk of the asthma attack is calculated. The result is displayed as Safe, Moderate, or Risky based on the predicted PEFR and the PEFR value entered by the patient. ''Safe'' is displayed when the predicted PEFR is above 80% of the best peak flow reading, ''Moderate,'' is displayed when the predicted PEFR is between 50% and 80% of the best peak flow reading, and ''Risky'' is displayed when the predicted PEFR is below 50% of the best peak flow reading entered by the user. This is a low-cost platform. All of the software tools used are open source tools. Smartphones have become ubiquitous and so the requirement of an additional auxiliary device is unnecessary.

V. EXPERIMENTAL RESULTS
For evaluating the CNN model used here, we compute the root mean square error (RMSE) and the mean absolute error (MAE) as our performance metrices. We calculate the RMSE and MAE between the actual PEFR and the estimated PEFR. The 14 Asthma patients' data is divided into 70% for training and the remaining 30% for testing. The model has not seen the testing data during any phase of training. We compute RMSE and MAE for the test data. The RMSE and the MAE results are 2.42 and 2.12 respectively when the model is trained on all the data i.e. using the data from all 14 individuals. We also computed the RMSE and the MAE for the individual patients i.e. the training and testing of the model was done using the data from a single patient. From the Table 2 and Table 3, we can see that the average RMSE and MAE for the individual patient data are 1.36 and 1.09 respectively. For instance, if the typical PEFR reading for a patient is 180 L/min, the overall estimation error is less than 1%, which is significantly small.
The proposed CNN-based classification model was compared to a stacked Deep neural networks (DNNs) model used in Ref. [3]. For objective comparison, we use a feed forward single layered neural network architecture [25] and a fully connected convolutive architecture [26]. The RMSE   comparison between all patients data and the average of individual patient data is also shown in Table 2. We observe an improvement of ≈61.1%, ≈54.3% and ≈20.8% by using the proposed method when compared to single layered ANN [25], stacked DNN [3] and FCN [26] respectively. The graphical representations of Tables 2 and 3 are shown in figures 6-9.
The CNNs are more commonly used for classification than other DNNs or the Long Short Term Memory (LSTM) networks because the CNNs have weight sharing characteristic that comparatively reduces the number of parameters. As there are less parameters in the CNN model, the inference time is quite low and thus suitable for smartphone implementation. Given that we can get the individual patient data by   recording them or from their medical history, the proposed method can be trained for each individual making it a personalized application. We can also employ Transfer learning methods [34] where a generalized neural network model can be trained for an individual by using his or her specific data. This will reduce the error and improve the performance considerably.

VI. CONCLUSION
In this paper, we presented an asthma risk prediction tool based on a convolutional neural network. The PEFR readings are predicted using simple PM and weather data. The performance improvement of the proposed method is observed using objective evaluations. This cost-effective tool involves an edge device, sensors and an IoT platform. The entire tool is implemented on a smartphone as a m-health application using several resources of IoT. The tool can be successfully used to predict asthma risk of individual patients. SUNGCHUL SEO received the Doctor of Philosophy degree in environmental health and occupational hygiene with strong background in aerosol science, extensive experiences in project management and laboratory works, and exposure assessment for radon and air pollutants, as well as chemical/biological agents. Since 2018, he has been the President of Korea Association of Radon. He is currently a Professor with Eulji University, Seoul, South Korea. He has served on the executive boards of Korean Society of Indoor Environment, and for over 20 years he is dedicated to the improvement of indoor air related to environmental health, including radon, particulate matters, and bioaerosols. Recently, he is focusing on establishment of prevention platform using deep learning technology based on big data attributed to real-time the IoT devices. He has many funding as well as academic articles. His research interest includes development of monitoring system for the level of environmental risk factors (i.e., fine particulate matters) to prevent diseases exacerbations. degree in electrical engineering from the University of Rhode Island. He is currently a Professor of electrical and computer engineering with The University of Texas at Dallas (UTD), Richardson, TX, USA, where he is also the Director of the Quality of Life Technology Laboratory. Previously, he was the Founder, the CEO, and the CTO of Yotta Networks Inc., a company that designed and marketed terabit-switching platforms. He also worked as a Senior Manager directing research on advanced optical networks with Alcatel's Corporate Research Center, Richardson. He is also working as the President and the CEO of HygeiaTel Inc., a start-up that commercializes some of the innovations of the Quality of Life Technology Laboratory and as a member of the advisory boards of a few companies. His invention was the core asset of Spike Technologies, Inc. that developed and marketed the antennas for the early MMDS system, a precursor to the modern Wi-Max. He has been a Technology Consultant with Raytheon Company, Electrospace Systems Inc., Spike Technologies Inc., Lighthouse Capital Partners, and McKool Smith LLP. Over the course of his career, he has contributed to more than 150 research publications and 23 patents, and has directed 23 doctoral dissertations. His research interests include telemedicine, the Internet of Things (IoT), and machine learning and artificial intelligence applications to medicine and healthcare. He has also served as an Associate Editor for Radio Science (Journal Sponsored by the American Geophysical Union and the International Radio Science Union) and as a member of the Editorial Board of Optical Fiber Technology: Material, Devices and Systems (Elsevier) and Optical Network Magazine (Kluwer Academic Publishers). He is a fellow of the National Academy of Inventors (NAI), the Optical Society of America (OSA), and The Electromagnetics Academy (TEA), an Elected Member of the International Radio Science Union (URSI) Commission B and D and, a member of the American Association for the Advancement of Science (AAAS). VOLUME 9, 2021