## 3 Materials and Methods
### Machine Learning Methodology  
Three different machine learning (ML) methods were used in the classification analysis to assess product quality: Neural Networks (NNs), Bagged Trees, and Support Vector Machines (SVMs). These methods were chosen because of their proven effectiveness in solving various classification problems, especially when dealing with complex data [37; 38]. The dataset used in this study consisted of 565 records, further emphasising the importance of carefully selecting the classification approach to ensure optimal performance and prediction precision. Neural networks (NNs) have demonstrated their suitability for analysing highly complex datasets due to their ability to model intricate, nonlinear relationships. With deep neural network architectures, it becomes possible to uncover hidden patterns and structures within the data, especially when the relationships between variables are complex and not easily captured by simpler models. However, one of the challenges of using NNs is the risk of overfitting, particularly with smaller datasets and to mitigate this, careful consideration must be given to the network architecture, including the number of layers, the neurones in each layer, and the choice of activation functions. Bagged Trees, an ensemble method based on the bootstrap aggregation (bagging) technique, was also used. This method involves building multiple decision trees on different subsets of data and aggregating their results to produce more stable and accurate predictions. By training each decision tree on randomly selected subsets of the data, bagged trees can capture different aspects of the dataset and reduce model variance. In classification tasks, the final decision is based on the majority vote of all trees. Bagged trees are particularly useful for data with high variability and complexity and are more resistant to overfitting than single decision trees. However, parameters such as the number of trees in the ensemble and the depth of each tree must be carefully tuned for optimal performance. Despite their advantages, bagged trees can be computationally intensive, especially for larger datasets [39]. Support Vector Machines (SVMs) are well known for their ability to effectively handle high-dimensional data and determine the optimal decision boundary between classes. By using kernel functions, SVMs can model complex, nonlinear relationships, which is critical when analysing data that are not linearly separable. However, while SVMs are a powerful tool for classification, selecting the correct kernel and tuning parameters, such as the kernel scale and box constraint, requires careful analysis and experimentation. Improper parameter selection can lead to suboptimal model performance. The decision boundary in a linear SVM is represented by the equation of a hyperplane:  
\[w\cdot x+b=0 \tag{3}\]  
where  
* \(w\) is the weight vector;
* \(x\) is the input characteristic vector;
* \(b\) is the bias term. SVM works by maximising the margin between the decision boundary and the nearest data points. The margin is given by:  
\[\text{Margin}=2/\|w\| \tag{4}\]  
Maximising this margin while minimising classification errors leads to the following optimisation problem: \( \begin{array}{l}\underset{w,b}{min}\ \frac{1}{2}\ \|\ w\ \|\ \text{subject to}\ y_{i}(w\cdot x_{i}+b)\geq 1\ \forall i.\end{array} \)  
Where  
* \(y_{i}\) is the label of the \(i\)-th training example (\(y_{i}=+1\) for one class, and \(y_{i}=-1\) for the other);
* \(x_{i}\) is the \(i\)-th training example. For cases where the data are not linearly separable, SVMs introduce slack variables \(\xi i\) that allow for some misclassification.