## 2 Materials and Methods
### Data Analysis  
Analysis of the training set spectral data was performed using Consumer Physics Inc. software, the \(\text{SCiOT}\)Lab. This software provides the user with a small range of pre-processing methods that can be applied to the data within the library. The output or data gathered with the studied instrument is made up of a reflectance spectrum comprised of a total of 300 discrete reflectance points in a one-nanometre scale that ranges from 740 to 1040 nm. In order to eliminate any noise from the environment and the instrument, as well as to ensure the spectra were reproducible, a series of pre-processing techniques commonly used in the field of chemometrics, and included in the instrument's software, were applied to the data. A combination of Subtract Average, Standard Normal Variate (SNV), 1 st Derivative, with a window of 35 points and polynomial degree of 2, and wavelength selection of the spectral region between 800 to 1000 nm, was identified as the best pre-processing method and used to design a series of models with different parameters using the Partial Least Squares (PLS) algorithm [29; 30] employed by the instrument's software. Their theoretical performance was assessed through internal 'leave-one-out' (LOO) cross-validation performed automatically by the software once a model was built. This cross  
Figure 1: Experimental workflow from sample collection to model performance evaluation. Created with BioRender.com. * presents corrosive compounds.  
validation follows the venetian blinds approach where the samples within the training library are split into cross-validation groups and then samples within those groups are chosen in an alternating fashion, removed from the calibration group and tested against it to perform the cross-validation. In the particular case of the LOO validation, the number of cross-validation groups equals the number of samples, thus, only one sample is included in the validation group at a time [31]. When the cross-validation is run, the software provided an automatic measurement of these models' performance through their F1 score, a harmonic mean of the precision and recall of a binary classification system, i.e., a classification of positive and negative samples [32]. Here 'precision' is defined as the number of identified true positives among all the samples classified by the studied method as 'positives', and recall is the number of positive samples correctly identified as positive by the studied method within the total population of positive samples [33]. In other words, the closer the F1 score of a model is to 1, the more accurate a classification model is. This is further outlined in the equation below:  
\[\text{F}_{1}=\frac{2}{\text{recall}^{-1}+\text{precision}^{-1}}=2.\frac{\text {precision}\cdot\text{recall}}{\text{precision}+\text{recall}}=\frac{\text{TP} }{\text{TP}+\frac{1}{2}(\text{FP}+\text{TP})}\]  
where 'TP' is the number of true positives and 'FP' is the number of false positives.  
Once the models were created, their F1 score and predicted classification values were used to select the most suitable model(s) to be evaluated during the testing stage of the study.  
Figure 2: Graphical summary of the sample preparation and analysis during the data collection stage. Aliquots of 100 mL of each corrosive substance were poured into plastic bottles of PET and HDPE. Five aliquots of each combination of corrosive substance and plastic material were prepared and scanned 10 times each using NIR spectroscopy. Created with BioRender.com.