Rapid and accurate monitoring of talcum powder in wheat flour is of great practical importance for maintaining market order, public health and food safety. In this study, the potential of a home-made microwave detection system for rapid quantitative and qualitative detection of talcum powder adulteration in wheat flour at 2.5–11.5 GHz was investigated. Useful microwave spectral information is selected using three feature selection strategies, the bootstrapping soft shrinkage (BOSS), the multiple feature spaces ensemble with least absolute shrinkage and selection operator (MEF-LASSO), and the competitive adaptive reweighted sampling (CARS). The eXtreme Gradient Boosting (XGBoost) classification and regression models are constructed and evaluated, and three nature-inspired optimization algorithms (NIOA) are used for parameter optimization: the Osprey Optimization Algorithm (OOA), the Crested Porcupine Optimizer (CPO), and the Sparrow Search Algorithm (SSA). The experimental results show that both feature selection strategies and NIOA algorithms can effectively improve the model performance. The SSA-XGBoost classification model has the highest prediction accuracy, and its prediction accuracy and F1-score can reach 100 % and 1, respectively. The MEF-LASSO-SSA-XGBoost regression model has strong robustness. The root mean square error (RMSE) was 1.76 %, the prediction coefficient of determination (R2) was 0.98, and the ratio of performance to deviation (RPD) was 8.66. The results of this study showed that the combination of microwave technology and machine learning model with multivariate analysis method can realize the rapid and accurate determination of qualitative and quantitative talcum powder in wheat flour.