Next Article in Journal
Crushing Mechanics and Flour Properties of Wheat Under Different Graded Crushing Durations in a Blade Crusher
Previous Article in Journal
Unveiling the Physical and Nutritional Profiling of Grains in Maize Landraces and Hybrids
Previous Article in Special Issue
Aflatoxin M1 in Milk from South–Central and Northwest China: Prevalence and Integrated Risk Characterization for Different Age-Sex Groups of Consumers
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Multi-Scale Spatial–Temporal Graph Model for Unsupervised Anomaly Detection in the Wheat Flour Transportation Process

1
College of Information Science and Engineering, Henan University of Technology, Zhengzhou 450001, China
2
Henan Zhongyu Port and Shipping Construction Engineering Co., Ltd., Zhengzhou 450001, China
*
Author to whom correspondence should be addressed.
Foods 2026, 15(16), 2934; https://doi.org/10.3390/foods15162934
Submission received: 3 July 2026 / Revised: 10 August 2026 / Accepted: 18 August 2026 / Published: 21 August 2026
(This article belongs to the Special Issue Assessment and Control of Food Safety Risks)

Abstract

Wheat flour transportation involves extended transit periods, which present considerable challenges for safety risk oversight. Therefore, it is essential to develop an efficient anomaly detection method to support risk assessment during this stage. However, existing anomaly detection methods often neglect the coupling effects across different time scales and the spatial clustering of hazard factors. To address this limitation, we propose a multi-scale spatial–temporal graph model-based unsupervised anomaly detection framework (MSTUAD), which can simultaneously capture the spatial–temporal correlations between importance and hazard factors across multiple time scales. Specifically, feature maps are first constructed for each hazard factor within a given time window to represent coupling effects. Secondly, a multi-scale spatial–temporal graph model is designed to extract spatial–temporal characteristics from these feature maps. Finally, a reconstruction model based on a variational autoencoder learns latent representations of spatial–temporal features of hazard factors, thereby capturing the intrinsic characteristics of normal wheat flour. Experimental validation on the wheat flour transportation hazard factor dataset and three public industrial datasets demonstrates that MSTUAD significantly outperforms state-of-the-art anomaly detection methods, achieving an average F1-score greater than 84.55%. This approach provides valuable decision support and technical guidance for relevant regulatory authorities.

1. Introduction

Food safety is a critical global issue that is closely linked to human health. As food supply chains become increasingly complex, international food safety incidents continue to occur [1,2,3]. For example, in April 2022, Salmonella contamination was detected in Kinder chocolate products during cross-border distribution in Belgium, prompting a large-scale recall and regulatory investigation across 11 countries with more than 150 cases of foodborne illness [4]. In the same year, inadequate oversight of berry transportation in several European countries resulted in contamination with norovirus and hepatitis A virus [5]. Meanwhile, with the advancement of industrialization and urbanization in China, heavy metals and cyanotoxins in irrigation water can enter the food chain through transport processes, posing significant risks to human health [6]. Furthermore, the recent “3.15” Gala in China revealed that several food companies were excessively adding phosphate water-retaining agents during seafood transportation to preserve product appearance and weight. Long-term consumption of such products may lead to calcium–phosphorus imbalance and cardiovascular disease. As a primary dietary staple, the wheat flour supply chain encompasses production, processing, storage, transportation, and consumption. The transportation stage is particularly vulnerable to factors such as fluctuations in temperature and humidity, as well as packaging damage. These conditions may induce starch denaturation, promote microbial proliferation, and accelerate lipid oxidation, thereby generating both chemical and biological hazards. These hazards may interact through synergistic or antagonistic mechanisms, creating coupled risks that present significant food safety concerns. Therefore, conducting a risk assessment of the wheat flour transportation stage holds substantial practical and applied value [7].
Currently, many scholars investigate interactions among hazard factors using decision-analysis methods, such as the analytic hierarchy process [8] and gray correlation analysis [9], in order to obtain more accurate food-safety risk assessment results. However, these methods rely heavily on expert subjective judgment, which may lead to limited stability and generalization performance when applied to diverse food detection data. In contrast, artificial neural networks update parameters through gradient-descent optimization without requiring expert knowledge and have been widely applied in food computing [10]. Therefore, researchers have integrated decision-analysis techniques with artificial neural networks to enhance the assessment of food safety risks [11,12]. However, actual food safety risks exhibit complex temporal dynamics characteristics influenced by factors such as climatic conditions and storage practices. The above methods generally ignore the temporal dimension of food hazard factors and cannot effectively learn long-term dependencies. As a result, there is a need to develop deep-learning models to identify complex dependencies among hazard factors. Long Short-Term Memory (LSTM) networks exhibit strong capabilities for modeling correlations within long-sequence data and have been widely applied in food-safety risk assessment [13].
Although LSTMs can effectively capture complex relationships among hazard factors when predicting food safety risks, they require preprocessing of hazard factor detection data to generate target outputs for supervised learning. In contrast, anomaly detection uses a data-driven approach to identify samples that differ significantly from the majority. It does not rely on pre-labeled data but instead detects risks by uncovering latent patterns and outliers within the dataset. Existing research has demonstrated the substantial applicability of anomaly detection in food safety monitoring [7,14]. However, current anomaly detection methods neglect the spatial correlations among hazard factors during food transportation. To overcome this limitation, researchers have proposed a new approach for modeling complex spatial relationships. This approach not only constructs graph structures based on node embedding similarity metrics but also employs graph neural networks to learn the spatial relationships among hazard factors and has achieved significant success in the field of food safety risk assessment [15].
However, existing anomaly detection methods focus only on the single-time or spatial structural characteristics of food hazards, neglecting the modeling of dynamic characteristics across different time scales, and are thus unable to effectively integrate short-term and long-term safety risks during transportation. To this end, we propose an unsupervised anomaly detection framework for wheat flour based on a multi-scale spatial–temporal graph model. Specifically, we first employ sliding window techniques to decompose hazard factor data during wheat flour transportation into multiple consecutive time windows, constructing feature maps for each window. Secondly, we design a multi-scale spatial–temporal graph model that integrates multi-scale convolutional attention with spatial–temporal feature extraction. Finally, we learn latent representations of spatial–temporal features in hazard factors through reconstruction learning based on a variational autoencoder to capture characteristics of normal wheat flour. Additionally, we employ end-to-end optimization of the proposed MSTUAD framework using a joint loss function. Its main contributions are as follows:
  • This paper designs a coupled graph structure learning approach that quantifies the interrelationships among hazard factors. This method effectively captures synergistic interactions and antagonistic effects among hazard factors in wheat flour.
  • This paper proposes a novel multi-scale spatial–temporal graph model that employs a multi-scale convolutional attention to learn correlations across multiple temporal scales. By incorporating a spatial–temporal feature extraction module, the model captures the spatial–temporal characteristics of wheat flour hazard factors.
  • This paper improves a reconstruction learning approach based on a variational autoencoder. It employs a Kolmogorov–Arnold network as both the inference and generative networks, thereby enabling more flexible modeling of the latent feature distribution of normal wheat flour through learnable activation functions.

2. Materials and Methods

2.1. Problem Statement

Given the wheat flour transportation hazard factor dataset X = x 1 , x 2 , , x n n × t as training input, the goal of unsupervised anomaly detection is to identify whether previously unseen observations x t ( t > n ) are anomalous. For anomaly detection in wheat flour transportation, historical values help characterize the current time point. Therefore, we first defined a time window w t = x t τ + 1 , , x t 1 , x t of length τ at time point t, transforming the wheat flour transportation hazard factor dataset into Y = w 1 , w 2 , , w n as the training input for the model. Secondly, we calculated the anomaly scores for time window w t ( t > n ) . Finally, the anomaly scores were compared against a threshold to determine the binary label y, where 1 denotes an anomaly, and 0 denotes a normal observation.

2.2. Data Sources and Construction

