## 2 Development of the Algorithm
### Dataset Structure

Table 2: Performance indicators of the primary encoder model with the inclusion of parallel convolutional layers in the architecture with confidence interval. Figure 3: Encoder error matrix with the inclusion of parallel convolutional layers in the architecture. Analyzing the data presented in Figure 3, we can conclude that the complexity of the trained model in separating classes S and SI requires additional measures to eliminate this disadvantage. The error matrix indicators indicate that class SI, from the point of view of the trained model, is closer to class S than to classes V and VI, which would be more logical from a clinical standpoint. Furthermore, the error matrix indicates that the model struggles to distinguish between classes V and VI, highlighting the need for a solution. An error analysis of the current version of the encoder model prompted us to take the following steps:  
1. We applied a hierarchical classification approach, in which we identified the base classes of the senior hierarchy, and then defined the classes subordinate to them. 2. We consciously changed the clinical hierarchy of AMD stages given in Section 2.1, adapting it to solve the problems of class overlap for the trained encoder model. In clinical practice, the development of a model to recognize essential hierarchies or create a global classifier should focus on four main categories: absence of disease, early stage of AMD, intermediate stage, and late stage of AMD. However, an analysis of results from different encoder versions has shown difficulty distinguishing between the GA stage (SI class) and the early stage of AMD (S class). This challenge is mainly due to the presence of overlapping features in OCT images, a phenomenon that has also been noted in other studies [63]. A similar issue arises when differentiating between the SF stage (VI class) and the late stage of AMD (V class) because of overlapping specific features, which have also been reported in other research [64]. Due to the overlap between classes S and SI and V and VI, we adjusted the hierarchical structure to simplify the classification task for the trained model. In the new hierarchical structure, the initial stage of AMD, referred to as class S, has been replaced with class S', which now encompasses both S and SI. Similarly, the later stage of AMD is classified as V', which includes only V and VI. To ensure users receive accurate information about the stages of AMD according to true classification, a deterministic set of rules has been developed that transforms AMD output data. The allocation of a new base class, S', which includes the SI class and has a lower tendency to overlap with the P class, can help the model better distinguish the class within the whole of S'. Incorporating regression models into the structure of the hybrid classifier will further enhance this distinction. In cases where the definitions of the class between P and S are unclear, the regression models will still provide valuable insights. In order to carry out a hierarchical classification in accordance with the above principles, we divided the difficult task of classifying six non-equilibrium classes into more manageable subtasks. As a result, the following components of the developed hierarchical classifier were identified:  
1. Global classifier for the classification of primary classes of AMD stages: N, P, S' and V';
2. Binary classifiers working within the S' and V' classes to separate S and SI and V and VI, respectively;
3. Regression model for estimating the degree of proximity of class P to classes S and V.  
It is important to note that the image features extracted by the global model using different convolutional layers can act as input to binary classifiers. This significantly reduces the computational complexity required for high accuracy, sensitivity, and specificity. This is achieved by passing information directly from the global model to these classifiers from intermediate layers.