Analysis of milk composition is essential for quality assurance and compliance with regulations related to quality standards, yet current tools lack of rapid analysis capability especially for field application. This study investigated the potential use of portable near-infrared spectroscopy (NIRS) combined with chemometrics and machine learning to predict fat, protein and lactose content of fresh cow milk. Spectral data were collected from fresh cow milk samples using a portable device working in the short-wave NIR (740–1070 nm). Samples were obtained from five farms at two locations in the Bogor area during morning and evening milking times. As a reference to develop the predictive model, the fat, protein, and lactose contents were measured using Milkotester Master Eco, which is a standard widely accepted by farmers and the milk industry. Two predictive methods were applied: Partial Least Squares Regression (PLS-R) and machine learning algorithms (i.e. Artificial Neural Network (ANN) and Random Forest (RF)) with various data pre-treatments. The best PLS-R models achieved determination coefficient of prediction (R²p) values of 0.828 (fat), 0.397 (protein), and 0.384 (lactose). Machine learning models further improved R²p to 0.901, 0.562, and 0.444, respectively. These findings demonstrate that portable NIRS combined with machine learning enables fast and reliable milk composition analysis, particularly for fat content. However, the prediction performance for protein and lactose is still limited and needs to be further improved.
Copyrights © 2026