The experimental data used in this paper were sourced from routine sampling inspections conducted by the Chinese Administration for Market Regulation of China [16], comprising 4865 wheat flour transportation detection records collected from April 2010 to July 2023, with a sampling interval of one day. Since each detection record includes a detection date, we sorted the records chronologically and constructed a hazard factor time series for wheat flour transportation to characterize the dynamic evolution of the transportation process. Meanwhile, to consider both the potential increase in hazard levels caused by improper temperature and humidity control or inadequate packaging integrity and the risks of toxicity and carcinogenicity associated with bioaccumulation and biological activity, we selected heavy metals, mycotoxins, and other contaminants as indicators for evaluating wheat flour transportation risks. These hazard indicators primarily include mercury (Hg), arsenic (As), lead (Pb), cadmium (Cd), chromium (Cr), zearalenone (ZEN), deoxynivalenol (DON), ochratoxin A (OTA), aflatoxin B1 (AFB1), and benzo[a]pyrene (BaP). Furthermore, this paper established anomaly labels according to the maximum allowable limits specified in the food safety standard for maximum contaminant levels (GB 2762-2025) [17] and the food safety standard for maximum mycotoxin levels (GB 2761-2017) [18], which were used for model validation and performance evaluation. The corresponding national food safety standards for each hazard factor are summarized in Table 1.

2.3. Overview

In this section, we describe the proposed MSTUAD, which comprises four components: graph structure learning, multi-scale spatial–temporal graph model, reconstruction representation, and anomaly detection with threshold selection, as illustrated in Figure 1. Specifically, graph structure learning uses coupling coefficients to quantify interactions among hazard factors and to construct the adjacency matrix of the representation graph. The multi-scale spatial–temporal graph model applies multi-scale convolutional attention to fuse feature information across different temporal scales and extracts global spatial–temporal information through the spatial–temporal feature extraction module. The reconstruction representation adopts an encoder–decoder architecture based on KAN to reconstruct the spatial–temporal features of hazard factors. Anomaly detection and threshold selection identify abnormal states by computing anomaly scores and determining threshold values using a point-adjusted strategy.

2.4. Graph Structure Learning

During transportation, coupled interactions among multiple hazard factors exert significant influence on the overall safety status of wheat flour. But these coupled interactions exhibit nonlinear characteristics, which make them difficult to characterize effectively using traditional statistical methods. Therefore, to present these coupled interactions, this paper transforms the wheat flour hazard factor detection data within each time window into a graph G t = V , E consisting of nodes and edges, which is then used as input for a multi-scale spatial–temporal graph model. Here, node v i V represents hazard factors, and each hazard factor is connected by edges to its k most relevant hazard factors. Specifically, we first use the detection values of each hazard factor within the current time window as features, denoted as f t i = x t τ + 1 i , , x t 1 i , x t i . Secondly, to ensure balanced coverage of all coupling relationships, we quantify the coupling interactions (including synergistic and antagonistic effects) among the m hazard factors based on maximal information [19] and compute the coupling coefficient matrix C m × m :
C ( f t i , f t j ) = max a b < B p ( f t i , f t j ) log p ( f t i , f t j ) p ( f t i ) p ( f t j ) d f t i d f t j log 2 min ( a , b ) ,   i ,   j 1 ,   2 ,   ,   M
where a and b denote the number of grid points in the x and y directions after two-dimensional grid partitioning, respectively; B represents a constant, set to 0.6 in this paper; p ( f t i , f t j ) is the joint probability distribution function of f t i and f t j ; and p ( f t i ) and p ( f t j ) are the marginal probability distribution functions of f t i and f t j , respectively.
Finally, high coupling coefficients indicate the presence of coupling effects among hazard factors within the current time window. Thus, this paper employs the k-nearest neighbors (k-NN) approach to identify, for each hazard factor, the k hazard factors with the highest coupling coefficients, which together constitute its set of coupling effects. An adjacency matrix is subsequently constructed to implicitly represent the coupling effects among hazard factors:
A t ( f t i , f t j ) = 1 , j t o p k ( ρ ( f t i , f t k ) : k 1 ,   2 ,   ,   M ) 0 , o t h e r w i s e

2.5. Multi-Scale Spatial–Temporal Graph Model

Graph structure learning only captures positional information within the current time window wt, failing to integrate long-term and short-term dynamic trends across multiple windows. To address this limitation, we design a multi-scale spatial–temporal graph model (MSTGM). Specifically, a multi-scale convolutional attention (MSCA) [20] is employed to capture hazard factor features in wheat flour across multi-scale time windows. It consists of three components: deep convolutions that aggregate local information, multi-branch deep strip convolutions that capture multi-scale contextual information, and 1 × 1 convolutions that model relationships across channels, whose mathematical equation is given by
x ˜ t = x t C o n v 1 × 1 i = 0 3 S c a l e i ( D W C o n v ( x t ) )
where xt denotes the tth feature within the time window; represents element-wise matrix multiplication; DWConv indicates depthwise convolution; and S c a l e i , i { 0 , 1 , 2 } signifies the ith branch, whose structure is illustrated in Figure 2.
Meanwhile, to comprehensively consider the spatial–temporal characteristics of hazard factors during wheat flour transportation, this paper designs a spatial–temporal feature extraction module (STFEM) that integrates spatial graph convolution with sequence modeling. Specifically, graph convolution is applied to each graph Gt to aggregate hazard factor information from neighboring regions while maintaining weight-sharing properties, capturing potential coupling relationships among hazard factors:
G C N ( H t l ) = Λ ˜ 1 2 A ˜ t Λ ˜ 1 2 H t l W l
where Wl denotes the trainable parameter matrix of layer l, A ˜ t denotes the sum of the adjacency matrix and the identity matrix, Λ ˜ denotes the degree matrix corresponding to A ˜ t , and H t l n × d denotes the output of layer l for time window H t l n × d .
However, to obtain a larger receptive field, it is often necessary to stack multiple GCN layers, which may result in indistinguishable node features after convergence and vanishing gradients during backpropagation [21]. In practice, most state-of-the-art GCN models do not exceed four layers. Therefore, this paper proposes a residual graph convolutional network (RGCN), which employs skip connections with activation functions across three cascaded GCN layers, described as follows:
R G C N = G C N R e L U G C N R e L U G C N x ˜ t x ˜ t
where GCN(.) denotes graph convolution, ReLU(.) denotes the activation function, and denotes element-wise summation.
In addition, previous studies have demonstrated that LSTM can capture the temporal dependencies of hazard factors in wheat flour [22]. Therefore, to jointly capture spatial–temporal dependencies, the proposed RGCN is incorporated into the LSTM through matrix multiplication, enabling the extraction of broader spatial features. Specifically, each LSTM unit contains two internal states, ct and ht. The cell state ct is regulated by three gates: the forget gate ft, the input gate it, and the output gate ot. Since deep neural networks are prone to vanishing or exploding gradients during training, an exponential gating function is introduced as the activation function in both the input and forget gates. In addition, a normalized state is incorporated to stabilize gradient propagation, thereby reducing the risk of gradient vanishing or explosion and improving the stability of model training:
i t = ( R G C N e x p ) ( W f [ h t 1 ; x ˜ t ] + b f )
i t = ( R G C N e x p ) ( W i [ h t 1 ; x ˜ t ] + b i )
o t = ( R G C N σ ) ( W o [ h t 1 ; x ˜ t ] + b o )
c t = f t c t 1 + i t ( R G C N tanh ) ( W c [ h t 1 ; x ˜ t ] + b c )
n t = f t n t 1 + i t
h ˜ t = c t / n t
h t = o t h ˜ t
where [ ; ] denotes a series operation; ht−1 represents the previous hidden state; x ˜ t denotes the current input; σ denotes the sigmoid activation function; exp denotes the exponential gate activation function; and and denote functional composition and element-wise multiplication, respectively. Wf, Wi, Wo, Wc and bf, bi, bo, bc are learnable parameters; nt denotes the normalized state at the current time step; nt-1 denotes the normalized state at the previous time step; and h ˜ t denotes the normalized hidden state at the current time step.
During the computation of the input and forget gates, the exponential gating activation function may exhibit numerical overflow. To this end, a steady-state parameter, mt, is designed to regulate the numerical range of the exponential gating activation function, enhancing model stability and improving the accuracy of spatial–temporal feature extraction for hazard factors:
m t = max log f t + m t 1 , log ( i t )
i t = exp log i t m t
f t = exp log f t + m t 1 m t
where mt denotes the stable state at the current time step, mt−1 denotes the stable state at the previous time step, and it and ft denote the values of the output gate and forget gate, respectively. The overall architecture of the STFEM is illustrated in Figure 3. This approach not only handles extreme values more effectively, thereby reducing the impact of anomalous data on model performance, but also substantially enhances model stability. Moreover, it achieves performance comparable to that of more complex models while maintaining low computational complexity.

