## 4 Proposed Framework
### EdgeGuard Framework
#### 4.1.1 Local Model Training  
The local training process is independently conducted using locally stored data on each IoMT edge device. We consider \(N\) edge devices as \(\mathcal{E}=\{ed_{1},ed_{2},\ldots,ed_{N}\}\). Let there be \(M\) medical sensors at each edge device denoted as \(\mathcal{S}=\{s_{1},s_{2},\ldots,s_{M}\}\) sending their health data to the IoMT environment for processing and analysis. Each sensor generates a set of health measurements, \(mathcal{}H=h_{1},h_{2},\ldots,h_{Z}\), along with particular parameters like the timestamp, sensor type, and measurement value \((h_{i}imei,h_{i}ypei,h_{o}aluei)\). The edge device consists of computational resources characterized by CPU, memory, and bandwidth capacities \((E_{CPU}^{i},E_{Mem}^{i},E_{BW}^{i})\). A convolutional neural network (CNN) is utilized at the edge devices to process and analyze the health data. The neural network comprises \(p\)-\(q\)-\(r\) number of neurons at the input, hidden, and output layers. These layers are interconnectedthrough NN weights \((\{w_{h_{1}},w_{h_{2}},\ldots,w_{l_{p}},w_{H_{1}},w_{H_{2}},\ldots,w_{H_{q}},w_{O_{ 1}},\ldots,w_{O_{r}}\})\), with the size of the NN as \(S\), such that we have the following:  
\[S=(p+1)\times q+(q\times r)=q(p+r+1)\Rightarrow q(p+2)\text{ as }r=1 \tag{21}\]  
The NN weights and biases \((b)\) are initialized randomly in the range of \([0,1]\). The CNN collects the historical health data and normalizes the data to create and provide \(p\) input values, such as \(\{DS_{1},DS_{2},\ldots,DS_{p}\}\), into the input layer. The prediction process consists of three main steps: training, testing, and prediction. Data validation is conducted to improve the model's performance, using the mean absolute percentage error (MAPE) as the error function to assess the model's accuracy. The pre-processing of data extracts health measurements from different sensors and aggregates them over a fixed time interval. To normalize the input data within the range of \([0,1]\), the data aggregation process is applied, as shown in Equation (22):  
\[\hat{D_{i}}=\frac{D_{i}-D_{min}}{D_{max}-D_{min}} \tag{22}\]  
In the dataset, \(DS_{max}\) represents the highest value obtained, while \(DS_{min}\) corresponds to the lowest value. The normalized data, denoted as \(\hat{DS}\), comprise a collection of all normalized data values, represented as \(D\hat{S_{1}},D\hat{S_{2}},\ldots,D\hat{S_{n}}\). These normalized one-dimensional values are utilized as input to the input layer of the CNN. This model analyzes previous \(p\) health data values to predict the health status \((Y_{out})\) at the \(p+1 th\) time instance. The \(ReLU\) activation function, as depicted in Equation (23), is used in the hidden layers:  
\[ReLU(x)=\max(0,x) \tag{23}\]  
The evaluation of the accuracy and performance of the LM training process is carried out by utilizing the _MAPE_ score, as given in Equation (24):  
\[MAPE=\frac{100\%}{n}\sum_{i=1}^{n}\frac{|Y_{predicted}-Y_{actual}|}{Y_{actual}} \tag{24}\]  
where \(n\) represents the total number of data samples, while \(Y_{actual}\) and \(Y_{predicted}\) correspond to the actual and predicted health status, respectively. Stochastic gradient descent with momentum (SGD-M) is employed to achieve dynamic and adaptive optimization of the network weights. In this context, velocity \((v)\) represents the gradient change needed to reach the global minimum, as expressed in Equation (25):  
\[w_{t+1}=w_{t}-v_{t} \tag{25}\]  
The updated weight vector is represented as \(w_{t+1}\), while the current weight vector is denoted as \(w_{t}\). The calculation of \(v_{t}\) can be performed using Equation (26):  
\[v_{t}=\beta\cdot v_{t-1}+\eta\
abla w_{t} \tag{26}\]  
Here, the momentum is represented by the term \(\beta\cdot v_{t-1}\). The constant \(\beta\) has a value between 0 and 1, the learning rate is denoted as \(\eta\), and \(\
abla w_{t}\) corresponds to the gradient of the loss function for the weight. \(v_{t-1}\) represents the velocity at the previous step.