# Embedded AI-Based Digi-Healthcare
## 4 Design and Implementation
### Software Development
#### 4.2.2 Data Pre-Processing  
This part of the implementation was further divided into steps to ensure a clean dataset ready for ML training. These steps are further described below:  
1. **Local Instance Creation** SQL language is used to query relational databases for extracting relevant information. AWS provides its own query service known as Athena which is also based on standard SQL. As the database was already hosted on the AWS cloud, Athena was used to query the database and create a local instance of the required dataset. The local dataset had the required data of the three physiological parameters namely heart rate (BPM), body temperature (\({}^{\circ}\)C), and blood oxygen saturation (SpO\({}_{2}\)). From the Athena console, the dataset was downloaded as a comma-separated (.csv) file.
2. **Data Cleaning** The local dataset was then further processed and cleaned so that it would be ready to feed for the training of an ML model. It was made sure that there were no null values in any row (masking) and the precision of the data points was uniform throughout. This step was achieved using python's data analysis library, pandas. Data cleaning was an important measure because null values and non-uniform data points adversely affect the accuracy of any ML algorithm [17].
3. **Data Labelling** The problem of developing a module for healthcare prediction was modeled as a binary one. Under this binary model, the predicted values fell under two classes namely 'Healthy' or 'Un-healthy', based on the three vital parameters. The MIMIC-III database had no data which could be uniformly used as the target class for the ML model. Hence, the dataset had to be labeled automatically so that it can be used for training purposes. For data labeling, the powerful numeric computing environment MATLAB was used. The data was labeled according to the medically accepted normal human body ranges of vital parameters which can be found on different websites and scholarly articles. A patient's vitals were labeled as 'Unhealthy' if they fell out of range of normal body functioning. The ranges are mentioned henceforth: (a) **Body Temperature:** 36.5 \({}^{\circ}\)C to 37.3 \({}^{\circ}\)C [18] (b) **Heart Rate:** 60 to 100 beats per minute [18] (c) **Blood Oxygen Saturation:** 95% or higher [19] After labeling, the dataset was in the required format with de-identified time-stamps as seen in Figure 7 where a '0' label specified 'Healthy' while '1' specified 'Un-healthy'.
4. **Data Splitting** Traditionally, to employ machine learning algorithms, the datasets are randomly split into two parts: training and test sets. The data is assigned randomly to any of the  
Figure 7: An instance of the labelled dataset.  
two sets, but according to a particular ratio. The widely accepted train-test split ratio is 80:20 where the training set contains 80% of the data and the test set contains 20% of the data. The purpose of this split is to evaluate the ML model and check its accuracy against the test set. The model is trained solely on training data and then its performance is tested on the test set to gain insight into the validity of the model. For this purpose, we split the dataset into randomized 80:20 training and test sets using python.