# Automatic Detection of Marine Litter: A General Framework to Leverage Synthetic Data
## 2 Materials and Methods
### Case Study on Sentinel-2
#### 2.2.6 Training of a Classifier on Synthetic Data  
For the sake of simplicity, only a Random Forest classifier [40] was chosen to test automated plastic detection. When large datasets are available, a Random Forest is a good choice given its accuracy and intelligibility. This classifier is trained on individual pixels from the generated images. This ensures that all pixels from a patch can be classified, without regard for the shape or the size of the patch. This also allows the classifier to correctly classify patches that are made out of multiple materials. We split the dataset into training, validation and testing sets with ratios 0.8, 0.1, and 0.1, respectively. We used the Random Forest classifier from the scikit learn package version 0.24.2 [41]. Various parameters have been tested by generating new datasets. On the S2 case, the Random Forest with default parameters prove to have satisfying results. On the synthetic data, the key performance metrics of the classifier are very high: superior or equal to 0.99 for the f1-score, precision, and recall. The classifier was able to successfully classify seawater, plastic, or wood pixels. These high results are mostly due to the fact that the \begin{table}
\begin{tabular}{c c c} \hline \hline
**GSD** & **Bhape** & **Rectangle** & **Circle** \\ \hline
**GSD = 10 m** & \(25\,\mathrm{m}\times 25\,\mathrm{m}\) & R = 15 m \\ (B2, B3, B4, B8) & & \\ \hline
**GSD = 20 m** & \(40\,\mathrm{m}\times 40\,\mathrm{m}\) & R = 25 m \\ (B5, B6, B7, B8a, B11, B12) & & \\ \hline
**GSD = 60 m** & \(120\,\mathrm{m}\times 120\,\mathrm{m}\) & R = 70 m \\ (B1, B9, B10) & & \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Table of the minimum sizes recommended to ensure S2 data reliability, i.e., to avoid aliasing. simulated materials are easily separable. The classifier performs well on a pixel by pixel case, but it is also worth investigating its performances on an image by image case. By this, we mean performing the assessment of the same classifier on the entirety of an image, not training a separate one that takes a whole image as input. We expect it to be sensitive to the size of the patch due to aliasing: the smaller it is, the harder it will be to detect, thus inducing lower f1-score, precision, and recall. To test this, we generated a set of 45 scenes with patches of circular shape, with radius ranging between 1 m and 100 m. The material type for all images was set to wet bottles frame. To observe the impact on detection of the artifacts induced by the sampling process, we randomly picked 10 jitters for each image. Figure 9 shows three particular cases of inaccurate prediction. At the top, the masks of simulated images are displayed and at the bottom, the results of the prediction by the Random Forest classifier. For all for three images, we chose a particular jitter to plot the images. The results do not drastically change between jitters. On these images, we can see the aliasing effect particularly well on the third one (R = 50 m). Some of the pixels at the border are expected to be plastic but because of the sampling and the jitter, the left bottom border have water values instead. In all images, we can see that some of the surrounding water pixels are mis-classified as plastic (one or two false positives for each image). However, at the scale of the patch, the predictions are satisfactory. Afterwards, for each image and each jitter, we compared the number of plastic pixels on the simulated image and the number of plastic pixels predicted. Figure 10 shows the ratio of the predicted number by the simulated number depending on the radius of the patch and per jitter. We can see that for small radii (under 15 m), the ratio can reach 2, meaning that there were 2 times more plastic predicted that there actually was. Between 15 m and 30 m, the ratio stabilizes to 1: for bigger patches, the classifier is able to predict the correct number of plastic pixels.