## 3 Detection of Cyber-Attacks with Supervised Machine Learning-Artificial Neural Networks
### Deployment of Supervised Machine Learning-Based Artificial Neural Networks
```
Input:\([x_{n}:V_{C},I_{L},dV_{C}/dt,dI_{L}/dt,G,T]\) Output: Weighting factors of cyber-attack situation [Attack_Bit, \(V_{DC}\)]
1: Initialize network_parameters (\(w_{t,i\bar{y}},b_{k,j}\)) with proper values #Training Phase
2: For epoch in range(num_epochs):  For each training_sample (\(x,y\)) in training_data:  For each layer \(j\) in the network: \(h_{t,j}=w_{t,j\bar{y}}\ast x_{t,i}+b_{k,j}\) \(r_{t,j}=f_{hidden\_activation\_function}(h_{t,j})\)
#Error Calculation-Loss Function
3: Loss = compute_loss(Attack_Bit, \(V_{DC}\) [output_layer], \(y\))
#Backpropagation
4: Compute gradients of loss with \(w_{t,i\bar{y}}\) and \(b_{k,j}\)
5: Update new \(w\) and \(b\) through gradient descent
#Test Phase
6: For each test_sample \(x\) in test_data:  For each layer \(j\) in the network: \(h_{t,j}=w_{t,j\bar{y}}\ast x_{t,i}+b_{k,j}\) \(r_{t,j}=f_{activation\_function}(h_{t,j})\)
7:\(Attack\_Bit=f_{activation\_function}(w_{t,i\bar{y}},\)\(r_{t,j},\)\(b_{y})\) Estimated_output =Attack_Bit, \(V_{DC}\) [output_layer]
8: Return trained_model
9: Calculate the Cross-Entropy after training for ANN-I
10: Calculate the mean squared error (MSE) after training for ANN-II
```  
**Algorithm 1** Pseudo-code flow of the executed ANN structures  
The distribution of attack sizes was selected randomly; however, for clarity, it adheres to a uniform distribution over a specific time interval to ensure a realistic representation of cyber-attacks. If the distribution is executed between a time interval \([x_{i},x_{k}]\), a uniform distribution can be modeled as  
\[f(x)=\frac{1}{x_{k}-x_{i}},\hskip 30.0 ptx_{i}\leq x\leq x_{k} \tag{16}\]  
The perturbations were introduced within a fixed range, maintaining an unbiased and evenly distributed modification of sensor data. This approach enhances the robustness  
Figure 4: Schematic structure of the utilized ANN for estimating the correct output (x: input, \(y\): output, w: weights, b: bias, and f: activation function). (**a**) ANN-I structure for the cyber-attack detection scheme and (**b**) ANN-II for estimating the DC bus voltage–VDC. of the proposed system evaluation. A large dataset (2.8 million samples) was utilized to improve generalization performance, as neural networks require extensive data to mitigate overfitting due to their high number of parameters. As widely recognized, larger datasets support better generalization, particularly in scenarios with high variability. In PV-supported energy systems, cyber-attacks are often complex and unpredictable, increasing the risk that models trained on limited data may fail in real-world deployments. Consequently, 2.8 million samples were employed to capture diverse attack patterns and enhance robustness. Furthermore, in power electronic systems--particularly those with converters operating at a switching frequency of 25 kHz--high-dimensional datasets are essential for accurately capturing system dynamics in simulation studies. The training dataset was synthetically generated using a high-fidelity MATLAB/Simulink model of a PV-powered energy island scheme. The dataset size was determined based on the need for robust generalization across diverse attack scenarios and operating conditions. The low sampling time chosen to make the simulation realistic provides more precise and accurate results in the Simulink environment, which is especially important in systems with fast transients. However, it can increase the computational load and extend the simulation time. Choosing an optimal value depends on the dynamics of the system; a very small value creates an unnecessary processing load, while a very large value can reduce precision. Although it increases the computational load on the training data, it provides an adaptive solution against other situations by offering depth for good training data. Having a significant amount of training data increases the training time. While extended training is generally not a major concern, it presents a crucial challenge for practical development.