2.6. Reconstruction Representation

Although a multi-scale spatial–temporal graph model can capture dependencies across temporal and spatial dimensions, accurately distinguishing between normal and abnormal wheat flour remains crucial for unsupervised anomaly detection. Variational Autoencoder (VAE) is capable of extracting latent patterns from high-dimensional data and has been widely applied to anomaly detection tasks [23]. Specifically, VAE employs dimensionality reduction to compress the spatial–temporal feature representation ht of the wheat flour hazard factor into a low-dimensional latent variable zt and subsequently reconstructs ht from zt. Assuming that zt follows a prior distribution pθ(zt), the reconstructed feature ĥt can be sampled from the posterior distribution pθ(ht|zt). However, conventional VAEs typically employ a multi-layer perceptron (MLP) as both inference and generative networks, which can lead to poor interpretability and high parameter complexity in wheat flour anomaly detection tasks. Kolmogorov–Arnold networks (KANs) [24] employ learnable activation functions to parameterize weights in spline form, offering high flexibility and enabling complex functions to be simulated with fewer parameters, thereby improving model interpretability. Building on this idea, the traditional VAE is enhanced by employing KAN as both the inference network qφ(zt|ht) and the generative network pθ(ht|zt), where φ and θ denote the parameters of the inference and generative networks, respectively. The internal architecture of the proposed model is illustrated in Figure 4.
As can be seen from Figure 4, learnable activation functions and spline functions are first applied to ht to reduce the embedding dimensionality of the spatial–temporal features of the wheat flour hazard factor, ensuring that they approximately follow a normal distribution. The mean and variance are then computed to obtain the latent representation vector zt:
z t ( μ , σ ) = k = 1 K ω k ϕ k ( S k ( h t ) )
where k = 1 K ω k ϕ k ( ) represents the spline function of the encoder, Sk(.) denotes the learnable activation function of the encoder, μ denotes the mean, and σ denotes the variance. Secondly, the features are reconstructed using the spline function and the learnable activation function within the decoder:
h ^ t = k = 1 K ω k φ k ( S k ( z t ) )
where k = 1 K ω k φ k ( ) represents the spline function of the decoder, and S k ( ) denotes the learnable activation function of the decoder. Finally, model parameters are optimized by adjusting the spline function and the learnable activation function through the reconstruction loss.

2.7. Anomaly Detection and Threshold Selection

2.7.1. Offline Training

To achieve optimal detection performance, a joint loss function is designed for end-to-end training of the MSTUAD framework. Specifically, for unsupervised learning, to optimize the multi-scale spatial–temporal graph model, we employ negative sampling and utilize a binary cross-entropy loss function to maximally enhance similarity among node embeddings in positive samples and minimize similarity among node embeddings in negative samples:
L M S T G M = i = 1 , j = 1 log σ D o t ( c t i , ( c t j ) T ) k = 1 , l = 1 log σ D o t ( d t k , ( d t l ) T )
where c t i and d t k represent the sets of positive and negative samples, respectively, for the embedding vector in time window Wt, T represents matrix transposition, and Dot(.) denotes the inner product.
Secondly, consistent with most VAE training approaches, stochastic gradient variational Bayes (SGVB) [25] is employed to optimize the VAE parameters by maximizing the evidence lower bound (ELBO). For the spatial–temporal feature ht of the wheat flour hazard factor, the reconstruction loss function LRe and the similarity metric function LSim are respectively defined as follows:
L R e = 1 K i = 1 K h ^ t i h t i 2
L S i m = D K L q ϕ ( z t | h t ) p θ ( z t )
where h ^ t i and x t i denote the reconstructed value and the actual value of the ith variable in time window wt, respectively, and D K L q ϕ ( z t | h t ) p θ ( z t ) represents the regularization term for the latent variable zt, which is obtained by minimizing the Kullback–Leibler divergence between the approximate posterior and the prior distribution of the latent variable.
Finally, we integrate LMSTGM, LRe, and LSim to jointly train the proposed MSTUAD, measuring the importance of the multi-scale spatial–temporal graph model and the reconstruction representation through the balanced parameter λ. The joint training loss function is
L j o i n t ( Θ ) = L M S T G M + λ ( L R e + L S i m )
where Θ denotes all parameters requiring training, including Wl, Wf, Wi, Wo, Wc, bf, bi, bo, bc, Φ, and θ.

2.7.2. Online Detection

After training, the MSTUAD can be used to detect abnormal conditions that deviate from normal patterns in wheat flour. Specifically, this paper calculates a comprehensive anomaly score by aggregating the anomaly scores at each time point within a time window. If the anomaly score of time window wt exceeds the threshold, the corresponding time window is classified as anomalous. The anomaly score is calculated as follows:
s ( t ) = i s i ( t ) = i h ^ t i h t i
At the same time, to determine the optimal threshold, this study sets the search iterations to 700 with a step size of 0.01 and performs threshold optimization based on the F1-score of the validation set. The threshold achieving the highest validation F1-score is selected as the optimal threshold. Additionally, a point-adjustment strategy is applied to the anomaly scores based on the method proposed in reference [26]. Algorithm 1 summarizes the main procedure of the MSTUAD.
Algorithm 1 Pseudo-code of MSTUAD framework under the guidance of loss function
Input: Wheat flour multi-hazard factor detection data X, parameters n, τ, k.
Output: The value of loss.
1: for t = τ to n do
2:               wt = x [tτ + 1:t]
3:               ρ ← MIC (wt)
4:               Gtk-NN (k, ρ)
5:                x ˜ t ← MSCA (xt)
6:               ht←STRCM ( x ˜ t , G t )
7:                h ^ t   VAE ( h t )
8: end for
9: Calculate Ljoint using Equation (22)
10: Back propagation and update parameters in MSKTSAD
11: Return Ljoint

3. Experiments and Results

In this section, we first provide a detailed introduction to the experimental details and baseline models. Secondly, we compare our proposed MSTUAD with state-of-the-art baseline methods, demonstrating its effectiveness in wheat flour anomaly detection. Subsequently, we focus on ablation experiments to validate the impact of each component within the model. Finally, we discuss the model’s broad applicability and parameter sensitivity.

3.1. Experimental Details

3.1.1. Data Preprocessing

Due to differences in the physical interpretations and measurement units of hazard factors during wheat flour transportation, Min-Max normalization is applied to standardize the training set, while the normalization parameters (mean and variance) are applied to the test set to prevent data leakage:
x i * = x i x m i n x m a x x m i n
where x i = x 1 , x 2 , , x T denotes the wheat flour transportation hazard factor dataset, x i * denotes the normalized data, xmax denotes the maximum value of the dataset, and xmin denotes the minimum value of the dataset.

3.1.2. Baseline Model

The proposed MSTUAD is compared with state-of-the-art baseline models, including machine learning-based anomaly detection methods and widely used deep-learning-based multivariate anomaly detection approaches. Detailed descriptions of the baseline models are provided in Table 2.

3.1.3. Setting of Hyperparameters

The MSTUAD framework is implemented using Python 3.8 and PyTorch 1.11. All experiments were conducted on a workstation equipped with an Intel® Xeon® Silver 4210R CPU and an NVIDIA GeForce RTX 3090 GPU. In this experiment, the wheat flour transportation hazard factor dataset was divided chronologically into training and test sets at a ratio of 7:3, and 35% of the test set was further allocated as a validation set for determining the optimal threshold. Additionally, to avoid potential information leakage caused by overlapping sliding windows across different subsets, we constructed sliding windows independently within the training and test sets after data partitioning, thereby providing a more reliable evaluation of the model’s generalization capability.
For MSTUAD, the number of graph neural network layers l is set to 3, the variable embedding dimension to 5, the time window τ to 20, the number of nearest neighbors k to 6, the balanced parameter λ to 1, the latent representation dimension z to 100, and the batch size to 256. At the same time, we evaluated the baseline model using the same time window, normalization method, and threshold strategy. All experimental results are reported as the average of five independent runs with different random seeds. The source code is publicly available at https://github.com/ShengWB/MSTUAD, accessed on 2 July 2026.

3.1.4. Evaluation Metrics

