## 4 The Proposed Real-Time Monitoring System
### Proposed Encoding-Based Machine Learning Model  
ML models evaluate a patient's risk for heart attack, stroke, or sudden cardiac arrest by analyzing risk factors such as age, chest pain, and shortness of breath. This assessment helps in identifying heart-related issues in real-time and provides preventive care. In the proposed encoding-based model, the risk factors are encoded to calculate the risk score (RS) and vital score (VS), which represent the preprocessing for the feature extraction process. The calculation of the risk factor score is performed based on encoding two features (chest pain and shortness of breath) that have high priority for being important symptoms as listed in Table 4. However, this is due to applying the PCA algorithm for providing initial preprocessing, demonstrating that only the CP and SoB have a strong influence on impacting the model performance. Hence, we only considered these two crucial risk factors in the proposed encoding-based algorithm. It can be seen from Table 4, for instance, when \(RS\) is equal to 0, this implies that the patient does not have an issue with these signs, whereas \(RS=1\) indicates that the patient is suffering from shortness of breath. When \(RS=3\), then the patient has both chest pain (CP) and shortness of breath (SoB). Therefore, they are encoded with two bits (\(b_{0}\) and \(b_{1}\)), which are equivalent to SoB and CP, where CP represents the most significant bit (MSB = \(b_{1}\)) and SoB represents the least significant bit (LSB = \(b_{0}\)). The values of \(RS\) are then encoded (steps 6 to 11 in the pseudo-algorithm) and stored in a lookup table (LUT1). Figure 4: Applying the PCA algorithm for dimensional reduction, (**a**) variance level for PCA components, (**b**) components stability. Vital score (VS), on the other hand, has been encoded based on the five most important vital signs, including Glasgow coma (GC), SPO2, systolic/diastolic blood pressure (BP), heart rate (HR), and respiratory rate (RR), which is equivalent to (\(b_{4}b_{3}b_{2}b_{1}b_{0}\)), respectively. These vital signs have been considered the highest priority factors to guide labeling the output classes for the classification process. We represent each factor with a single bit; thus, five bits are needed for encoding the vital signs and calculating the value of \(VS\), as illustrated in Algorithm 1 from step 12 to step 26. Afterward, the values of the vital score are stored in a lookup table (LUT2). The encoded values of both RS and VS are then fed to 32 case statements to predict the status of a cardiac patient. The output condition of the comparison process, along with the vital sign score, is then fed to a lookup table (LUT3/LUT4) to provide the predicted status of the patient, as illustrated in Figure 5. Because the output of the condition is a Boolean (false/true), 64 possible statements are stored in two LUTs (LUT3 and LUT4) with a capacity of 32 locations. These LUTs work in parallel with a control signal for read enable. The VS value (five bits) is used as the address lines for both LUTs, whereas the condition is inverted and connected to the read enable (RE) signal of LUT3 and directly connected to the RE signal of LUT4. Thus, if the condition becomes false, then the status stored at the location indicated by the VS value of LUT3 goes to the output to be the predicted status. Otherwise, the statement in the equivalent location of LUT4 passes to the output. To further understand the working mechanism of the encoding-based model, we provide a case study that takes an example of three different cardiac patients, listed in Table 5 as follows: \begin{table}
\begin{tabular}{c c c} \hline \hline  & **Risk Factors** \\ \hline
**Risk Score (RS)** & **Chest Pain?** & **Shortness of Breath?** \\ \hline
2 & 1 & 0 \\ \hline
3 & 1 & 1 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Risk factor score.