Sensitively detecting hazardous and suspected bioaerosols is crucial for safeguarding public health. The potential impact of pollen on identifying bacterial species through fluorescence spectra should not be overlooked. Before the analysis, the spectrum underwent preprocessing steps, including normalization, multivariate scattering correction, and Savitzky–Golay smoothing. Additionally, the spectrum was transformed using difference, standard normal variable, and fast Fourier transform techniques. A random forest algorithm was employed for the classification and identification of 31 different types of samples. The fast Fourier transform improved the classification accuracy of the sample excitation–emission matrix fluorescence spectrum data by 9.2%, resulting in an accuracy of 89.24%. The harmful substances, including Staphylococcus aureus, ricin, beta-bungarotoxin, and Staphylococcal enterotoxin B, were clearly distinguished. The spectral data transformation and classification algorithm effectively eliminated the interference of pollen on other components. Furthermore, a classification and recognition model based on spectral feature transformation was established, demonstrating excellent application potential in detecting hazardous substances and protecting public health. This study provided a solid foundation for the application of rapid detection methods for harmful bioaerosols.