We evaluate the performance of our proposed model and baseline models using Precision (Pre), Recall (Rec), F1-score (F1), and AUC, defined as follows:
P r e c i s i o n = T P T P + F P
R e c a l l = T P T P + F N
F 1 - s c o r e = 2 × P r e c i s i o n × R e c a l l P r e c i s i o n + R e c a l l
A U C = 0 1 R e c a l l ( F P R ) d ( F P R )
where TP denotes the actual number of anomalies detected, TN denotes the actual number of normal instances detected, FP denotes the number of anomalies falsely detected, FN denotes the number of anomalies undetected, and F P R = F P / F P + T N denotes the false positive rate.

3.2. Results and Analysis

To validate the anomaly detection performance of the proposed MSTUAD, comparative experiments were conducted using the wheat flour transportation hazard factor dataset. The results are summarized in Table 3, where the best results are highlighted in bold, and the second-best results are underlined.
As shown in Table 3, MSTUAD achieves substantial improvements in AUC, Pre, and F1. Compared with RNN-based models such as LSTM-NDT, OmniAnomaly, and MSCRED, the AUC increases by an average of 32.5%, Pre by an average of 38.8%, and F1 by an average of 18.4%. This is because graph structure learning fully exploits the latent associations among risk factors, enhancing the model’s ability to detect complex anomaly patterns, thereby enabling more accurate detection of anomalies in wheat flour transportation. However, MSTUAD is capable of comprehensively accounting for both local deviations in individual hazard factors and complex interactions among multiple hazard factors. For minor anomalies characterized by small deviations that do not significantly disrupt the learned spatiotemporal correlation patterns, the model tends to regard them as normal fluctuations, resulting in a slight decrease in Rec.
Compared with graph neural network-based models, such as GDN, AGCSL, MTAD-GAT, and MUTANT, the AUC improved by an average of 17.7%, Pre by an average of 24.9%, and F1 by an average of 11.2%. This improvement results from the multi-scale convolutional attention, which focuses on changes in wheat flour hazard factors across multiple temporal scales, capturing both short-term and long-term temporal dependencies. This enhancement improves the model’s ability to perceive local details, thereby increasing the accuracy of wheat flour anomaly detection.
Compared with encoder-based models, such as TranAD, CAE-M, MEMTO, DTAAD, LFTSAD, and TransDe, the AUC improved by an average of 20.1%, Pre by an average of 16.6%, Rec by an average of 35.6%, and F1 by an average of 26.1%. This improvement is attributed to the reconstruction learning design, which reduces computational parameters through learnable activation functions and enhances model flexibility, thereby improving MSTUAD’s anomaly detection performance.

3.3. Ablation Experiments

To validate the effectiveness and superiority of MIC, MSTGM, and KAN, five ablation variants were meticulously designed for comparative experiments with MSTUAD. Despite partial modifications, all ablation variants retain identical framework structures and parameter settings. The Pre, Rec, F1, and AUC of these variants on the wheat flour transportation hazard factor dataset are presented in Figure 5.
(1)
w/o MIC: This ablation variant removes the maximum mutual information coefficient, using the traditional Pearson correlation coefficient as the standard for measuring the association between hazard factors.
(2)
w/o MSTGM: This ablation variant removes the multi-scale spatial–temporal graph model and directly uses the time window wt as input for the reconstruction learning.
(3)
w/o KAN: This ablation variant removes the KAN layer and employs an MLP layer as both the inference network and the generative network of the VAE.
(4)
w/o PA: This ablation variant omits the point adjustment strategy and directly uses the computed anomaly scores to calculate the optimal threshold.
(5)
with event: This ablation variant employs an event-based anomaly detection strategy.
As can be seen from Figure 5, compared with w/o MIC, MSTUAD achieved improvements of 6.8%, 3.5%, 3.9%, and 3.7% in AUC, Pre, Rec, and F1, respectively. This indicates that the maximum mutual information coefficient effectively encompasses all adjacency relationships, capturing both synergistic and antagonistic interactions among hazard factors. Consequently, MSTUAD demonstrates enhanced adaptability and robustness in graph structure learning, thereby establishing a strong foundation for more accurate and efficient anomaly detection.
Compared with w/o MSTGM, MSTUAD exhibits superior performance. Specifically, MSTUAD achieves a 3.3% improvement in F1, highlighting that the multi-scale spatial–temporal graph model not only captures dynamic trends and intrinsic correlations across time windows but also uncovers latent dependencies and chronic cumulative effects among wheat flour hazard factors, enhancing the model’s capacity to identify anomaly patterns in complex scenarios.
Compared with w/o KAN, although F1 of MSTUAD improved by only 2%, it leverages the Kolmogorov–Arnold theorem to establish robust nonlinear modeling capabilities at the theoretical level. This unique advantage not only captures spatial–temporal variation patterns among hazard factors but also ensures high interpretability while maintaining accuracy, enhancing the precision of anomaly detection in wheat flour transportation processes.
Compared with w/o PA and with an event, MSTUAD demonstrates a more substantial performance improvement after incorporating the point adjustment strategy. This indicates that the strategy enables fine-grained correction of point-level detection results under the guidance of event-level cues, thereby preserving the recall advantage offered by event semantics while improving anomaly localization and classification accuracy through point-level refinement, ultimately reducing both false positives and false negatives more effectively.

3.4. Parameter Sensitivity

In practical applications, parameter sensitivity influences the performance of deep-learning models in detecting wheat flour anomalies across various scenarios. Therefore, this section examines the impact of four key parameters in the MSTUAD on anomaly detection performance: time window length τ, number of nearest neighbors k, latent representation layer dimension z, and balanced parameter λ. The results are presented in Figure 6.
Figure 6a illustrates the Pre, Rec, F1, and AUC under different time window lengths. It can be observed that as the time window length increases, the performance of MSTUAD initially improves and subsequently declines. When τ = 20, MSTUAD achieves optimal performance. This occurs because when the time window is too small, the limited amount of data prevents the model from effectively learning synergistic or antagonistic interaction patterns among hazard factors. However, excessively large time windows introduce overly complex information, which complicates the interrelationships among hazard factors and ultimately degrades wheat flour anomaly detection performance.
The second parameter researched is the number of nearest neighbors k, which determines how many similar hazard factors are selected as neighboring nodes for a given hazard factor. As shown in Figure 6b, the impact of k on the model’s detection performance exhibits an initial increase followed by a subsequent decline. MSTUAD achieves optimal performance when k = 6. If k is too small, the model may overlook coupling relationships among hazard factors. Conversely, when k is excessively large, noise may weaken the true correlations among hazard factors.
Figure 6c indicates that, as the dimension of the latent representation layer increases, the performance of MSTUAD gradually declines and then exhibits a slight improvement. When z = 100, MSTUAD achieves optimal performance. The primary reason is that a smaller latent representation dimension leads to the loss of critical information, resulting in larger reconstruction errors for normal wheat flour samples. Conversely, an excessively large latent dimension fails to capture essential features, preventing the model from effectively distinguishing abnormal wheat flour from normal samples.
Figure 6d illustrates the effect of the balanced parameter λ on anomaly detection performance. It can be observed that the influence of the balanced parameter λ on the model exhibits a trend similar to that of the number of nearest neighbors k. When λ = 1, MSTUAD achieves optimal performance. This is because the balanced parameter λ regulates the relative importance of the multi-scale spatial–temporal graph model and the reconstruction representation during training. An appropriate λ not only enables the model to capture latent temporal and spatial structural features among hazard factors but also facilitates accurate reconstruction of their spatial–temporal characteristics, enhancing the detection capability for abnormal wheat flour.

3.5. Extensive Experiments

