Spectroscopic-Based Prediction of Milk Foam Properties for Barista Applications

The important quality parameters of cow’s milk for barista applications are frothability and foam stability. In the past, quality assessment was very time-consuming and could only be carried out after milk treatment had been completed. Since spectroscopy is already established in dairies, it could be advantageous to develop a spectrometer-based measurement method for quality control for barista applications. By integrating online spectroscopy to the processing of UHT (ultra-high temperature processing) milk before filling, it can be checked whether the currently processed product is suitable for barista applications. To test this hypothesis, a feasibility study was conducted. For this purpose, seasonal UHT whole milk samples were measured every 2 months over a period of more than 1 year, resulting in a total of 269 milk samples that were foamed. Samples were frothed using a self-designed laboratory frother. Frothability at the beginning and foam loss after 15 min describe the frothing characteristics of the milk and are predicted from the spectra. Near-infrared, Raman, and fluorescence spectra were recorded from each milk sample. These spectra were preprocessed using 15 different mathematical methods. For each spectrometer, 85% of the resulting spectral dataset was analyzed using partial least squares (PLS) regression and nine different variable selection (VS) algorithms. Using the remaining 15% of the spectral dataset, a prediction error was determined for each model and used to compare the models. Using spectroscopy and PLS modeling, the best results show a prediction error for milk frothability of 3% and foam stability of 2%.


Introduction
Cows' milk is a highly valued primary product in the food industry. It is an important protein source and therefore a staple food. Milk is used to produce a large number of secondary products such as cheese, yogurt, and cream. Various requirements are applied on shelf stable milk. A long shelf life, good taste, and no change in taste over the storage period and good frothability and foam stability, these are desired quality parameters (Goh et al., 2009).
There are different methods of frothing milk, either steam injection, air bubbling, or mechanical agitation (Goh et al., 2009). In all methods, air or gas is introduced into the milk, which then creates foam. Proteins in the milk stabilize the air in the milk by placing the hydrophobic parts of the proteins at the boundary interface between the air and the milk, with the hydrophilic part facing the milk (Borcherding et al., 2008;Dombrowski et al., 2016). Other substances in the milk influence the milk foam, too. Short-chain free fatty acids can stabilize the foam, because they act as surfactants, while long-chain free fatty acids or phospholipids destabilize the foam. Large particles have a negative influence on the milk foam (Pilhofer et al., 1994).
Milk fat from UHT (ultra-high temperature processing) milk does not necessarily contribute to the frothability of milk. Milk fat is typically a triglyceride consisting of a glycerol and up to three fatty acid residues. Mechanical stressing of the raw milk and enzymatic cleavage produces mono-and diglycerides on the one hand and free fatty acids on the other hand. Short-chain fatty acids have a positive influence on the foaming result, while long-chain fatty acids have a negative influence (Huppertz, 2010). Hu et al (2010) evaluated the fatty acid profile of Wagyu Beef using ATR-FTIR-spectroscopy.
There is a large amount of literature that elucidates the properties of milk during foaming. These include the mechanical influences during foaming, as well as temperature and milk type, the functions of the milk constituents of the UHT milk, or the manufacturing process of the milk (Oetjen et al., 2014;Rouimi et al., 2005;Huppertz, 2010;Kamath et al., 2008). Up to now, the foaming qualities can only be determined by time-consuming foaming of the milk and observing the foam decay (Marinova et al., 2009). No other measurement method is currently available. To these days, not all details are known about the foam stability of cows' milk. On the one hand, there are industrial process parameters and storage conditions that have an influence on cows' milk. On the other hand, the influence of other milk components or enzyme activities on the frothability is described. Likewise, the influence of the storage of UHT milk on the frothability of the milk has not yet been adequately evaluated.
Spectroscopy shows a lot of applications, not only in chemical analysis, but for the study and quality monitoring of food systems (Zettel et al., 2016). One advantage of spectroscopic measurements is that they are fast, effective, and non-destructive. Spectrometers can be integrated into the food production processes via probes to monitor the quality of the product in real time. Especially in dairy and milk processing plants, spectroscopy is used (Aït-Kaddour et al., 2021). Many milk ingredients contribute to the stability of milk foam, and ingredients are also known to have a destabilizing character. Since different milk components can be detected by different spectroscopic measurement techniques, it will be investigated which spectrometer is best suited for this type of prediction.
Near-infrared spectrometer (NIR) can be used for on-line process monitoring. It has been shown that abnormalities in milk production can be detected in real time (Vasafi et al., 2021). Infrared spectroscopy (IR) has already established itself in dairy. In addition to protein, lactose, and fat, urea can be determined via total reflectance Fourier transform IR (Jha et al., 2015). IR can be used to measure polar substances, while Raman spectroscopy can be applied to measure non-polar substances. Due to the measurement principal of Raman spectroscopy, the fundamental vibrations of molecules can be analyzed. In the literature, there are just a few examples where Raman spectroscopy is performed with milk (Mendes et al., 2016). It has been shown that milk powder adulteration can be detected via Raman spectroscopy (Cheng et al., 2010;McGoverin et al., 2010). Between buffalo milk for male and female infants, significant variation in the Raman spectra corresponding to concentration of milk fats has been observed; PCA is able to clearly separate these two classes of milk on the basis of features obtained from the Raman spectra (Ullah et al., 2017b). To detect derivation in milk, production can also be identified with Raman spectroscopy and suitable chemometrics (Vasafi et al., 2022). Fluorescence spectroscopy measurements were used to identify cows' milk in buffalo milk in order to detect counterfeits at an early stage (Ullah et al., 2017a). Initial quality control of infant milk is performed with front-face fluorescence as a process control tool (Henihan et al., 2018).
As the foam quality of cow's milk used in barista applications gains more importance, this becomes a quality characteristic in the future. Therefore, a measurement technique is required, which can detect and evaluate foam qualities of cow's milk reliably. Here, spectroscopy is a good choice, because it can be integrated into a milk production process easily and can determine in real time its quality. Since there are currently no guidelines or references for good milk foam in Germany, in which good and bad milk foam can be distinguished, the prediction of frothability and frothiness from spectra by regression is used in this study. Likewise, two different foam qualities will also be used. A good milk foam should not only have a high foam volume (at the beginning of a foaming), but the foam should loose very little foam volume after 15 min, so that the foam stability is important as well.
In here, the spectroscopic analysis of predicting the foam quality of cow milk is presented. Raman, NIR, and fluorescence spectrometer are applied to predict the foam quality parameters of commercial available milk. Seasonal UHT whole milk samples were measured every 2 months over a period of more than 1 year in two campaigns, resulting in a total of 269 milk samples that were analyzed spectroscopically and afterwards foamed, to measure the foam volume and foam stability. Full-spectra PLS models will be investigated as well as different variable selection (VS) methods to be able to predict the foam parameters out of the spectra.

