ABSTRACT Accidental ingestion of psilocybin‐containing mushrooms can cause poisoning and hallucinations, making their rapid detection a public health priority. Conventional methods such as HPLC, GC–MS, LC–MS, TLC, CE, and ELISA provide sensitivity but are often destructive, time‐consuming, or impractical for real‐time applications. This study introduces a Raman spectroscopy–based approach for rapid, nondestructive identification of psilocybin. The molecular geometry of psilocybin was optimized using density functional theory (B3LYP/6‐31G(d,p)), and theoretical Raman spectra were generated to assign characteristic vibrational peaks, confirming its Raman activity. Experimental spectra of fresh and heat‐treated Psilocybe cubensis mushroom samples were collected, with peak alignment demonstrating good agreement with theoretical predictions, thus establishing psilocybin fingerprint features. For classification, raw and preprocessed spectra (MSC, SNV, 1st‐D, detrending) were evaluated. Among feature extraction methods (PCA, SPA, UVE, CARS), CARS yielded the most discriminative variables. An XGBoost model was developed and optimized via Bayesian tuning, while SMOTE addressed class imbalance. Furthermore, psilocybin fingerprint features were fused with CARS features to enhance interpretability and model robustness. Finally, a Bagging framework integrating XGBoost, KNN, SVM, and Decision Tree was implemented to improve generalization and noise resistance. The final Bagging‐based model achieved high performance (accuracy 0.984, F1‐score 0.984, ROC AUC 0.976), with strong stability under storage conditions. Overall, this study elucidates psilocybin's Raman spectral characteristics and establishes a machine learning–assisted detection model. The approach enables rapid, accurate, cost‐effective, and contamination‐free identification of psilocybin, with potential applications in food safety monitoring and on‐site toxic mushroom screening.
Sun et al. (Thu,) studied this question.