# Portable Protein and Fat Detector in Milk Based on Multi-Spectral Sensor and Machine Learning
## 1 Introduction  
Milk is an important dairy product that is widely used in the food and nutrition industry, and accurately determining its contents is important in ensuring food quality and safety. Protein and fat are important components of milk, and protein plays a crucial role in the growth and development of the human body as well as the immune system [1; 2]. Fat is a high-energy nutrient [3]. Therefore, in the process of milk procurement and production management, it is necessary to detect the contents of the main components of milk accurately and quickly, as this can not only provide a reference basis for milk quality analysis and production process quality control, but also provide scientific guidance for the excellent rearing of cows [4]. At present, classic detection methods are usually based on chemical analysis with typical standard detection methods such as the Kjeldahl nitrogen determination and Gable methods. The Kjeldahl method [5] calculates protein content by measuring the total nitrogen content in milk, whereas the Gable method [6] separates fat by adding sulfuric acid to calculate fat content. By contrast, traditional chemical analysis methods require longer detection time and complex chemical reactions, consume a large amount of reagents, and can also damage milk samples. This not only causes chemical pollution to the environment but also cannot meet the needs of online rapid measurement. Instrument analysis technologies, such as spectral technology, are widely used in milk composition analysis [7]. Optical testing methods are commonly used in non-destructive testing, mainly using infrared light, ultraviolet light, and fluorescence. Middle infrared (MIR) spectroscopy and near-infrared (NIR) spectroscopy are used extensively in the analysis of milk components [8; 9]. [PERSON] et al. [10] used the MIR method to measure the fatty acid content in milk. [PERSON] et al. [11] employed MIR data from milk to predict the protein and fat content inmilk using Bayesian regression. [PERSON] et al. [12] applied broadband laser mid-infrared spectroscopy with quantum cascade detectors for milk protein analysis. These studies provide strong support for the application of MIR in the field of milk analysis. Although MIR technology has significant advantages in providing more chemical information and high resolution [13], it requires relatively complex instruments and operations and requires high transparency of samples, which may have certain limitations in practical applications. By contrast, near-infrared (NIR) spectroscopy technology is more suitable for the milk and dairy industry [14; 15]. NIR has the characteristics of fast analysis speed and easy online real-time monitoring [16], meeting the needs of on-site measurement [17]. It is efficient, fast, and non-destructive [18], thus having great potential in the development of spectroscopic instruments [19]. [PERSON] et al. [20] predicted the composition of milk fatty acids using NIR technology. [PERSON] et al. [21] designed and established an online milk composition analysis system using NIR technology, with determination coefficients \(R^{2}\) of 0.947 and 0.989 for protein and fat prediction models, respectively. [PERSON] et al. [22] developed a system for the quality and safety assessment of heterogeneous raw milk using NIR technology. [PERSON] et al. [9] employed NIR spectroscopy technology to analyze the protein and fat content in milk, with a wavelength range of 600-1050 nm and standard error values for fat and protein prediction of 0.25% and 0.15%, respectively. These results demonstrate the excellent performance of the NIR method in milk quality assessment. Most NIR spectrometers are expensive and not suitable for a wide range of daily applications. In recent years, significant progress has been made in spectroscopic instruments, achieving low-cost miniaturized infrared instruments [21]. [PERSON] et al. [23] used a portable fluorescence detector to determine the protein content in milk. [PERSON] et al.