Samples
For the months of February, April, June, August, October, and December of 2020, various cow's milk samples were purchased from retailers. These included full-fat, lactosefree, and ESL (extended shelf life) milk samples, all of which came from German dairies. In a 2nd campaign in February and April of 2021, additional samples were collected from each retailer. These milks were purchased from supermarkets themselves and stored unrefrigerated after purchase. One day before measurement and foaming, the sample packs were tempered to 5 °C. Foaming and measurement of the samples were performed on the same day. If the sample was opened, it was also stored at 5 °C. A maximum of 3 days elapsed between acquisition of the sample and measurement. Table 1 shows the frothability and foam stability by month and year as well as the sample counts.

Milk Foaming Equipment to Determine Reference Values
In order to be able to characterize the milk foam, two parameters are determined. First, the frothability of the milk is examined. For this purpose, the foam volume of the samples is taken after 1 min of frothing and 1 min of foam equilibration. After 16 min, the foam volume is determined again. The difference between the foam volume at the beginning and after 16 min describes the foam stability. The extreme values are presented in milliliters in Table 1.
For foaming the milk samples, a laboratory frother was used, which is similar to a professional barista machine.
Here, parameters such as supply air and steam can be set and kept constant to ensure comparable foaming. First, 150 mL of the milk samples was tempered to 5 °C. These were then foamed in a 400-mL glass beaker for 18 s. Each sample was foamed 2 times, and the frothability and foam stability are averaged. From each purchased milk, two samples were taken, and the frothability and foam stability are averaged. The procedure is described in detail by Hummel et al. (2022).
The foam volume of the 1st campaign was determined manually by a metric scale in a beaker with a precision of ± 10 mL. To improve the precision of the 1st campaign, in the 2nd campaign, the foam volume is determined with two distance lasers, which continuously measured the distance between the foam surface and the laser source. With the help of a calibration, this distance can be converted into the sample foam volume. The precision of the foam volume determination by laser was ± 1 mL (Hummel et al., 2022).

