Soybean with insignificant differences in appearance have large differences in their internal physical and chemical components, therefore follow-up storage, transportation and processing require targeted differential treatment. A fast and effective machine learning method based on hyperspectral data of soybean for pattern recognition of categories is designed as a non-destructive testing method in this paper. A hyperspectral-image dataset with 2299 soybean seeds in 4 categories is collected; Ten features is selected by extreme gradient boosting algorithm from 203 hyperspectral bands in range 400 to 1000 nm; A Gaussian radial basis kernel function support vector machine with optimization by the Tree-structured Parzen Estimator algorithm is built as TPE-RBF-SVM model for pattern recognition of soybean categories. The metrics of TPE-RBF-SVM are significantly improved compared with other machine learning algorithms. The accuracy is 0.9165 in the independent test dataset which is 9.786% higher for vanilla RBF-SVM model and 10.02% higher than the extreme gradient boosting model.