BackgroundVolatile organic compounds (VOCs) in grain fluctuate depending on the degree of grain freshness. A new colorimetric sensor array (CSA) was developed as capture probes for the quantification of VOCs in grains in this work, and it was designed to monitor the variation of grain VOCs. CSA spectral data acquisition using visible–near‐infrared spectroscopy and image processing of CSA's image imformation by computer were used comparatively. Then, machine‐learning‐based models – for example, synergistic interval partial least squares, genetic algorithm, competitive adaptive reweighted sampling (CARS) algorithm, and ant colony optimization (ACO) algorithm – were introduced to optimize variables. Moreover, principal component analysis, and linear discriminant analysis (LDA), and K‐nearest neighbors (KNN) were used for the classification. Ultimately, quantitative models for detecting grain freshness are developed using various variable selection strategies.ResultsCompared with the pattern recognition results of image processing, visible–near‐infrared spectroscopy could better separate the grains with different freshness from principal component analysis, and the prediction set of LDA models could correctly identify 100% of rice, 96.88% of paddy, and 97.9% of soybeans. In addition, compared with CARS and ACO, the LDA model and KNN model based on genetic algorithms show the best prediction performance. The prediction set could correctly identify 100% of rice and paddy samples and 95.83% of soybean samples.ConclusionThe method developed could be used for non‐destructive detection of grain freshness. © 2023 Society of Chemical Industry.