Near-Infrared Spectrometry
For the near infrared measurements, the MPA II Multi-Purpose FT-NIR Analyzer (Bruker, Massachusetts-USA) was used. Sixty-four scans per measurement were performed and combined to a sum spectrum. The samples were measured five times in a 1-mm flow cell at 5 °C. The samples were pumped through the flow cell during the measurement to simulate process conditions. The spectrum of an empty cuvette filled with air was used to obtain the reference spectrum. These five individual spectra of the sample were then used as the averaged spectrum. An air spectrum was recorded as a reference spectrum.

Raman Spectrometry
For Raman spectra acquisition, the Raman-785 (Inno-Spec, Nürnberg-Germany) was used with a laser excitation wavelength of 785 nm and a laser power of 500 mW. The measurements were performed as reflectance measurements in a 1-cm quartz glass cuvette. Five manual scans per sample were recorded with an exposure time of 30 s and combined to an average spectrum. The measuring temperature was 5 °C.

Fluorescence Spectrometry
Fluorescence spectra were recorded with a FluoroMax (Horiba, Tokyo, Japan). The spectra were recorded with a reflection probe. This probe was connected to a small temperature-controlled chamber. The excitation wavelengths and emission wavelengths were adjusted between 250 and 550 nm (increment: 10 nm), as well as 270 and 570 nm respectively with a slit width corresponding to 3 nm. The sample temperature was 5 °C. Three individual spectra of the each sample were recorded, which were then averaged.

PLS Model Evaluation and Variable Selection
The following quantities were calculated for the assessment of the models. The RMSE (root mean square error) is calculated using Eq. (1). The RMSEC (C for calibration) calculates the calibration error where the foam qualities of the calibration set are used. For the validation, a cross validation was performed, according to the leave-on-out method. The RMSECV (CV for cross validation) is the error of the test set and therefore the prediction error. The percentage error is calculated using Eq.
(2) and is determined using the values of the test set.
The PLS models were calculated up to a maximum of 20 principal components (PCs) for each spectrometer. For each number of PC, the RMSEC, RMSECV, and percentage error were determined. The optimal number of PCs was determined by the minimum RMSECV.
PLS models of the spectra without any preprocessing were calculated. As an optimization step, 15 different preprocessing procedures for the spectra evaluation were carried out. These preprocessing techniques were: Savitzky-Golay filter (S.Golay) (as smoothing method and for the 1st and 2nd derivative), normalization of the spectra, baseline corrected spectra with the "baseline correction," "Rubberband" method, and polynomial corrected baselines (with 1-4 degrees), multi scatter correction, derivative according to the difference quotient method (1st and 2nd derivative), and an offset correction.
All preprocessing procedures of the spectra, methodization, and selection algorithms of the models were carried out in RStudio (version 4.0.1). The R packages "hyperSpec," "lattice," "grid," and "signal" were used for preprocessing. The package "pls" was utilized to calculate the model, and the packages "plsVarSel" and "MASS" were applied to select variables. Visualization of spectra was carried out by "Ggplot2." The operating system of the computer was a Windows 10 Home version (version: 20H2, 64-bit based processor).

Foam Qualities
The smallest volume and the largest volume of the foam qualities together with the month purchasing are shown in Table 1. A milk sample may have good frothability but poor foam stability. Similarly, there are milk samples that have poor frothability but good foam stability. Since such milk samples cannot be described sufficiently well with a single chemometric model, the frothability and foam stability of the milk are calculated using separate models. The 1st and 2nd campaigns are considered and compared separately, as these datasets differ from the reference measurement. The aim is to investigate whether a better reference measurement automatically leads to a better prediction.

