## 2 Development of the Algorithm
### Dataset Structure
The results of testing this basic model are presented below in Table 1.  
To ensure consistent training conditions for all ML models throughout the study, the following training parameters were established:  
* Number of model training epochs: 80 (the average time spent on training models was 25 min);
* Optimizer: Adam algorithm;
* Error function: cross entropy. \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Metrics** & **N** & **P** & **S** & **SI** & **V** & **VI** \\ \hline \multirow{2}{*}{Precision} & 0.9725 & 0.5741 & 0.618 & 0.4565 & 0.5606 & 0.7358 \\  & (0.96, 0.98) & (0.54, 0.6) & (0.58, 0.64) & (0.42, 0.48) & (0.52, 0.59) & (0.7, 0.76) \\ \hline \multirow{2}{*}{Sensitivity} & 0.6698 & 0.6526 & 0.6471 & 0.6774 & 0.6379 & 0.65 \\  & (0.64, 0.69) & (0.62, 0.68) & (0.61, 0.67) & (0.64, 0.7) & (0.61, 0.66) & (0.62, 0.67) \\ \hline \multirow{2}{*}{Specificity} & 0.9939 & 0.8647 & 0.9029 & 0.9381 & 0.9231 & 0.9627 \\  & (0.98, 0.99) & (0.84, 0.88) & (0.88, 0.92) & (0.92, 0.95) & (0.90, 0.93) & (0.95, 0.97) \\ \hline \multirow{2}{*}{F1-score} & 0.7933 & 0.6108 & 0.6322 & 0.5455 & 0.5968, & 0.6903 \\  & (0.76, 0.81) & (0.58, 0.64) & (0.6, 0.66) & (0.51, 0.57) & (0.56, 0.62) & (0.66, 0.72) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Performance indicators of the primary encoder model with confidence interval. During the first training stage, as described in Section 2.2, we conducted an iterative process to determine the optimal hyperparameter values to maximize the encoder's accuracy. After fixing these values for the primary encoder model, they were applied to train subsequent model versions. The specific hyperparameter values are detailed below:  
1. The Adam optimizer has a learning rate of \(3\times 10^{4}\). 2. The size of the latent space in the encoder was 512. 3. The batch size was 128. The technical specifications of the apparatus employed for training the models were as follows:  
* Cores/Threads: 8 cores/16 threads;
- Clock Speed: 3.8-4.6 GHz;
- Cache: 4 MB L2, 16 MB L3;
* System Memory: 32 GB DDR4 (\(2\times 16\) GB modules). We trained and tested the primary encoder model using the transformed dataset to classify six classes, which include the main stages and two late-stage scenarios. To assess the performance of our classifiers, we utilized the following set of metrics:  
* Precision measures the proportion of correct positive predictions among all positive predictions made by the model, including false positives. High precision indicates a significant probability that the answer is correct in the case of positive predictions for a given class [60];
* Sensitivity is the ratio of correctly identified positive cases to the total number of positive cases, including false negative cases. A high sensitivity value indicates that the model is more efficient at correctly identifying positive cases [60];
* Specificity measures the ratio of correctly identified negative cases to the total number of negative cases. A high specificity indicates that the model accurately identifies negative cases [60];
* F1-Score is the harmonic mean of precision and recall. It measures the model's overall performance, considering both false positives and false negatives, especially when dealing with class imbalance [60]. Figure 1 and Table 1, with confidence intervals for a 95% confidence level, present the encoder testing results in an error matrix. The analysis of the confusion matrix and evaluation metrics for the binary classifier indicated that the model's performance was suboptimal. This was primarily due to its difficulty distinguishing the intermediate state and the imbalance between the SI and VI categories, which exhibit similar characteristics to AMD's early and advanced stages. The model demonstrated a conservative approach characterized by high precision but low recall. This indicated that while it was unlikely to make errors in classifying categories N and VI, there was a significant chance of missing many actual instances of these categories.