## 1 Introduction  
Detecting contamination, the presence of parasites, or infection with viral or bacterial pathogens in animals, is crucial in today's food industry. Mass food production constantly encounters such problems. Therefore, the critical issue is an early response to the contamination, which is possible with the necessary measurement equipment. This article proposes advanced AI classification of eggshells' origin to determine whether they were obtained from a healthy hen or a _Mycoplasma synoviae_ (MS)-infected one by means of spectral analysis. Mycoplasma synoviae_ is a bacterium that can be transmitted both horizontally and vertically through an infected egg. Its presence in the oviducts of hens can lead to changes in the shell surface associated with eggshell apex abnormalities syndrome. Shell lesions include altered shell surface, thinning and increased transparency in various areas, which can lead to more cracks and fractures of the eggshell [1; 2]. The occurrence of MS in flocks of laying hens results not only in a decrease in laying rates, but also in a significant decrease in shell quality associated with ultrastructural changes in the shell surface [3; 4]. The occurrence of cracks due to changes caused by the presence of MS in the reproductive system can lead to damage, dehydration, and microbial infection of the embryo, leading to higher embryonic mortality [5; 6]. Many methods have been developed to detect MS infection from serum, swabs, and tissue samples. Serological tests such as the serum plate agglutination test (SPA), enzyme-linked immunosorbent assays (ELISA) [7; 8], and hemagglutinin inhibition test (HI) are commonly used for diagnosis [9; 10]. Culture methods using pleupropneumonia-like organisms (PPLO) broth can also be employed, but they are time-consuming, taking up to 28 days [11]. Molecular methods, including polymerase chain reaction (PCR) [12; 13; 14] and its variations like real-time PCR [15], multiplex PCR, loop-mediated isothermal amplification (LAMP) [13; 14; 15; 16; 17; 18; 19], and polymerase spiral reaction (PSR), are widely used for MS detection. PSR, for instance, is 100 times more sensitive than PCR and has a higher positive rate (69.9%) than ELISA (65.3%). The authors propose different approaches to detecting MS infection to those mentioned above. The proposed method may be used directly on farms by staff members with limited qualifications, as well as by veterinary doctors, assistants, or customs officers. It involves spectral, rapid measurement with data post-processing and AI classification [20; 21; 22; 23; 24]. Classifying samples' biological origins through spectral data analysis is now a trend, i.e., honey-type classification [25] or whether an egg comes from an MS-infected chicken or healthy chicken [26; 27; 28]. Given the wide range of possible biological samples and their inherent variations, numerous approaches are employed for the analysis of obtained spectral data. Moreover, spectral data may also vary depending on what kind of spectral response is measured: transmittance, reflectance, absorption, scattering, fluorescence, etc. Principal Component Analysis (PCA) is one of the most popular data analysis methods [29; 30; 31; 32; 33]. However, due to factors like subraces, age of hens, egg colouring, diet, and climate, eggshells' diversity is so extensive that standard PCA algorithms prove ineffective. Alternative approaches, such as using classifiers like the Spanning tree combined with various data reduction techniques, can be successfully employed, as shown in [27]. Employing this classifier in a specific case leads to the analysis of multiple levels in a tree structure. In their research, the authors concluded that machine learning algorithms were the most efficient for differentiating whether eggs originated from healthy or MS-infected hens. The presented paper is a fruitful follow-up of a previous work.