Evaluation of PLS Models
The spectra with the presented 15 preprocessing steps and the 9 PLS models with VS methods resulted in a total of over 135 models per spectrometer. For better illustration, the PLS model without preprocessing and VS is shown. For comparability, the two best models from the combination of VS and preprocessing of the spectra are presented. The measurements and evaluation from the 1st and 2nd campaigns are carried out and discussed separately. It should be mentioned that for the model calculations of the 2nd campaign, a smaller number of samples are used compared to the 1st campaign. The results are summarized in Tables 2 and 3.

Campaign 1
The 1st campaign includes 225 spectra, which were measured in year 2020. Thus, 191 spectra were used for calibration and 34 spectra for validation. For each model, these spectra were randomly selected. These measurements have a precision of ± 10 mL. Figure 1 shows an unprocessed NIR spectrum of whole milk with labeled peaks. In the spectrum, the two water peaks are clearly visible. Further peaks, like protein and fat, can be found between 4000 and 5000 cm −1 . NIR spectroscopy has been used to measure proteins and fat content in milk (La Roza-Delgado et al., 2017;Núñez-Sánchez et al., 2016;Tao & Ngadi, 2017).

NIR Spectrometry
A PLS model with raw spectra and no VS gives a prediction of foaming from the 1st campaign with an RMSECV of 17 mL and a percentage error of 4% for a number of 7 PCs. If a derivative according to S.Golay is used, the error decreases to an RMSECV of 14 mL; however, the average error remains at 4%. A similar result is obtained by an evaluation with a polynomial baseline (3rd degree)-corrected spectrum. For the prediction of foam stability, the PLS model obtained with raw spectra gives an RMSECV of 16 mL and 25% percentage error. The RMSECV can be reduced by optimization to 11 mL.
Since milk consists of more than 80% water, it can be difficult to make a useful evaluation of the spectra. Water is polar and shows two broad bands in the NIR spectrum, which can cover other bands. Since the water content of the milk samples varies, no water spectrum can be subtracted from the recorded spectra. The two strong water peaks occupy most of the spectrum, which explains why the unprocessed NIR spectra have a high error and require a high number of PCs. However, this can be adjusted somewhat by appropriate selection of VS and preprocessing the spectra.
Nevertheless, further information can be obtained from the spectra. The NIR measurements not only showed high water bands, but were sensitive to particles Aernouts et al. (2011). These did not show up as peaks, but with a clear baseline shift of the spectrum (Wang et al., 2019). However, this could be exploited by determining the particle sizes of the fat globules in the UHT milk. The sizes of these fat globules are determined by the manufacturing process of the milk. Homogenization can have an impact on the shear ability, which is why these models demonstrated that prediction is possible (Dombrowski et al., 2016). Although protein and fat play an important role in foam stability and these peaks are visible in the NIR spectrum, these bands are not filtered out by the PLS models with VS. Rather, peaks are picked out by the VS that corresponded to the baseline shift. However, it is known that fat globules have an effect on the spectrum, but it is not known what effect the fat globules have on foam stability. Table 2 Overview of the best PLS models of the foam qualities of the 1st campaign, sorted by spectrometers, reference, preprocessing methods, and variable selection algorithms of the PLS models. For these model combinations, the optimal number of components of the PLS models, the RMSECV, and the relative prediction error are given

