STANet: Spatiotemporal Attention Network for Aflatoxin M1 Prediction in Raw Milk
摘要
To address the challenges of aflatoxin M1 (AFM1) detection in the dairy industry, this study proposes a neural network model named STANet, based on a spatiotemporal attention mechanism, for probabilistic prediction of exceeding AFM1 in raw milk. This study utilizes nearly 1 million raw milk spatiotemporal monitoring data from December 2022 to October 2024 of a Chinese dairy company, generates high-quality synthetic data to alleviate the sample imbalance problem by the TABSYN method, and effectively integrates the spatiotemporal information with the basic features by using the dynamic weight fusion mechanism and attention pooling process. The experimental results show that STANet significantly outperforms other models in terms of accuracy (0.835), especially in the identification of sparse positive samples, with F1 scores of 0.842 and 0.828 for category 0 and category 1, respectively. The ablation experiments further validate the spatiotemporal features and dynamic weighting mechanism to enhance the performance of the model. Feature importance analysis reveals the significant contribution of features to the prediction. This study provides a data-driven framework to support the early probabilistic detection and monitoring of AFM1 exceedance, which has the potential to reduce screening costs in large-scale raw milk quality control. Future improvements may be achieved by incorporating biochemical validation experiments and refining data pre-processing strategies.