## 3 Results and Discussion
### Coffee Varieties  
Each variety was analyzed, using RF as the supervised machine learning approach, to demonstrate the presence of the fingerprint of coffee varieties both in green and in roasted coffee using all NMR data (mean predictive accuracy 91.7%, Table S1). This type of analysis conducted within the same farm, certainly highlights the strong differences between varieties. Then, the presence of the varietal fingerprint was investigated regardless of the farm of provenance, using bucketed spectra (Figure 2a,b). The predictive accuracies of green (Figure 2a) and roasted (Figure 2b) coffee beans models are similarly good (87.2% in green and 86.0% in roasted), confirming, as previously seen (Supplementary Materials Table S1), that even after roasting the varietal metabolomic fingerprint could be derived. Among all variety classes, TE and BR class error is the highest (Figure 2a,b). The RF variable importance is calculated for green and roasted coffee beans batches, and the overall importance is assessed by determining the maximum for each descriptor over all classes (Figure 2c,d). As shown in Figure 2c,d, there are some conserved regions (ppm), present both in green and roasted coffee spectra, that mostly contribute as important features ranked by RF: the region between 0.94 and 1.2 ppm could be mainly ascribed to the broad signals of methyl and methylene protons of fatty acids (FA) chains [9], the regions within 4.44 and 4.46 ppm, 8.08-8.12 ppm, 8.80-8.86 ppm and 9.12-9.14 ppm, attributable to trigonelline (TR) protons, and the bucket range from 2.52 ppm to 2.76 ppm corresponding to citric acid (CT) signals. Therefore, fatty acids, trigonelline and citric acid, can be considered descriptors of the varieties both in green and in roasted NMR spectra. It emerges that fatty acids and trigonelline maintain also the same trend between the considered varieties in green and in roasted coffee. In addition, with the aim to compare the efficacy of the fingerprinting and profiling approaches [8], RF was applied, even on the matrices of the corresponding peak areas of the identified metabolites in green and roasted spectra (Figure 3a-d). Compared to the RF models built on bucketed spectra (entire spectra, fingerprinting, Figure 2), models built on metabolites resulted to be less accurate (green model, Figure 3a, pred. acc: 79.4%; roasted model, Figure 3b, pred. acc: 69.7%). This suggests that the fingerprint approach is preferable for variety classification/recognition [8]. Figure 2: **Variety fingerprint assessment through RF. ** Confusion matrices of RF algorithm of green (**a**) and roasted (**b**) coffee bean spectra. A summary of the variable importance measures for the buckets of coffee NMR spectra with variety as the response variable in the RF model is reported: (**c**) for green coffee model (**a,d**) for roasted coffee model (**b**). Buckets are ranked according to the mean decrease in classification accuracy when they are permuted. Calculated RF class error and mean decrease accuracy units can be also read as percentage (e.g., class error of 0.05, means 5%). Most important buckets regions corresponding to assignable resonance present both in green and roasted coffee RF models (**c,d**) are labeled accordingly: fatty acid, FA; trigonelline, TR; citric acid, CT. Corresponding RF score plots are reported in Supplementary Materials Figure S3. Figure 3: **Variety profiling. ** Confusion matrices of RF algorithm of green (**a**) and roasted (**b**) metabolites of coffee beans. A summary of the variable importance measures for the identified metabolites with variety as the response variable in the RF model (**a**) of green coffee (**c**) and model (**b**) of roasted coffee (**d**). Metabolites are ranked according to the mean decrease in classification accuracy. At the bottom are reported the boxplots of the trigonelline levels in green (**e**) and roasted beans (**f**) among the seven different coffee varieties. The most important metabolites in discriminating varieties are ranked in Figure 3c,d.