Raman Spectrometry
A raw Raman spectrum can be seen in Fig. 2 with labeled peaks. As one can see, information about protein, fat, and lactose is hidden in the spectrum due to the vibrations of the corresponding group. For the main ingredients of milk, they can be predicted using Raman spectroscopy (El-Abassy et al. 2011: Mazurek et al. 2015Mendes et al., 2016). A PLS model for frothability with Raman spectra using 8 PCs showed an RMSECV of 16 mL and a percentage error of 4%. The Multi Scatter Correction of S.Golay transformed spectra was found to be suitable as preprocessing procedures. Using the URC algorithm to optimize the PLS model, the RMSECV could be reduced to 13 mL. An offset correction and a URC algorithm give an improved result of 12 mL.
The PLS models for foam stability of the Raman spectra showed a RMSEC of 12 mL and a percentage error of 16%. With the Rubberband methods sMC as a variable selection algorithm, the RMSECV could be obtained with 14 mL.
Raman spectroscopy is nevertheless well suited for milk measurements, because there are no water peaks in the spectrum (Reiner et al., 2020). Using Raman spectroscopy, the so-called fingerprint range can be analyzed. When Figs. 1 and 2 are compared, more peaks can be directly detected in the Raman raw spectrum. When VS is carried out, mainly intensity values of the peaks were selected. A prediction with unprocessed spectra can be improved by 4 mL with suitable VS and preprocessing and, with an RMSECV of 12 mL, is close to the accuracy of the reference measurement. Therefore, a well-chosen preprocessing of the spectra can significantly improve the prediction quality. The VS selected also some intensity values that are not based on peaks but wavenumbers where the baseline shift is the dominated factor. In a milk Raman spectrum, not only information about its composition but also about processing information. For example, it was demonstrated by Raman spectroscopy that analyzing the spectra buffalo milk for male and female infants can be distinguished (Ullah et al., 2017b). Table 3 Overview of the best PLS models of the foam qualities of the 2nd campaign, sorted by spectrometers, reference, preprocessing methods, and variable selection algorithms of the PLS models. For these model combinations, the optimal number of components of the PLS models, the RMSECV, and the relative prediction error are given

Fluorescence Spectrometry
The fluorescence spectra of milk with labeled peaks can be seen in Fig. 3. One dominant peak as protein peak, and two small peaks for the identification of the vitamins B2 and B6 (Faassen & Hitzmann, 2015) can be identified. Both vitamins do not participate in foam stabilization. This could be the reason why the PLS models with the fluorescence spectra, unprocessed with 8 PCs, showed an RMSECV of 19 mL and a percentage error of 5%. The VS algorithms did not improve the predictions, but significantly reduced the number of PCs in the prediction. With the full-spectrum PLS models for foam stability, an error of prediction of 15 mL and a percentage error of 21% are obtained. No improvement is possible by different preprocessing or VS.
The fluorescence spectrometer is much more sensitive compared to the NIR and Raman spectrometers, if the individual detection limits are compared with each other. However, this could not be shown in this work. The fluorophore intensities obtained from milk seems not to be influenced by the frothing properties of cow milk. This is shown by the high RMSECV of the PLS models. An optimization of the PLS models was not successful.
Protein is the main substance that makes milk foam. But it is not enough to use only the protein concentration to examine the foam qualities (Borcherding et al., 2008). Fluorescence spectroscopy measurements were used to identify cows' milk in buffalo milk in order to detect counterfeits at an early stage (Ullah et al., 2017a). Furthermore, initial quality control of infant milk has been performed with front-face fluorescence as a process control tool (Henihan et al., 2018).

Campaign 2
The 2nd campaign includes 44 spectra measured in 2021. Thus, 38 spectra were used for calibration and 6 spectra for validation. It should be noted that these results are not comparable to those of the 1st campaign. The smaller dataset is used to test if the PLS predictions improve, if the precision of the reference measurement is higher, even if the collection procedure of spectra remains the same. The reference measurements of the second campaign have a precision of ± 1 mL.
Using NIR raw spectra without optimizations and preprocessing, a percentage error of 2% and a RMSECV of 7 mL is obtained. In a prediction with baseline corrected spectra and a VS with mRMR, the number of PCs decreases to 2, but the percentage error increases to 3% and the RMSECV to 10 mL. The best result is obtained by the PLS prediction with the rubberband-corrected spectra of the 2nd campaign with a percentage error of 1% and a RMSECV of 2 mL. In the 2nd campaign for frothability, the percentage error can be reduced to 3% and the RMSECV to 2 mL. In general, the predictions for foam stability using NIR-spectra are not very good; both errors are very high. The NIR spectrum of milk is significantly affected by two water peaks; this could not be remedied even by suitable preprocessing and wavenumber selection.
The best results obtained by the evaluation of the raw Raman spectra using 6 PCs are a RMSECV of 8 mL. When a suitable preprocessing (here baseline corrected with 2nd polynomial) was carried out and the VIP as VS algorithm for the PLS models, the RMSECV of 6 mL is obtained. The predictions from the 2nd campaign for frothability are as follows: With suitable preprocessing, the results are for RMSECV 6 mL and percentage error 9%.
Using the raw fluorescence spectra, a RMSECV of 4 mL and a percentage error of 2% for frothability are obtained. This error can be improved due to preprocessing to a RMSECV of 2 mL and a percentage error of 1%. The foam stability can be predicted by the PLS model without any preprocessing with a RMSECV of 12 mL and a percentage error of 18%, but applying a suitable VS and preprocessing, the error can be reduced to a RMSECV of 2 mL and a relative error of 3%.

