## 2 Materials and Methods
### Data Preprocessing  
The raw downloaded spectra were internally calibrated within each wavelength range of BP and RP. These were processed using the GaiaXPy library, where each spectrum is calibrated and sampled to a default uniform wavelength grid using the calibrate routine, resulting in a single spectrum on the wavelength range covered by BP and RP. This calibration and sampling process generates flux values for all the sampled absolute spectra, resulting in a total of 343 values per spectrum. The default sampling was used, resulting in a wavelength range from 336 to 1020 nm, with a 2 nm increment between each sampling point. To improve the performance and stability of machine learning algorithms during training and inference, min-max normalization was applied to the flux values of each spectrum, setting a scale of 0-1 [14]. This approach expressed all spectrum values as a fraction of the maximum value, establishing a common scale across different spectra (See Figure 1). This prevents certain variables from dominating others due to their absolute values. The following equation demonstrates how min-max normalization is applied:  
\[X_{scaled}=\frac{X_{i}-X_{min}}{X_{max}-X_{min}}, \tag{3}\]  
The normalization process allows for a clearer distinction between different types of spectra, even at a glance. The spectrum of the PN is predominantly composed of emission lines, while the RG spectra mainly exhibit a continuum with many absorption lines and/or bands. On the other hand, the SS spectra represent a combination of both, displaying emission lines and absorption bands in the IR region of the spectrum (700 to 1000 nm). \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Stars** & **Downloaded** & \multicolumn{2}{c}{**Selection**} \\ \hline Symbiotic Stars & 201 & 0.29\% & 201 & 10.18\% \\ Planetary Nebulae & 574 & 0.82\% & 574 & 29.06\% \\ Red Giants & 69,146 & 98.89\% & 1200 & 60.76\% \\ \hline Total & 69,921 & 100\% & 1975 & 100\% \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Class distribution between the originally downloaded stellar spectra and those selected for the initial analysis, revealing imbalances in the representation of star types. Figure 1: The figures represent three different types of stars, (blue) symbiotic star [EM* AS 323], (red) red giant [2 MASS J04390924+2847545], and (green) planetary nebula [Hen 2-442]. In the initial diagram, the flux values are denoted in Watts per nanometer per square meter (W/nm/m\({}^{2}\)), derived from external calibration using GaiaXpy library. In the adjacent figure, the flux values are normalized to a range between 0 and 1. This dataset consists of 1975 records representing the spectra of the target stars. Each record is composed of 343 features, corresponding to the normalized flux values within the wavelength range of 336 to 1020 nm. Furthermore, an extra column was incorporated in the dataset, which contains the corresponding labels for the star types. These labels are crucial for identifying and classifying each spectrum based on its category, enabling the utilization of supervised algorithms for training and prediction purposes. The data exhibit a notable class imbalance, as there is a significant difference in the number of spectra for each star type. Data imbalance can have a detrimental impact on the performance of machine learning algorithms because they may struggle to learn patterns, and make inaccurate decisions for minority classes. This assertion was conclusively validated in Section 3.3, which further substantiates the analysis through weighted loss calculations and presents the outcomes of a ten-fold cross-validation procedure, assessing the findings by computing mean and standard deviation values. To mitigate this issue and improve classification accuracy, data balancing techniques were implemented, such as oversampling the minority class and undersampling the majority class, ensuring an equitable distribution between both classes [15].