Spectral detection technology can be used to identify different types of fish flesh and determine the presence of ingredients in samples, which helps to control the authenticity and conformity of products. The aim of this study was to develop and compare the effectiveness of machine learning methods for the classification of different types of fish based on hyperspectral data. In this paper, hyperspectral technology was used to obtain spectral data of 328 sampling points in the 400-1,000 nm band of four different fish, and the spectral curves were preprocessed to obtain more accurate and efficient spectral curves. The study systematically compared the preprocessing methods of Savitzky-Golay smoothing and multivariate scatter correction (MSC), and combined the principal component analysis (PCA) method to optimise the k-nearest neighbour (KNN) and support vector machine (SVM) classification models, in order to provide a more effective solution for fish classification. The principal component analysis method was used to reduce the dimensionality of the spectral data. The principal components after dimensionality reduction were compared with the full components, and the training set and test set were randomly generated. The SVM algorithm and the KNN algorithm were used in Python to predict and determine the accuracy of the model. It was shown that the average accuracy of spectral data after preprocessing and dimensionality reduction in the classification of SVM models can reach 97.25%, and the average classification accuracy of KNN models can reach 97.48%, which indicates that different types of fish flesh can be classified. Both models showed that overall, the preprocessing method that combines MSC and PCA is better than the single preprocessing method, highlighting the importance of PCA in removing redundant information and preserving key classification characteristics. When comparing the model performance under the same preprocessing conditions, the accuracy of SVM is higher than that of KNN, indicating that the SVM has greater adaptability to spectral data classification. Through the development and application of spectral detection technology, technological progress and innovation in food testing can be promoted, guiding the entire industry to a safer and more reliable future
spectrum; Savitzky-Golay method; multiplicative scatter correction; k-nearest neighbours model; support vector machine algorithm