As a characteristic edible fungus with a high nutritional value and medicinal effect, the Bachu mushroom has a broad market. To distinguish among Bachu mushrooms with high value and other fungi effectively and accurately, as well as to explore a universal identification method, this study proposed a method to identify Bachu mushrooms by Fourier Transform Infrared Spectroscopy (FT-IR) combined with machine learning. In this experiment, two kinds of common edible mushrooms, Lentinus edodes and club fungi, were selected and classified with Bachu mushrooms. Due to the different distribution of nutrients in the caps and stalks, the caps and stalks were studied in this experiment. By comparing the average normalized infrared spectra of the caps and stalks of the three types of fungi, we found differences in their infrared spectra, indicating that the latter can be used to classify and identify the three types of fungi. We also used machine learning to process the spectral data. The overall steps of data processing are as follows: use partial least squares (PLS) to extract spectral features, select the appropriate characteristic number, use different classification algorithms for classification, and finally determine the best algorithm according to the classification results. Among them, the basis of selecting the characteristic number was the cumulative variance interpretation rate. To improve the reliability of the experimental results, this study also used the classification results to verify the feasibility. The classification algorithms used in this study were the support vector machine (SVM), backpropagation neural network (BPNN) and k-nearest neighbors (KNN) algorithm. The results showed that the three algorithms achieved good results in the multivariate classification of the caps and stalks data. Moreover, the cumulative variance explanation rate could be used to select the characteristic number. Finally, by comparing the classification results of the three algorithms, the classification effect of KNN was found to be the best. Additionally, the classification results were as follows: according to the caps data classification, the accuracy was 99.06%; according to the stalks data classification, the accuracy was 99.82%. This study showed that infrared spectroscopy combined with a machine learning algorithm has the potential to be applied to identify Bachu mushrooms and the cumulative variance