Comparison of evaluation procedures
If predictions in the 1st campaign are performed only with a PLS model, a prediction below 20 mL can be achieved without preprocessing of the spectra, with a percentage error of 25%. A preprocessing of the spectra and a suitable VS show that in almost all predictions, a better result is obtained or the number of PCs used decreases. There is only one exception where the prediction cannot be improved by suitable preprocessing and VS, predictions of frothability using Raman spectra.
Comparing the results of all predictions with those of the 1st campaign, foam stability in milk is best predicted by the Raman spectrometer. With 12 mL of RMSECV, this prediction is close to the accuracy of the reference measurement. With the NIR spectrum, a prediction of 14 mL can be achieved, which is not lower than the results obtained with Raman spectra. However, the spectra evaluation of the fluorescence spectrometer presented the worse results.
Comparing the instruments technically, different spectrometers show advantages as well as disadvantages, which should be considered when discussing the suitability for a process control tool. The NIR spectra show high water peak. This can be disturbing, especially when other milk products are measured, which have even higher water content than whole milk (e.g., skim milk). The Raman spectrometer uses a laser for the measurement, which can be dangerous if safety precautions are not taken. The results of the 2nd campaign show better prediction results, which can be attributed to the accuracy of the reference measurement. However, these PLS models would have to be improved with further measurements.

Conclusion
At the outset, a hypothesis was formulated whether the frothability and foam stability of cow's milk can be predicted using spectroscopy and PLS models without knowing more information about this product. The frothability of milk can be predicted in the 1st campaign with an RMSECV of 12 mL using Raman spectroscopy. In this campaign, the reference data were recorded with a precision of 10 mL. If the reference method with a precision of 1 mL (2nd campaign) was improved, the prediction also improves significantly. With this technique, frothability can be predicted to 2 mL RMSECV using NIR or fluorescence spectrometer.
In contrast, the prediction of foam stability does not work via NIR, Raman, or fluorescence spectrometers without optimization or preprocessing of the spectra. Here, the models could not perform below a percentage error of 15%. The fluorescence model of the 2nd campaign preprocessing and optimization can reach a percentage error of 3%. With a baseline correction of the spectra and a VIP optimization, the percentage error can be optimized to 3%.
For good milk foam, it is not only the type of milk and the method of foaming that are decisive, but also the milk ingredients. The storage time and duration also have an influence on the structure of the milk, which are reflected in the foam qualities. If milk is foamed under the same conditions, foam qualities can be traced back to the milk constituents and their present structures. These ingredients are sometimes very time-consuming to determine, which is why a spectroscopic determination for the foam qualities of the milk is useful. In the results shown above, it can be demonstrated on a laboratory scale that these foam qualities can be detected by a spectrometer. As a next step, these models could be integrated into the dairies by means of online spectroscopy in order to determine these quality parameters in real time.
Funding Open Access funding enabled and organized by Projekt DEAL. The IGF Project (AiF 20200 N) of the Research Association of the German Food Industry (FEI) was supported via AiF within the program for promoting the Industrial Collective Research (IGF) of the German Ministry of Economics and Energy (BMWi), based on a resolution of the German Parliament.

Data Availability
The data supporting the findings of this study are available from the corresponding author upon reasonable request.

Conflict of Interest
The authors declare no competing interests.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http:// creat iveco mmons. org/ licen ses/ by/4. 0/.