## 2 Materials and Methods
### Detecting River Pollution through Machine Learning
#### 2.4.4 Model Training  
A Python script controls the DJI Mavic drone to capture images while flying over designated waypoints, representing areas of interest such as oil spills, river debris, and wastewater. It uses the DJI Mobile SDK to manage the drone's flight and image capture. The images are associated with specific labels for oil spills, river debris, and wastewater. Relevant features are extracted from images using three different machine learning models: SVM, k-NN, and RF. These models are trained on the labeled images, and their accuracy in classifying the images is evaluated, providing insights into the performance of the models for this image classification task. The dataset is split into 70% training, 10% validation, and 20% testing sets. The code is modular, allowing for the customization of image preprocessing and the definition of categories for classification. The three machine learning models included parameter tuning. For the SVM model, hyperparameter tuning involved exploring options for the choice of kernel, penalty parameter C, and kernel coefficient gamma. This tuning process aimed to find the optimal combination of these parameters that maximizes the model's performance in classifying images. With regard to the kernel type, in case of the linear kernel, it assumes a linear decision boundary between classes. Another type, the polynomial kernel, introduces polynomial features and allows for non-linear decision boundaries. We explored degrees 2 and 3. The third option to be investigated was the radial basis function kernel that considers the similarity between data points in high-dimensional space. The penalty parameter C was varied. For C = 0.1, it allowed a softer margin, allowing some misclassifications. In case of C = 1, it balanced between maximizing the margin and minimizing misclassifications. For C = 10, a stricter penalty was imposed on misclassifications, leading to a narrower margin. The kernel coefficient gamma was varied, namely, 0.1, 1, 10, as these values determine the influence of a single training example, with higher values giving more weight to nearby points. The best option chosen based on the hyperparameter tuning process for the SVM model was the radial basis function as a kernel type because it provided the best performance in capturing the complex relationships present in the image data. The penalty parameter C was set to 1 to obtain a balance between maximizing the margin and minimizing misclassifications. The kernel coefficient gamma was set to 0.1, as it effectively captures the similarity between data points in high-dimensional space without overfitting. These options were determined to yield the highest accuracy and generalization performance. As such, they represent the optimal configuration for the SVM model in classifying images captured by the drone over the Shatt al-Arab River region. For the k-NN model, hyperparameter tuning involved selecting the optimal number of nearest neighbors (k) to optimize the model's performance in classifying images. This tuning process involved testing various values of k and selecting the one that yielded the best results on the validation set. The tested numbers of nearest neighbors were 3, 5, 7, and 10. For k = 3, the classification was based on the three nearest neighbors, which captured local patterns in the data effectively. In the case of k = 5, it allowed for a broader consideration of neighboring points, capturing more global patterns in the data. Another tested value was k = 7, which led to smoother decision boundaries and reduced the impact of noise in the data. The last tested value, k = 10, provided an even broader perspective by considering the classification based on ten nearest neighbors. Upon completion of the tuning process, the selected value of k = 5, determined to yield the best performance, represented the optimal configuration for the k-NN model in classifying the images captured by our system.