# Efficient Argan Tree Deforestation Detection Using Sentinel-2 Time Series and Machine Learning
## 2 Materials and Methods
### Aragan Tree Detection Method  
After processing the data, the goal was to detect organ trees in the study area for 2017/2018 and 2022/2023. The approach involved testing various scenarios to minimize mapping errors and improve accuracy. This phase relied on tabular data and included the following steps:  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Data** & **Data Split** & **Categories** & **Number of Samples** \\ \hline \multirow{4}{*}{Single-temporal data} & \multirow{2}{*}{Training Data Set (90\%)} & \multicolumn{1}{c}{Argan} & 626 \\ \cline{3-4}  & & Non-Argan & 626 \\ \cline{2-4}  & & Argan & 69 \\ \cline{2-4}  & & Non-Argan & 69 \\ \hline \multirow{4}{*}{Multi-temporal data} & \multirow{2}{*}{Training Data Set (80\%)} & \multicolumn{1}{c}{Argan} & 15,024 \\ \cline{3-4}  & & Non-Argan & 15,024 \\ \cline{2-4}  & & Argan & 1656 \\ \cline{1-1} \cline{2-4}  & & Non-Argan & 1656 \\ \hline \hline \end{tabular}
\end{table}
Table 7: Tabular Data Split.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Metric Name** & **Formula** \\ \hline Overall accuracy & \(\frac{TP+TN}{TP+TP+TN+FN}\) \\ Precision (Argan) & \(\frac{TP+FP}{TN}\) \\ Precision (Non-Argan) & \(\frac{TN+FN}{TP+TN}\) \\ Kappa & \(\frac{TP+P_{c}}{TP+TP+FN}\) \\ \hline \hline \end{tabular}
\end{table}
Table 8: Formulas of the metrics [108].  
Figure 6: The form of the confusion matrix.  
Model evaluation: machine learning models were tested using original spectral bands and derived spectral indices (single temporal data) to identify the best-performing model for organ tree detection.
2. S2 Product Levels: the suitability of Sentinel-2 Level 1C and Level 2A products for training was compared.
3. Optimal detection time: the best time of year for detecting organ trees was identified to ensure model accuracy for both periods.
4. Impact of spectral information elements: the effect of individual spectral bands and indices on detection accuracy was analyzed by training the best model on each element separately.
5. Optimal spectral information combination: the best combination of spectral bands and indices was determined, testing next scenarios: 1. 10-m resolution spectral bands. 2. 10- and 20-m resolution spectral bands. 3. All spectral bands. 4. The top 10 most influential spectral features. 5. All spectral bands and indices.
6. Optimal temporal information combination: the impact of temporal data combinations was assessed, including: 1. Single-date data for the detection day. 2. Single-date data from both periods. 3. Multi-temporal data from one year. 4. Multi-temporal data from both periods.
7. Final model training and mapping: The final model was used to classify pixels from the 2017/2018 and 2022/2023 images of the study area into two categories: Argan and Non-Argan. This process resulted in the generation of two organ distribution maps.  
After evaluating the tests, the best model was trained on the optimal data to ensure robustness. Two optimal Sentinel-2 images were then selected, one for 2017/2018 and another for 2022/2023. Each pixel in these images was classified as \"contains Argan\" or \"does not contain Argan\", resulting in two detailed maps of organ tree distribution for the study area in each period.