To further validate the general applicability of the proposed MSTUAD, we conducted comparative experiments on three publicly available real-world datasets: the Mars Science Laboratory Rover (MSL) [28], the Soil Moisture Active Passive satellite (SMAP) [28], and the Safe Water Treatment [41]. Table 4 summarizes the detailed statistics of the three datasets. In the experiment, we used the training set shown in Table 4 to train the anomaly detection models and the test set to evaluate the performance of all models. The specific parameter settings and details of the evaluation process also follow Section 3.1.3.
Table 5 presents the performance results of all methods across the three public datasets, with the best results highlighted in bold and the second-best results underlined. It is evident that, across the three public datasets, MSTUAD consistently outperforms all baseline methods in terms of F1. Specifically, compared with the best-performing baseline model across all public datasets, MSTUAD achieves an average F1 improvement of 0.68%. This result validates the stability of MSTUAD across different datasets and highlights its broad applicability in practical scenarios.
Compared with traditional anomaly detection methods, MSTUAD demonstrates consistently superior performance across the three public datasets. When compared with prediction-based anomaly detection methods, MSTUAD achieves average F1 improvements of 61.5%, 73%, and 112.6%, respectively, across the three public datasets. Compared with reconstruction-based anomaly detection methods, MSTUAD achieves average F1 improvements of 26.9%, 30.4%, and 18.1% across the three public datasets. Compared with contrastive learning-based anomaly detection methods, MSTUAD achieves an average F1 improvement of 0.95% across the three public datasets.
Furthermore, compared with OmniAnomaly, MTAD-GAT, DTAAD, and LFTSAD, MSTUAD achieves average F1 improvements of 20.3% and 12.2% on small-scale datasets (i.e., MSL and SWaT), respectively, as well as an average F1 improvement of 34.2% on large-scale datasets (i.e., SMAP). This improvement can be attributed to MSTUAD’s ability to effectively capture interdependencies among multiple variables, thereby enhancing detection performance on large-scale datasets.

3.6. Complexity Analysis

Model complexity serves as an indicator of the model’s computational resource requirements. Table 6 summarizes the parameter counts and training times of MSTUAD in comparison with other methods. Notably, to more intuitively illustrate the balance between complexity and detection accuracy, the F1 on the wheat flour transportation hazard factor dataset was selected as the evaluation metric for these approaches.
As shown in Table 6, the GDN and DTAAD methods exhibit relatively low parameter counts. This is because these approaches employ graph neural networks and shallow temporal convolutional networks, respectively, to capture inter-variable relationships or temporal dependencies, thereby reducing model complexity. Although MSTUAD is constructed based on graph neural networks and shallow recurrent neural networks, it exhibits a comparatively larger number of parameters and the longest training time. This is because MSTUAD incorporates multi-scale convolutional attention and residual graph neural networks, which stack numerous convolutional operations and consequently increase model complexity. Nevertheless, compared with GDN and DTAAD, MSTUAD achieves a superior F1. Furthermore, methods such as ACGSL, CAE-M, and LFTSAD exhibit lower model complexity due to their encoder–decoder architectures. However, their anomaly detection accuracy remains inferior to the proposed MSTUAD.

3.7. Case Study

In this section, we investigate the effectiveness of the proposed MSTUAD in anomaly detection through a case study. Figure 7 illustrates selected anomalous time periods from the wheat flour transportation hazard factor dataset. The data samples at time points t1, t2, t3, and t4 represent anomalies identified by the proposed model and correspond to confirmed abnormal events.
As shown in Figure 7, the trends of AFB1 and BaP exhibit relatively stable patterns with periodic fluctuations, which generally correspond to cyclical variations in transportation batches and environmental conditions in real-world scenarios. When significant changes in AFB1 and BaP occur at time points t3 and t4, both the proposed MSTUAD and existing anomaly detection models are able to identify these anomalies. This is because such anomalies exhibit prominent univariate characteristics with large fluctuation amplitudes, classifying them as easily observable anomalies. Therefore, most anomaly detection models demonstrate strong detection capability for this type of anomaly.
At the same time, the temporal trends of Cr and DON were largely consistent throughout most periods and exhibited a strong correlation, suggesting a potential synergistic coupling relationship. However, at time points t1 and t2, the relative variation patterns of Cr and DON, as well as Pb and Hg, exhibited noticeable deviations, suggesting that the previously learned coupling relationships among hazard factors were disrupted and resulted in anomalous states. Since other anomaly detection models do not explicitly model the complex dependencies among hazard factors, they may fail to capture abrupt changes in coupling relationships and consequently have difficulty detecting such anomalies.
In contrast, the proposed MSTUAD model utilizes graph structure learning to characterize the mutual coupling relationships among hazard factors within each time window, and it employs a multi-scale spatial–temporal graph model to dynamically model and update evolving dependency structures. As a result, when coupling relationships among hazard factors change, MSTUAD can effectively identify potential anomalies induced by these structural shifts—even when individual hazard factors exhibit normal behavior, thereby substantially enhancing anomaly detection accuracy.

4. Discussion

  • Model adaptability in special environments
This paper investigates hazard factors during wheat flour transportation. By constructing feature maps to characterize the coupling relationships and designing a multi-scale spatial–temporal graph model to extract spatial–temporal features from these maps, we employ a reconstruction model based on variational autoencoders to learn latent representations of hazard factors’ spatial–temporal characteristics for capturing the intrinsic features of normal wheat flour. However, during actual transportation, wheat flour safety is also influenced by external contextual factors, including transportation environments, geographic conditions, and packaging characteristics, which may interact with hazard factors through complex mechanisms. For example, extreme environmental conditions, such as high-altitude and extremely cold environments, may cause packaging materials to become brittle, deform, or rupture, compromising packaging integrity and increasing the risk of moisture penetration and microbial contamination, which may further promote mold growth and mycotoxin accumulation. Meanwhile, hot and humid climates, such as those in Southeast Asia, may accelerate microbial metabolic activity and mycotoxin production, causing wheat flour with identical initial hazard levels to exhibit different risk profiles. Furthermore, even when the measured hazard levels of samples from different regions are comparable, differences in transportation routes and climatic conditions may result in divergent safety outcomes. Therefore, a key challenge in food safety research is how to incorporate multi-source heterogeneous information to move beyond risk analysis frameworks driven solely by individual hazard factor data and how to effectively integrate structured and unstructured data to uncover the intrinsic relationships among diverse influencing factors.
2.
Trade-off between model accuracy and efficiency
As shown in Figure 5, compared with w/o MSTGM, MSTUAD exhibits superior anomaly detection accuracy during wheat flour transportation. This improvement arises because the multi-scale spatial–temporal graph model can effectively extract dynamic variation features of hazard factors across multiple time scales and environmental conditions, enabling multi-granularity perception and information fusion, facilitating more accurate identification of potential anomaly patterns. Meanwhile, multi-scale information is integrated to characterize temperature and humidity variations induced by seasonal and geographical factors, which enhances the robustness and reliability of wheat flour anomaly detection. However, multi-scale spatial–temporal graph models typically integrate parallel and stacked conventional convolutional layers, which inevitably increase the number of model parameters and computational complexity, thereby limiting their applicability in large-scale, real-time, and high-speed risk detection scenarios. Previous studies have demonstrated that depthwise separable convolution, which decomposes standard convolution into depthwise and pointwise operations, can substantially reduce both the number of parameters and computational costs [42]. Therefore, integrating depthwise separable convolution with multi-scale approaches to reduce computational overhead while preserving detection accuracy remains an important research challenge.
3.
Adjustment and optimization of key parameters
As discussed in Section 3.1.3, the proposed MSTUAD in this paper incorporates key parameters such as the number of graph neural network layers, the embedding dimensions, and the time window size, which jointly affect the overall performance of wheat flour anomaly detection. Figure 6 illustrates that comprehensive experimental evaluation facilitates the identification of optimal hyperparameter configurations, thereby improving the accuracy of anomaly detection in wheat flour. However, this study primarily relies on theoretical analysis and iterative experimentation, without an automated hyperparameter search mechanism. This dependence leads to a time-consuming and inefficient tuning process that is difficult to adapt to diverse and dynamically evolving scenarios. Furthermore, manual parameter tuning is susceptible to overfitting across different real-world scenarios, thereby undermining the robustness and stability of the model. Deep Q-Network (DQN) has the capacity to autonomously learn optimization strategies within complex, high-dimensional, and uncertain search spaces, thereby enabling dynamic exploration and global optimization of hyperparameter configurations. Therefore, designing an automatic hyperparameter optimization mechanism based on DQN to enhance model tuning efficiency and generalization capability constitutes an important direction for future research.

5. Conclusions and Future Work

