A rapid and nondestructive assessment of food safety risk using machine learning-assisted hyperspectral imaging was developed for classification of fungal contamination in brown rice grain. Brown rice was inoculated with Penicillium. The fungal infected rice was then mixed with healthy rice to obtain 0 %, 5 %, 25 %, 50 % and 100 % (w/w) contamination of infected rice. Volatile compounds including pentamethyl-heptane, decane, dodecane, 3-octanone, and 1-octen-3-ol were found in fungal infected rice, as analyzed using gas chromatography-mass spectrometry. The HSI system was used to collect spectral reflectance and spatial data of the samples covering the wavelength range of 400–1000 nm. The hypercubed data were analyzed using machine learning algorithms, including principal component analysis (PCA), discriminant factor analysis (DFA) and support vector machine (SVM). Using PCA for data reduction, 3 principal components were extracted with a cumulative variance of 90.53 %. DFA (linear and quadratic algorithms) and SVM (linear, quadratic, cubic, and Gaussian algorithms) were then used to classify the samples. HSI integrated with Gaussian SVM gave 93.4% accuracy which was best for classifying rice with different percentages of contamination. The image analysis gave a pseudo-color distribution map which facilitated the visualization of the contaminated rice by presenting data in an uncomplicated image. The machine learning-assisted HSI can be used as a rapid, nondestructive and chemical-free tool for an assessment of food safety risk for rice grain.