This paper proposes an MSTUAD framework for wheat flour anomaly detection. It uses a multi-scale convolutional attention to capture both short-term dynamic changes and long-term temporal trend information across multiple time scales. Meanwhile, the multi-scale spatial–temporal graph model and reconstruction representation can effectively capture the spatial–temporal characteristics of wheat flour hazard factors while learning the features of normal samples through reconstruction. Comparative experiments conducted on the wheat flour transportation hazard factor dataset demonstrate that MSTUAD attains an F1-score of 0.8455, surpassing all baseline methods. Furthermore, MSTUAD achieves the highest F1-score on three public benchmark datasets (SMAP: 0.9803, MSL: 0.9629, and SWaT: 0.9520), as well as the best AUC on the SMAP and MSL datasets, further validating its effectiveness and generalization capability in anomaly detection tasks.
Future work will focus on collecting multi-source heterogeneous data and integrating them with wheat flour hazard factor detection data to construct a wheat flour safety risk assessment system based on heterogeneous information fusion. This strategy is expected to improve the capability to address diverse and complex abnormal scenarios encountered during wheat flour transportation and storage.

Author Contributions

Conceptualization, W.S. and H.J.; methodology, W.S. and H.J.; software, W.S. and H.J.; validation, W.P., Z.Y. and L.Z.; formal analysis, W.P.; investigation, H.J.; resources, Z.Y.; data curation, W.S.; writing—original draft preparation, W.S.; writing—review and editing, H.J.; visualization, L.Z.; supervision, W.P., Z.Y. and L.Z.; project administration, W.P.; funding acquisition, H.J. All authors have read and agreed to the published version of the manuscript.

Funding

This research was supported by the National Natural Science Foundation of China (62541312), the Natural Science Foundation of Henan Province (252300421868), and the Key Scientific Research Project of Colleges and Universities in Henan Province (25A520019).

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

Data will be made available on request.

Conflicts of Interest

Author Wenqiang Pi was employed by the company Henan Zhongyu Port and Shipping Construction Engineering Co., Ltd. He participated in validation, formal analysis, project administration and supervision in the study. The role of the company was limited to providing the author with institutional affiliation. There were no potential conflicts of interest, nor did the company influence the research design, data collection, data analysis, interpretation of results, writing of the paper, or decisions regarding the publication of the results. The remaining authors declare that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.

References

  1. Srivastava, R.; Singh, Y.; White, J.C.; Dhankher, O.P. Mitigating toxic metals contamination in foods: Bridging knowledge gaps for addressing food safety. Trends. Food. Sci. Tech. 2024, 153, 104725. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  2. Melendreras García, C.; Soldado Cabezuelo, A.; Ferrero Martín, F.; Valledor Llopis, M.; Ortíz-Gómez, I.; Manuel Costa-Fernández, J. An Affordable IoAT Colorimetric Sensor Based on NanoMOFs for On-Site Food Safety Detection. IEEE Trans. Instrum. Meas. 2025, 74, 9506610. [Google Scholar] [CrossRef] [Scilit]
  3. Song, C.; Wu, Z.; Gray, J.; Meng, Z. An RFID-Powered Multisensing Fusion Industrial IoT System for Food Quality Assessment and Sensing. IEEE Trans. Ind. Inform. 2024, 20, 337–348. [Google Scholar] [CrossRef] [Scilit]
  4. Han, Y.; Liu, J.; Pan, F.; Ni, Q.; Ma, B.; Geng, Z. Synthesized minority Oversampling Technique-Reverse k-nearest Neighbors-K-Dimensional Tree for dairy food safety risk evaluation. Expert Syst. Appl. 2025, 275, 127064. [Google Scholar] [CrossRef] [Scilit]
  5. Oteiza, J.M.; Prez, V.E.; Pereyra, D.; Jaureguiberry, M.V.; Sánchez, G.; Sant’Ana, A.S.; Barril, P.A. Occurrence of Norovirus, Rotavirus, Hepatitis a virus, and Enterovirus in Berries in Argentina. Food Environ. Virol. 2022, 14, 170–177. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  6. He, X.; Liu, X.; Wu, P.; Zhang, L.; Zhou, W.; Zhang, Q.; Zhang, J. Reduction of pathogenic bacteria from irrigation water through a copper-loaded porous ceramic emitter. Environ. Pollut. 2023, 330, 121776. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  7. Yan, J.; Sun, L.; Zuo, E.; Zhong, J.; Li, T.; Chen, C.; Chen, C.; Lv, X. An explainable unsupervised risk early warning framework based on the empirical cumulative distribution function: Application to dairy safety. Food Res. Int. 2024, 178, 113933. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  8. Ma, B.; Han, Y.; Cui, S.; Geng, Z.; Li, H.; Chu, C. Risk early warning and control of food safety based on an improved analytic hierarchy process integrating quality control analysis method. Food Control 2020, 108, 106824. [Google Scholar] [CrossRef] [Scilit]
  9. Han, Y.; Cui, S.; Geng, Z.; Chu, C.; Chen, K.; Wang, Y. Food quality and safety risk assessment using a novel HMM method based on GRA. Food Control 2019, 105, 180–189. [Google Scholar] [CrossRef] [Scilit]
  10. Wang, X.; Bouzembrak, Y.; Lansink, A.O.; van der Fels-Klerx, H.J. Application of machine learning to the monitoring and prediction of food safety: A review. Compr. Rev. Food Sci. Food Saf. 2022, 21, 416–434. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  11. Sheng, W.; Jiang, H.; Yang, Z.; Zhao, L.; Jin, J. A safety risk assessment method based on conditionally constrained game theory and adaptive ensemble learning: Application to wheat flour and rice. Food Res. Int. 2025, 203, 115835. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  12. Geng, Z.; Shang, D.; Han, Y.; Zhong, Y. Early warning modeling and analysis based on a deep radial basis function neural network integrating an analytic hierarchy process: A case study for food safety. Food Control 2019, 96, 329–342. [Google Scholar] [CrossRef] [Scilit]
  13. Geng, Z.; Wang, X.; Jiang, Y.; Han, Y.; Ma, B.; Chu, C. Novel IAPSO-LSTM neural network for risk analysis and early warning of food safety. Expert Syst. Appl. 2023, 230, 120747. [Google Scholar] [CrossRef] [Scilit]
  14. Zuo, E.; Du, X.; Aysa, A.; Lv, X.; Muhammat, M.; Zhao, Y.; Ubul, K. Anomaly Score-Based Risk Early Warning System for Rapidly Controlling Food Safety Risk. Foods 2022, 11, 2076. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  15. Zuo, E.; Yan, J.; Aysa, A.; Chen, C.; Chen, C.; Ma, H.; Lv, X.; Ubul, K. SUCOLA: Self-adaptive structure refinement unsupervised contrastive learning framework for food safety risk early warning. Eng. Appl. Artif. Intell. 2023, 126, 107016. [Google Scholar] [CrossRef] [Scilit]
  16. China Administration for Market Regulation. Available online: https://www.samr.gov.cn (accessed on 18 January 2026).
  17. GB 2762-2025; National Food Safety Standards—Limits of Contaminants in Food. The National Health Commission of the People’s Republic of China: Beijing, China, 2025. Available online: https://down.foodmate.net/standard/yulan.php?itemid=166971 (accessed on 2 July 2026).
  18. GB 2761-2017; National Food Safety Standards—Limits of Mycotoxins in Food. The National Health Commission of the People’s Republic of China: Beijing, China, 2017. Available online: https://down.foodmate.net/standard/yulan.php?itemid=50747 (accessed on 2 July 2026).
  19. Kinney, J.B.; Atwal, G.S. Equitability, mutual information, and the maximal information coefficient. Proc. Natl. Acad. Sci. USA 2014, 111, 3354–3359. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  20. Guo, M.-H.; Lu, C.-Z.; Hou, Q.; Liu, Z.; Cheng, M.-M.; Hu, S.-M. SegNeXt: Rethinking Convolutional Attention Design for Semantic Segmentation. Adv. Neural Inf. Process. Syst. 2022, 35, 1140–1156. [Google Scholar] [CrossRef] [Scilit]
  21. Li, G.; Müller, M.; Qian, G.; Delgadillo, I.C.; Abualshour, A.; Thabet, A.; Ghanem, B. DeepGCNs: Making GCNs Go as Deep as CNNs. IEEE Trans. Pattern Anal. Mach. Intell. 2023, 45, 6923–6939. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  22. Beck, M.; Pöppel, K.; Spanring, M.; Auer, A.; Prudnikova, O.; Kopp, M.K.; Klambauer, G.; Brandstetter, J.; Hochreiter, S. xLSTM: Extended Long Short-Term Memory. In The Thirty-Eighth Annual Conference on Neural Information Processing Systems, Vancouver, BC, Canada, 10–15 December 2024; Curran Associates, Inc.: Red Hook, NY, USA, 2024. [Google Scholar]
  23. Kingma, D.P.; Welling, M. Auto-Encoding Variational Bayes. arXiv 2022, arXiv:1312.6114. [Google Scholar]
  24. Liu, Z.; Wang, Y.; Vaidya, S.; Ruehle, F.; Halverson, J.; Soljacic, M.; Hou, T.Y.; Tegmark, M. KAN: Kolmogorov-Arnold Networks. In Proceedings of the Thirteenth International Conference on Learning Representations, Singapore, 24–28 April 2024. [Google Scholar]
  25. Kingma, D.P.; Welling, M. Stochastic Gradient VB and the Variational Auto-Encoder. arXiv 2014, arXiv:1312.6114v8. [Google Scholar]
  26. Kim, S.; Choi, K.; Choi, H.-S.; Lee, B.; Yoon, S. Towards a Rigorous Evaluation of Time-Series Anomaly Detection. Proc. AAAI Conf. Artif. Intell. 2022, 36, 7194–7201. [Google Scholar] [CrossRef] [Scilit]
  27. Liu, F.T.; Ting, K.M.; Zhou, Z.-H. Isolation Forest. In Proceedings of the Eighth IEEE International Conference on Data Mining, Pisa, Italy, 15–19 December 2008. [Google Scholar]
  28. Hundman, K.; Constantinou, V.; Laporte, C.; Colwell, I.; Soderstrom, T. Detecting Spacecraft Anomalies Using LSTMs and Nonparametric Dynamic Thresholding. In Proceedings of the 24th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, London, UK, 19–23 August 2018. [Google Scholar]
  29. Deng, A.; Hooi, B. Graph Neural Network-Based Anomaly Detection in Multivariate Time Series. Proc. AAAI Conf. Artif. Intell. 2021, 35, 4027–4035. [Google Scholar] [CrossRef] [Scilit]
  30. Pang, H.; Wei, S.; Li, Y.; Liu, T.; Zhang, H.; Qin, Y.; Zhao, Y. Asymptotic Consistent Graph Structure Learning for Multivariate Time-Series Anomaly Detection. IEEE Trans. Instrum. Meas. 2024, 73, 2509510. [Google Scholar] [CrossRef] [Scilit]
  31. Su, Y.; Zhao, Y.; Niu, C.; Liu, R.; Sun, W.; Pei, D. Robust Anomaly Detection for Multivariate Time Series through Stochastic Recurrent Neural Network. In Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, Anaheim, CA, USA, 4–8 August 2019. [Google Scholar]
  32. Zhang, C.; Song, D.; Chen, Y.; Feng, X.; Lumezanu, C.; Cheng, W.; Ni, J.; Zong, B.; Chen, H.; Chawla, N.V. A deep neural network for unsupervised anomaly detection and diagnosis in multivariate time series data. In Proceedings of the Thirty-Third AAAI Conference on Artificial Intelligence, Honolulu, HI, USA, 29–31 January 2019. [Google Scholar]
  33. Zhao, H.; Wang, Y.; Duan, J.; Huang, C.; Cao, D.; Tong, Y.; Xu, B.; Bai, J.; Tong, J.; Zhang, Q. Multivariate Time-Series Anomaly Detection via Graph Attention Network. In Proceedings of the IEEE International Conference on Data Mining (ICDM), Sorrento, Italy, 17–20 November 2020. [Google Scholar]
  34. Tuli, S.; Casale, G.; Jennings, N.R. TranAD: Deep transformer networks for anomaly detection in multivariate time series data. In Proceedings of the VLDB Endowment, Sydney, Australia, 5–9 September 2022. [Google Scholar]
  35. Zhang, Y.; Chen, Y.; Wang, J.; Pan, Z. Unsupervised Deep Anomaly Detection for Multi-Sensor Time-Series Signals. IEEE Trans. Knowl. Data Eng. 2023, 35, 2118–2132. [Google Scholar] [CrossRef] [Scilit]
  36. Shi, Y.; Wang, B.; Yu, Y.; Tang, X.; Huang, C.; Dong, J. Robust anomaly detection for multivariate time series through temporal GCNs and attention-based VAE. Knowl.-Based Syst. 2023, 275, 110725. [Google Scholar] [CrossRef] [Scilit]
  37. Song, J.; Kim, K.; Oh, J.; Cho, S. MEMTO: Memory-guided transformer for multivariate time series anomaly detection. In Proceedings of the 37th International Conference on Neural Information Processing Systems, New Orleans, LA, USA, 10–16 December 2023. [Google Scholar]
  38. Yu, L.-R.; Lu, Q.-H.; Xue, Y. DTAAD: Dual Tcn-attention networks for anomaly detection in multivariate time series data. Knowl.-Based Syst. 2024, 295, 111849. [Google Scholar] [CrossRef] [Scilit]
  39. Chen, L.; Tang, J.; Zou, Y.; Liu, X.; Xie, X.; Deng, G. Lightweight and Fast Time-Series Anomaly Detection via Point-Level and Sequence-Level Reconstruction Discrepancy. IEEE Trans. Neural Netw. Learn. Syst. 2025, 36, 17295–17309. [Google Scholar] [PubMed]
  40. Zhang, W.; Luo, C. Decomposition-based multi-scale transformer framework for time series anomaly detection. Neural Netw. 2025, 187, 107399. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  41. Mathur, A.P.; Tippenhauer, N.O. SWaT: A water treatment testbed for research and training on ICS security. In International Workshop on Cyber-Physical Systems for Smart Water Networks; IEEE: New York, NY, USA, 2016; pp. 31–36. [Google Scholar]
  42. Sandler, M.; Howard, A.; Zhu, M.; Zhmoginov, A.; Chen, L.-C. MobileNetV2: Inverted Residuals and Linear Bottlenecks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Salt Lake City, UT, USA, 18–23 June 2018. [Google Scholar]
Figure 1. The overview of the proposed MSTUAD. (a) Graph structure learning, which converts the sequence of multiple hazard factors in wheat flour transportation into graph structure data using maximum mutual information. (b) Multiscale spatial-temporal graph model, which identifies the spatial-temporal characteristics of hazard factors in wheat flour transportation through multi-scale convolutional attention and spatial-temporal feature extraction modules. (c) Reconstruction representation, which uses KAN-based Encoder and Decoder to reconstruct spatial-temporal features. (d) Anomaly detection and threshold selection, which employs the anomaly score and point adjustment strategy to determine thresholds for detecting anomalies.
Figure 1. The overview of the proposed MSTUAD. (a) Graph structure learning, which converts the sequence of multiple hazard factors in wheat flour transportation into graph structure data using maximum mutual information. (b) Multiscale spatial-temporal graph model, which identifies the spatial-temporal characteristics of hazard factors in wheat flour transportation through multi-scale convolutional attention and spatial-temporal feature extraction modules. (c) Reconstruction representation, which uses KAN-based Encoder and Decoder to reconstruct spatial-temporal features. (d) Anomaly detection and threshold selection, which employs the anomaly score and point adjustment strategy to determine thresholds for detecting anomalies.
Foods 15 02934 g001
Figure 2. The structure of multi-scale convolutional attention.
Figure 2. The structure of multi-scale convolutional attention.
Foods 15 02934 g002
Figure 3. The structure of STFEM.
Figure 3. The structure of STFEM.
Foods 15 02934 g003
Figure 4. The structure of an improved variational autocoder.
Figure 4. The structure of an improved variational autocoder.
Foods 15 02934 g004
Figure 5. The performance comparison of variants on the wheat flour transportation hazard factor dataset.
Figure 5. The performance comparison of variants on the wheat flour transportation hazard factor dataset.
Foods 15 02934 g005
Figure 6. Experimental results of the MSTUAD parameter on the wheat flour transportation hazard factor dataset: (a) window length τ; (b) number of nearest neighbors k; (c) latent representation layer dimension z; (d) balanced parameter λ.
Figure 6. Experimental results of the MSTUAD parameter on the wheat flour transportation hazard factor dataset: (a) window length τ; (b) number of nearest neighbors k; (c) latent representation layer dimension z; (d) balanced parameter λ.
Foods 15 02934 g006
Figure 7. Anomaly detection results for the wheat flour transportation hazard factor dataset. The red shaded areas indicate abnormalities caused by single-variable mutations, while the gray shaded areas indicate abnormalities caused by synergistic changes in multiple variables.
Figure 7. Anomaly detection results for the wheat flour transportation hazard factor dataset. The red shaded areas indicate abnormalities caused by single-variable mutations, while the gray shaded areas indicate abnormalities caused by synergistic changes in multiple variables.
Foods 15 02934 g007
Table 1. The national food safety standard for wheat flour.
Table 1. The national food safety standard for wheat flour.
CategoryItemsLimited ValueNational Standard
Heavy metalsHg0.02 mg/kgGB 2762-2025
As0.5 mg/kgGB 2762-2025
Pb0.2 mg/kgGB 2762-2025
Cd0.1 mg/kgGB 2762-2025
Cr1.0 mg/kgGB 2762-2025
MycotoxinsZEN60.0 μg/kgGB 2761-2017
DON1000 μg/kgGB 2761-2017
OTA5.0 μg/kgGB 2761-2017
AFB15.0 μg/kgGB 2761-2017
OthersBaP2.0 μg/kgGB 2762-2025
Table 2. Details of the compared methods.
Table 2. Details of the compared methods.
CompetitorsBasisPublication and Year
IF [27]ClassicalICDM, 2008
LSTM-NDT [28]Prediction-basedKDD, 2018
GDN [29]AAAI, 2021
AGCSL [30]IEEE TIM, 2024
OmniAnomaly [31]Reconstruction-basedKDD, 2019
MSCRED [32]AAAI, 2019
MTAD-GAT [33]ICDM, 2020
TranAD [34]VLDB, 2022
CAE-M [35]IEEE TKDE, 2023
MUTANT [36]KBS, 2023
MEMTO [37]NIPS, 2023
DTAAD [38]KBS, 2024
LFTSAD [39]TNNLS, 2025
TransDe [40]Contrastive learning-basedNN, 2025
Table 3. The comparative experiments with the state-of-the-art anomaly detection model.
Table 3. The comparative experiments with the state-of-the-art anomaly detection model.
MethodAUCPreRecF1
IF0.5231 ± 0.0050.6657 ± 0.0250.1207 ± 0.0050.2044 ± 0.008
LSTM-NDT0.4916 ± 0.0000.5468 ± 0.0000.9056 ± 0.0000.6819 ± 0.000
GDN0.5936 ± 0.0010.6036 ± 0.0000.9709 ± 0.0010.7444 ± 0.000
AGCSL0.6061 ± 0.0090.6104 ± 0.0050.9851 ± 0.0040.7537 ± 0.005
OmniAnomaly0.5937 ± 0.0030.6067 ± 0.0020.9230 ± 0.0080.7321 ± 0.002
MSCRED0.5646 ± 0.0090.5870 ± 0.0050.9583 ± 0.0140.7279 ± 0.004
MTAD-GAT0.5647 ± 0.0050.5861 ± 0.0030.9791 ± 0.0100.7333 ± 0.004
TranAD0.6131 ± 0.0260.7847 ± 0.0160.3439 ± 0.0870.4712 ± 0.082
CAE-M0.5681 ± 0.0100.5885 ± 0.0060.9702 ± 0.0080.7326 ± 0.006
MUTANT0.7187 ± 0.0140.8227 ± 0.0100.7775 ± 0.0130.7994 ± 0.010
MEMTO0.7132 ± 0.0310.7733 ± 0.0290.6810 ± 0.0560.7231 ± 0.038
DTAAD0.5984 ± 0.0030.6069 ± 0.0020.9650 ± 0.0040.7451 ± 0.002
LFTSAD0.6259 ± 0.0080.7375 ± 0.0040.9507 ± 0.0030.8306 ± 0.004
TransDe0.5294 ± 0.0030.6957 ± 0.0070.6067 ± 0.0020.6482 ± 0.012
MSTUAD0.7243 ± 0.0110.8037 ± 0.0060.8896 ± 0.0150.8444 ± 0.009
Table 4. Dataset Information.
Table 4. Dataset Information.
DatasetDimensionsTrainTestAnomalies (%)
MSL55 (27)58,31773,72910.72
SMAP25 (55)135,183427,61713.13
SWaT51 (1)99,00089,98412.15
Table 5. Anomaly detection accuracy in terms of AUC, Pre, Rec and F1 on three datasets.
Table 5. Anomaly detection accuracy in terms of AUC, Pre, Rec and F1 on three datasets.
MethodMSLSMAPSWaT
AUCPreRecF1AUCPreRecF1AUCPreRecF1
IF0.52010.14520.13070.13760.48650.09760.07610.08550.81780.79960.65830.7221
LSTM-NDT0.63780.75850.28640.41580.74120.29880.73550.42490.83910.71970.71680.7182
GDN0.83550.76460.69620.72880.77590.84890.56650.67950.86190.97650.72630.8330
AGCSL0.89280.78310.81210.79730.77620.85480.56650.68140.57050.13880.99300.2435
OmniAnomaly0.95400.78200.93880.85330.77550.85000.56560.67920.87080.89590.75370.8187
MSCRED0.83620.74510.70060.72220.79130.83630.59970.69850.90260.49680.93640.6492
MTAD-GAT0.92300.74630.88130.80820.77620.85420.56660.68130.84460.97690.69140.8097
TranAD0.89140.56050.86230.67940.78220.89120.57480.69880.87660.58500.83510.6880
CAE-M0.69030.84040.38930.53210.77820.70870.59210.64520.94130.63990.95700.7669
MUTANT0.98800.88470.99680.93740.97530.98550.95310.96910.95940.95840.92690.9424
MEMTO0.97070.93250.94950.94090.97170.94930.95080.95010.94300.94010.89380.9164
DTAAD0.93780.56400.96340.71150.77820.91920.56380.69890.87960.98690.76060.8591
LFTSAD0.88810.91450.78540.84510.93150.94320.87070.90550.94000.94160.88760.9138
TransDe0.98910.92420.98820.95510.98990.93430.99000.96140.98270.92860.97560.9515
MSTUAD0.99020.93590.99140.96290.99090.97400.98660.98030.97170.95050.95350.9520
Table 6. Comparison of model complexity of different methods.
Table 6. Comparison of model complexity of different methods.
MethodParams (M)Train Time (s)F1 (%)
IF-0.1720.82
LSTM-NDT0.020425.5968.19
GDN0.0015260.4174.38
AGCSL0.0082137.4174.60
OmniAnomaly0.0149236.7173.35
MSCRED1.2374302.2271.08
MTAD-GAT0.1299351.3173.13
TranAD0.01066.1358.09
CAE-M0.0072146.2171.08
MUTANT0.065443478.25
MEMTO5.81697.8867.57
DTAAD0.00396.2474.65
LFTSAD0.0069212.1783.24
TransDe0.8271408.0264.82
MSTUAD4.0592292284.44
Note: The best results are highlighted in bold, and the second-best results are underlined.
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Sheng, W.; Jiang, H.; Pi, W.; Yang, Z.; Zhao, L. Multi-Scale Spatial–Temporal Graph Model for Unsupervised Anomaly Detection in the Wheat Flour Transportation Process. Foods 2026, 15, 2934. https://doi.org/10.3390/foods15162934

AMA Style

Sheng W, Jiang H, Pi W, Yang Z, Zhao L. Multi-Scale Spatial–Temporal Graph Model for Unsupervised Anomaly Detection in the Wheat Flour Transportation Process. Foods. 2026; 15(16):2934. https://doi.org/10.3390/foods15162934

Chicago/Turabian Style

Sheng, Wanbao, Huawei Jiang, Wenqiang Pi, Zhen Yang, and Like Zhao. 2026. "Multi-Scale Spatial–Temporal Graph Model for Unsupervised Anomaly Detection in the Wheat Flour Transportation Process" Foods 15, no. 16: 2934. https://doi.org/10.3390/foods15162934

APA Style

Sheng, W., Jiang, H., Pi, W., Yang, Z., & Zhao, L. (2026). Multi-Scale Spatial–Temporal Graph Model for Unsupervised Anomaly Detection in the Wheat Flour Transportation Process. Foods, 15(16), 2934. https://doi.org/10.3390/foods15162934

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop