Next Article in Journal
Cycle-Informed Triaxial Sensor for Smart and Sustainable Manufacturing
Previous Article in Journal
BGIR: A Low-Illumination Remote Sensing Image Restoration Algorithm with ZYNQ-Based Implementation
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Meta-Learning Task Relations for Ensemble-Based Temporal Domain Generalization in Sensor Data Forecasting

1
School of Computer Science and Technology, Dalian University of Technology, Dalian 116024, China
2
Key Laboratory of Social Computing and Cognitive Intelligence, Ministry of Education, Dalian 116024, China
3
School of Innovation and Entrepreneurship, Dalian University of Technology, Dalian 116024, China
*
Authors to whom correspondence should be addressed.
Sensors 2025, 25(14), 4434; https://doi.org/10.3390/s25144434
Submission received: 2 June 2025 / Revised: 4 July 2025 / Accepted: 15 July 2025 / Published: 16 July 2025
(This article belongs to the Section Intelligent Sensors)

Abstract

Temporal domain generalization is crucial for the temporal forecasting of sensor data due to the non-stationary and evolving nature of most sensor-generated time series. However, temporal dynamics vary in scale, semantics, and structure, leading to distribution shifts that a single model cannot easily generalize over. Additionally, conflicts between temporal domain-specific patterns and limited model capacity make it difficult to learn shared parameters that work universally. To address this challenge, we propose an ensemble learning framework that leverages multiple domain-specific models to improve temporal domain generalization for sensor data forecasting. We first segment the original sensor time series into distinct temporal tasks to better handle the distribution shifts inherent in sensor measurements. A meta-learning strategy is then applied to extract shared representations across these tasks. Specifically, during meta-training, a recurrent encoder combined with variational inference captures contextual information for each task, which is used to generate task-specific model parameters. Relationships among tasks are modeled via a self-attention mechanism. For each query, the prediction results are adaptively reweighted based on all previously learned models. At inference, predictions are directly generated through the learned ensemble mechanism without additional tuning. Extensive experiments on public sensor datasets demonstrate that our method significantly enhances the generalization performance in forecasting across unseen sensor segments.

1. Introduction

Sensor data forecasting plays a critical role in a wide range of real-world applications, serving as the foundation for intelligent decision-making and proactive system control. It has been widely adopted in diverse domains, including electricity consumption forecasting [1], traffic prediction [2], and weather forecasting [3]. Given the increasing scale, heterogeneity, and temporal dynamics of sensor data, developing robust forecasting models has become a fundamental challenge in the era of intelligent systems. Due to the non-stationary nature of the real-world streaming environment [4], the assumption that the data is independent and identically distributed (i.i.d.) cannot be satisfied [5]. This violation severely limits the generalization ability of traditional machine learning models, which tend to suffer significant performance degradation when confronted with temporal distribution shifts or previously unseen patterns.
To overcome these challenges, domain generalization (DG) techniques have been proposed to learn domain-invariant representations and forecasting models that maintain robustness across temporal domains [6,7,8], without requiring access to data from future tasks or environments during training. Existing approaches to temporal domain generalization typically rely on either data augmentation strategies—such as constructing diverse training environments to simulate distributional variations [9]—or domain-agnostic representation learning techniques aimed at extracting invariant features [10]. However, these methods often learn a single forecasting model. In practice, the evolving and dynamic characteristics of sensor data introduce both marginal and conditional distribution changes over time, making it difficult for a single, capacity-limited model trained on historical data to maintain effectiveness in future scenarios.
As highlighted in the model DRAIN [8], effective temporal forecasting not only requires that the data dynamics are modeled, but also requires the dynamic= adaptation of the forecasting model itself over time. DRAIN addresses this by using a Long Short-Term Memory (LSTM) network [11] to capture model dynamics and generate task-specific parameters for future prediction. Although this strategy leads to improved performance, it still suffers from limitations in capturing long-range dependencies and may underperform when historical dynamics exert delayed or accumulated influences. Furthermore, due to the non-stationary nature of temporal data, the distribution of model dynamics itself evolves over time, making it difficult for a single model to generalize across diverse and shifting forecasting tasks. This challenge motivates the use of ensemble-based strategies, where multiple specialized models can be integrated to cover a broader spectrum of temporal variations. Such ensemble learning approaches have demonstrated their effectiveness in various domains, as evidenced by Exemplar-SVMs [12], GMOE [13], and D 3 G [14], highlighting their potential to enhance generalization by leveraging model diversity.
In this paper, we focus on the challenging problem of sensor data forecasting under temporal domain shifts. Unlike prior approaches that rely on fixed weighting schemes [12] or data-driven weight calculation based on auxiliary meta data [14], we propose METDG, a novel framework that automatically models the dynamic relationships among domain-specific forecasting models tailored to non-stationary sensor environments. Specifically, when given a time series from sensor data, we first partition it into semantically meaningful temporal segments—such as weeks, months, quarters, or years—based on domain knowledge or expert heuristics. These segments are treated as distinct tasks to reflect potential distributional shifts over time. To capture commonalities and distinctions across tasks, we adopt a meta-learning strategy that learns to generalize from shared temporal patterns. During the meta-training stage, we introduce a variational inference network to encode the support set of each task into a rich contextual representation. This embedding captures the underlying task-specific dynamics and is fed into a lightweight decoder (e.g., MLP) to generate the parameters of the forecasting model for that task. Importantly, to uncover global inter-task relationships, we leverage a Transformer-based encoder [15] to model the long-range dependencies among tasks and generate relationship-aware model parameters. In the inference phase, each sample from the query set is evaluated using all task-specific models in an ensemble manner, enabling the system to adaptively integrate multiple temporal perspectives for robust prediction. This design allows the model ensemble to dynamically respond to evolving sensor data characteristics, thereby enhancing generalization across unseen temporal domains. Our main contributions are listed as follows:
  • We propose METDG, a novel ensemble-based meta-learning framework that segments sensor time series into semantically meaningful tasks and learns task-specific forecasting models via variational inference. A Transformer-based encoder is further leveraged to capture long-range inter-task relationships and generate relationship-aware model parameters.
  • We design an adaptive ensemble inference mechanism that evaluates each query using all task-specific models, enabling the dynamic integration of temporal perspectives.
  • We conduct extensive experiments on different real-world temporal forecasting tasks to show that our method outperforms state-of-the-art time series prediction methods and temporal domain generalization methods.

2. Related Work

Time Series Forecasting. Time series forecasting refers to predicting future changes based on historical data. Early researchers used statistical learning methods for forecasting, such as exponential smoothing and ARIMA models [16], Kalman Filter [17], and Linear State-Space models  [18]. With the advent of deep learning techniques, deep neural networks have increasingly been utilized for time series forecasting, owing to their exceptional ability to model complex nonlinear relationships. To capture the dependencies between time steps, researchers introduced recurrent neural network (RNN) methods, e.g., the Long Short-Term Memory network (LSTM) and Gated Recurrent Unit network (GRU), and Autoregressive Recurrent Neural Network methods, e.g., DeepAR [19]. For example, Salinas et al. [19] proposed an autoregressive recurrent neural network for probabilistic forecasting. In recent years, with the tremendous success of the Transformer model [15] in capturing global temporal patterns, researchers have also incorporated them into time series forecasting tasks, proposing algorithms such as Informer [1], FEDformer [20], Non-Stationary Transformer [21], DLiner [22], and Timer [23]. For instance, given the non-stationary nature of many time series (e.g., sensor data), Liu et al. proposed a non-stationary Transformer to mitigate the over-stationarization issue in forecasting tasks. The experimental results on sensor datasets such as Electricity and Traffic validate the effectiveness of the proposed model; Liu et al. [23] also developed a foundation model tailored for general-purpose time series modeling. In addition, multivariate times series prediction methods have also been focusing on variable relationship modeling, together with forecasting [3,24]. For instance, Cai et al. [3] proposed learning multi-scale inter-series correlations for multivariate time series forecasting. Despite recent advances, time series forecasting remains vulnerable to distribution drift, which poses a major challenge to model generalization and robustness across varying temporal domains [25,26]. In addition, recent works have begun to exploit graph structures to model complex dependencies in forecasting. For example, Yang et al. [27] proposed DEST-GNN, a double-explored spatio-temporal GNN for multi-site intra-hour photovoltaic (PV) power forecasting. Similarly, Fu et al. [28] introduced SDR-GNN, which constructs an utterance-level interaction graph in conversational data and uses spectral-domain reconstruction (multi-frequency aggregation) to recover incomplete multimodal features for emotion recognition. Hou et al. [29] further developed a parallel multi-scale dynamic GNN (PMEDGN) that learns dynamic graph structures at multiple time resolutions in parallel, capturing evolving inter-variable interactions in multivariate time series forecasting. These dynamic graph-based approaches suggest that incorporating graph neural network structures is beneficial for modeling the spatial relationships between sensors in time series forecasting tasks.
Temporal Domain Generalization. Typical machine learning methods assume that the training data and test data follow the same probability distribution. However, the non-stationary nature of sensor data violates the i.i.d. assumption [21,30]. Domain generalization learning aims to learn robust models without using test domain data, making it appropriate for future time series inference. Therefore, temporal domain generalization has attracted researchers’ attention. In general, these methods can be grouped into three categories [8]. First, data manipulation [9], which builds complex data training environments via data generation or data augmentation. Second, representation learning [10], which aims to learn domain-invariant representations via feature alignment or invariant risk minimization. For instance, Fan et al. [10] proposed to separately learn the distribution of input and output space, which would naturally capture the distribution difference of the two spaces. Third, learning strategy [6,8], which focuses on exploiting the ensemble learning strategy [6], meta-learning strategy [6,31,32], and gradient interpolation strategy [7]. For example, Li et al. [6] introduced a lifelong learning mechanism in sequential domain generalization, while Bai et al. [8] proposed using a sequential model to adaptively learn the temporal drift and leverage the learned sequential pattern to predict the model status in the future domain. However, existing methods either use a single model or employ multiple models, without considering the global dynamic relationships between models or assigning appropriate weights.

3. Methodology

3.1. Problem Formulation

In a sensor data forecasting task, we are provided with historical multivariate time series data, denoted as X R H × N , where H is the length of the historical window and N is the number of sensor channels. The objective is to learn a model that accurately predicts the future sensor readings Y R F × N over the following F time steps. However, sensor data in real-world applications often exhibit temporal distribution shifts, where the underlying data distribution changes over time. These evolving patterns violate the stationary assumption commonly made by standard forecasting models, resulting in a degraded performance when deployed in unseen or shifted temporal domains. Our goal is to develop a forecasting model that is robust to such distributional shifts, thereby maintaining low prediction error on test data drawn from future, potentially shifted time periods.
During the training process, we divide the historical training data into T different segments (i.e., domains) D 1 , D 2 , , D T , where each segment (i.e., domain) contains n samples D t = { ( X i , Y i ) } i = 1 n . We assume that the data within each domain follow the same distribution, while the distributions differ across domains. For each domain t, a neural network model g Φ t can be learned by minimizing the loss function i = 1 n l ( g Φ t ( X i ) , Y i ) , where Φ t represents the parameters of the neural network. Our objective is to generate model parameters for a new, unseen domain D T + 1 based on the data from the existing domains D 1 , D 2 , , D T , such that the empirical risk for D T + 1 is minimized.

3.2. Model Architecture

In this section, we present the architecture of our proposed METDG model. To effectively capture temporal domain-specific characteristics and enhance the model’s generalization capability across temporally shifting distributions, we adopt a Bayesian meta-learning framework. Unlike conventional meta-learning approaches that learn deterministic task-specific representations, Bayesian meta-learning [33] models the uncertainty and variability across tasks (i.e., domains) by learning a distribution over model parameters. This probabilistic formulation allows the model to better adapt to new, unseen domains by leveraging prior knowledge while accounting for domain-specific deviations. In our context, each domain corresponds to a time segment of sensor data with distinct temporal patterns; thus, modeling such domain-level uncertainty is crucial for robust forecasting under distributional shifts.
Following the Bayesian meta-learning framework, our approach consists of two main stages: meta-training and meta-testing. For each domain D t , we partition the data into a support set D t S u and a query set D t Q u , i.e., D t = { D t S u , D t Q u } . In the meta-training phase, our goal is to train an encoder to extract representations of the domains. In the meta-testing phase, we use the extracted representations to generate neural network parameters corresponding to each domain, and evaluate them using meta-testing data, calculate the loss, and perform backpropagation to train the parameters of the encoder and decoder. Assuming that P ( D t ) is the probability density function associated with D t , the process of meta-learning can be formally expressed as follows:
a r g m i n θ t = 1 T E ( l ( g Φ t ( X t Q u ) , Y t Q u ) ) , Φ t = f θ ( D t S u )
where f θ represents the encoder parameterized by θ , which extracts domain representations from the support set, and g Φ t represents the inference network parameterized by Φ t . According to the theory of Bayeasin meta-learning, it is assumed that each domain has a latent variable z , which represents the domain and leads to variation in domain distribution. By learning a representation of this latent variable, we can effectively model the distributional differences among domains, thereby enhancing the model’s adaptability and generalization abilities. To infer the latent variable z , we utilize the support set of each domain as contextual input. Specifically, an encoder network processes the support set to approximate the posterior distribution over z , capturing rich domain-specific information. This latent representation is then passed through a decoder, which generates the parameters for a domain-specific inference network. Finally, the query input X from the same domain is fed into the generated inference network to produce prediction Y. This entire process can be naturally formulated within a probabilistic framework, where both the uncertainty in domain representations and the domain-specific adaptation are explicitly modeled.
The probabilistic formulation of this process is provided as follows:
P ( D 1 : T S u , X 1 : T , Y 1 : T , z 1 : T , Φ 1 : T ) = P ( D 1 : T S u , z 1 : T ) P ( X 1 : T , Y 1 : T , Φ 1 : T | D 1 : T S u , z 1 : T ) .
In summary, the architecture of our model can be conceptually divided into two main components: (1) domain representation learning and (2) parameter generation for domain-specific inference networks. In the first stage, we extract domain-specific representations from the support set. Specifically, the input time series from each support set is processed by a diffusion convolutional GRU-based encoder, which captures both temporal dependencies and spatial correlations among sensors. Note that the encoder can also employ GRU or LSTM for sensor prediction tasks where there are no spatial dependencies among sensors. To further model inter-domain dependencies, a self-attention mechanism is employed over the encoded features, enabling the model to learn rich and informative domain relationships. This results in a set of contextualized domain representations that reflect both intra-domain characteristics and cross-domain interactions. In the second stage, these domain representations are passed through a lightweight decoder to generate the parameters of a domain-specific inference network. This inference network is instantiated using the decoded parameters and then applied to the query set: it takes input X and produces predictions Y tailored to the specific domain characteristics. This two-stage design allows the model to dynamically adapt to unseen domains by leveraging learned cross-domain knowledge and ensures robust forecasting performance under temporal distribution shifts.
The overall framework is illustrated in Figure 1. In the following sections, we provide a detailed description of the core modules of our model: the GRU-based encoder and the self-attention mechanism for learning relational domain representations, and the inference network for generating domain-specific parameters.

3.2.1. DCGRU-Based Encoder

In the first component of our formulation, the objective is to extract domain-specific feature representations from the support set data, denoted as P ( z 1 : T | D 1 : T S u ) . To achieve this, we adopt the diffusion convolutional gated recurrent unit (DCGRU) architecture, following the approach of Liu et al. [24]. DCGRU is designed to effectively model both the temporal and spatial dependencies inherent in the sensor data of each domain. Specifically, it integrates diffusion convolution to capture the spatial correlations among sensors, and employs the Gated Recurrent Unit (GRU) to model temporal dynamics. This hybrid architecture enables the encoder to produce expressive and informative representation vectors for each domain. The operations of DCGRU are defined as follows:
R t = s i g m o i d ( W R A [ X t | | H t 1 ] + b R ) , C t = t a n h ( W C A [ X t | | R t H t 1 ] + b C ) , U t = s i g m o i d ( W U A [ X t | | H t 1 ] + b U ) , H t = U t H t 1 + ( 1 U t ) C t ,
where A is the adjacency matrix representing the connectivity between sensors. The graph convolution is computed as follows:
W Q A X = Σ k = 0 K ( w k , 1 Q ( D O 1 A ) k + w k , 2 Q ( D I 1 A ) k ) X ,
where D O 1 and D I 1 are the out-degree and in-degree matrices, respectively, and w k , 1 Q and w k , 2 Q are the trainable model parameters. The diffusion feature K is a hyperparameter.
For each domain, the encoder sequentially takes support set data D t S u as inputs, and outputs the distribution of the domain representation. Here, we assume that the data from all domains follow a normal distribution. The optimization process of the encoder can be carried out using the variational inference method. This approach is particularly suitable for extracting features from different domains. By introducing a domain-level latent variable and inferring its posterior from observed data, variational inference provides a principled way to capture cross-domain variability. In contrast, other probabilistic approaches, such as Bayesian neural networks, primarily model parameter uncertainty and lack an explicit mechanism to represent domain-specific structure. Therefore, variational inference is adopted to model uncertainty at the representation level, which better aligns with the objectives of our meta-learning framework. According to the theory of variational inference, the posterior distribution q ( z 1 : T | D 1 : T S u ) has the following variational lower bound(ELBO):
L t v a r = E [ l o g p ( D t S u | z t ) ] D K L ( q ( z t | D t S u ) | | p ( z t ) )
where p ( D t S u | z t ) represents the reconstruction of D t S u , and p ( z t ) denotes the prior distribution, which is assumed to be a standard normal distribution. D K L ( · | | · ) means the KL divergence between the posterior distribution and the prior distribution.
It is worth noting that, during training, the data is first partitioned into T distinct domains in chronological order. For feature extraction, an encoder with shared parameters is applied concurrently across all domains. In other words, the feature distributions for all domains are extracted simultaneously. To incorporate stochasticity into the domain generalization process, the encoder does not directly output domain representations. Instead, after the support set passes through two DCGRU layers, the resulting features are fed into a fully connected layer that produces the mean and log-variance of a Gaussian distribution. The representation for each domain is then obtained through sampling from its corresponding distribution.

3.2.2. Domain Relation Modeling

After extracting features from the T domains using a shared encoder, a self-attention mechanism is employed to model inter-domain relationships, thereby enabling dynamic domain generalization. Let Z = { z 1 , z 2 , , z T } denote the representations of the T training domains, where each z t is a k-dimensional tensor. The process of modeling domain relationships is described as follows:
First, positional embeddings are applied to incorporate temporal or sequential information:
Z = Z P .
It is important to note that a fixed absolute positional encoding scheme is adopted. For each representation vector z t , the corresponding positional encoding vector is defined as follows:
p t , 2 i = s i n ( k / 10000 2 i d ) , p t , 2 i + 1 = c o s ( k / 10000 2 i + 1 d ) .
After obtaining the positional embeddings, the matrix Z is projected through three learnable weight matrices— W Q , W K , and W V —to generate the query, key, and value embeddings Q , K , and V , respectively:
Q = Z W Q , K = Z W K , V = Z W V .
Next, the self-attention mechanism is applied to Q , K , and V to compute attention scores and aggregate information, resulting in the following domain relation representations:
Z = S A ( Q , K , V ) = s o f t m a x ( QK T d q ) V .
Since the encoder outputs distributions over domain representations, sampling must be performed from these distributions before feeding them into the self-attention layer. The domain relation modeling process can be formally defined as follows:
z t = s = 1 T d s , t z t s = 1 T d s , t , z t = f ( D t S u ) .
The self-attention mechanism plays a central role in modeling the global dynamic relationships between domains. Specifically, it allows each domain representation to attend to all other domains in the input sequence, regardless of their temporal proximity. By computing pairwise attention scores based on learned similarities, the model is able to capture long-range dependencies and latent correlations across domains. This enables it to dynamically weigh the influence of each domain when generating the task-specific representation, thus reflecting broader temporal trends, recurrent patterns, or shared dynamics.

3.2.3. Decoder and Inference Network

After obtaining the related domain representations, they are passed into a decoder to generate the corresponding parameters for each domain. These parameters are then used to instantiate an inference network for each domain. In this work, a two-layer multilayer perceptron (MLP) is adopted as the inference network. The query set data is subsequently fed into the respective inference networks to produce the prediction results, followed by the computation of the supervised loss:
L t s u p = M S E ( g Φ t ( X t Q u ) , Y t Q u ) ,
where g Φ t denotes the inference network parameterized by Φ t , and X t Q u and Y t Q u represent the input features and corresponding labels of the query set for domain t, respectively.
To achieve effective training, we aim to minimize the supervised loss while simultaneously maximizing the variational lower bound. By combining these two objectives, the overall loss function used during optimization is defined as follows:
L = t = 1 T ( L t s u p + λ L t v a r ) ,
where λ is used to balance supervised loss and variational loss.

3.3. Model Training and Testing Process

In this section, we present the training and testing procedures of METDG. The overall workflow of the proposed model consists of two main stages: training and testing. During the training stage, the model learns transferable knowledge from multiple known domains by encoding their support sets, modeling inter-domain relationships via self-attention, and using a decoder to generate domain-specific inference networks. The model is optimized by computing prediction losses on query sets across domains. During the testing stage, the model uses the support set of an unseen domain to generate its representation, reweight it using stored training domain representations, and constructs an inference network for final prediction on the test query set.
During the training stage, we empirically divide the training data into T distinct domains. Each domain’s data is further split into a support set and query set. The support set from each domain is sequentially fed into the encoder to produce a distribution over domain representations. We then sample the representations from these distributions and apply a self-attention mechanism to model the relationships among the domains. The resulting representations are passed through a decoder, which generates the parameters required to instantiate the domain-specific inference networks. Specifically, we use a multi-layer perceptron (MLP) as the inference network architecture. The query set is then fed into the corresponding inference network to produce predictions Y ^ 1 : T . For each domain, we compute the loss using Equation (11), sum the losses across all domains to obtain the total training loss, and update model parameters via backpropagation. After training, we store the learned representations of all domains for use during the testing phase. The complete training procedure is summarized in Algorithm 1.
Algorithm 1 Training Procedure
Require: Training domain data D 1 ,…, D T , meta split ratio ζ , learning rate η , initialized
      encoder f θ
      Initialize all learnable parameters
      Split { D t } t = 1 T into D t S u and D t Q u using split ratio ζ
      while not converge do
           for { ( X , Y , t ) } t = 1 T in { D t Q u } t = 1 T do
               for t = 0 to T do
                    Sample z t q ( z t | D t S u , θ )
                    Compute log likelihood using Equation (2)
               end for
                Z = S A ( Z )
                { Φ t } t = 0 T = F ( z t )
                { Y ^ t } t = 1 T = { g Φ t ( X t ) } t = 1 T
           end for
           Calculate supervised loss L t s u p and Consistency loss L t v a r with { Y ^ t } t = 1 T and { ( Y t ) } t = 0 T
            L = L t s u p + λ L t v a r
           Update learnable parameters with learning rate η
      end while
During the testing stage, the unseen test domain is similarly divided into a support set and query set. The support set is used to generate the representation of the test domain. Subsequently, a self-attention mechanism is employed to extract relevant information by attending to the saved training domain representations. Using the updated test domain representation, the decoder generates parameters to instantiate the corresponding inference network. The query set is then fed into this inference network to produce the final prediction results. The complete testing procedure is outlined in Algorithm 2.
Algorithm 2 Testing Procedure
Require: Training domain representation z 1 ,…, z T ,Testing domain data D T + 1 , meta split
      ratio ζ
      Split D T + 1 into D T + 1 S u and D T + 1 Q u using split ratio ζ
      Sample z T + 1 q ( z T + 1 | D T + 1 S u , θ )
       z T + 1 = S A ( z 1 : T , z T + 1 )
       Φ T + 1 = F ( z T + 1 )
      for each example ( X , Y ) in D T + 1 Q u  do
            Y ^ T + 1 = g Φ T + 1 ( X T + 1 )
           Calculate MSE loss with Y ^ and Y
      end for

4. Theoretical Analysis

In this section, we present a theoretical analysis of the proposed network, focusing on its ability to mitigate domain shifts by extracting domain representations and modeling inter-domain relationships.
Definition 1.
To facilitate the theoretical derivation, we represent the proposed neural network using formal mathematical notation. Let f θ denote the encoder as f θ , with S A representing the self-attention mechanism, h representing the decoding network, and g representing the inference network. For any data ( X , Y ) in the query set of domain t, the prediction process can be formally represented by Equation (1). The self-attention mechanism can be interpreted as a weighted aggregation operation. Accordingly, the parameters of the inference network for domain t can be expressed as follows:
Φ t = s = 1 T d s , t Φ t s = 1 T d s , t ,
where d s , t represents the similarity between domain s and t.
Definition 2.
We begin by assuming that the model has been fully trained on domains 1 through T. For the unseen test domain T + 1 , we employ a meta-learning strategy to extract its domain representation and apply the self-attention mechanism to integrate information from the previously seen domains. This process yields the inference network g Φ T + 1 for domain T + 1 . Given the ground-truth labels Y T + 1 , we define the predictive or generalization error as e r r : = l ( g Φ T + 1 ( X t + 1 ) , Y t + 1 ) , where l ( . ) denotes the loss function used for evaluation.
Definition 3.
To illustrate the impact of meta-learning on domain generalization, we introduce a comparison model. This model is trained on domains 1 through T; however, during testing on the unseen domain T + 1 , it does not utilize the support set D T + 1 s u to generate domain representations. Instead, it relies on the support set from the last training domain D T s u to construct the inference network, which is denoted as g Φ T .
Theorem 1.
Following the prior works of Bai et al. [8], we assume g Φ T + 1 has a Lipschitz constant with upper bound L upper and lower bound L lower ; then, we have
e r r ( g Φ T + 1 ) < e r r ( g Φ T ) .
To prove the above theory, we use q θ to represent the encoder parameterized by θ, and P ( Φ 1 : T | D 1 : T S u ) to denote the ideal posterior distribution. The process of optimizing the encoder can be seen as minimizing the gap between q and P, expressed as follows:
a r g m i n θ D K L ( q θ | | P ( Φ 1 : T | D 1 : T S u ) ) .
We assume that, initially, the encoder parameters are θ 0 , and, after optimization, the parameters become θ , while the ideal parameters are denoted as θ * . We can assume that the optimized parameters are closer to the ideal parameters compared to the initial parameters, i.e.,
| | q θ ( D T + 1 S u ) q θ * ( D T + 1 S u ) | | < | | q θ 0 ( D T + 1 S u ) q θ * ( D T + 1 S u ) | | .
Assuming Lipschitz continuity, let Φ * denote the parameters of the ideal inference network. Then, the inference network satisfies the following property:
| | g Φ T ( X ) g Φ * ( X ) | | > L l o w e r · | | Φ T Φ * | | , | | g Φ T + 1 ( X ) g Φ * ( X ) | | < L u p p e r · | | Φ T + 1 Φ * | | .
Based on Equation (14), we can assume that Φ T + 1 is closer to the ideal parameters than Φ T . Therefore, we have | | Φ T + 1 Φ * | | < | | Φ T Φ * | | . Moreover, since upper bound L u p p e r is greater than lower bound L l o w e r , we have the following:
L u p p e r L l o w e r · | | Φ T + 1 Φ * | | | | Φ T Φ * | | < 1 .
Based on the above formulas, we have | | g Φ T + 1 ( X ) g Φ * ( X ) | | < | | g Φ T ( X ) g Φ * ( X ) | | . Since g Φ * ( X ) represents the optimal inference network, it follows that the model leveraging D T + 1 S u as the support set outperforms the model that relies on D T S u as the support set [8].
Definition 4.
Our proposed method helps improve the domain generalization capability of the model. For a domain t that has not been seen during the training process, we aim to minimize the loss between the outputs of the inference model g Φ t parameterized by Φ t and the true values. In addition, if the domain t is known, we can use traditional empirical risk minimization methods to train an inference model g Φ ^ t with parameter Φ ^ t . The closer Φ t is to Φ ^ t , the better the performance of g Φ t is. Here, we assume that the domain relationship extraction module has been fully trained, such that E [ ( g Φ t ( x ) g Φ ^ t ( x ) 2 ] = O ( C ( H ) n d ) , where C ( H ) is the Rademacher complexity of the function class H [14]. Then, we have the following theorem:
Theorem 2.
Suppose the number of meta-testing data for training domain d is n d . If the loss function is Lipschitz continuous, then for the unseen test domain T + 1 , the excess risk satisfies [14]:
E ( x , y ) P T + 1 [ L g Φ T + 1 ( x ) , y ] E ( x , y ) P T + 1 L g Φ ^ T + 1 ( x ) , y B + C H / n N t r B r ,
where N t r represents the number of training domains. Theorem 2 suggests that during the training phase, increasing the number of domains improves the performance of g Φ T + 1 ( x ) .

5. Experimental Evaluation

5.1. Datasets Descriptions

To evaluate the performance of our model on time series prediction of sensor data, we conducted experiments on three traffic sensor datasets: PEMS04, PEMS07, and PEMS08 (The traffic sensor datasets provided by the authors of STID, https://drive.google.com/drive/folders/14EJVODCU48fGK0FkyeVom_9lETh80Yjp (accessed on 14 July 2025)). These datasets contain traffic flow data collected from California highways, with multiple sensors recording data every 5 min. PEMS04 includes 307 sensors over 59 days, PEMS07 includes 883 sensors over 98 days, and PEMS08 includes 170 sensors over 61 days. Each dataset also provides a graph representing the connectivity between sensor locations. For each dataset, we used the past 60 min of data (corresponding to a sequence length of 12 time steps) to predict traffic flow for the next 15, 30, and 60 min, which correspond to prediction horizons of 3, 6, and 12 time steps, respectively. We assumed that data collected within each day share the same distribution. Each dataset was split into training, validation, and test sets with proportions of 60%, 20%, and 20%, respectively.
The sensors in the above three datasets have spatial relationships. To evaluate the performance of our method on sensors without spatial relationships, we conducted experiments on the ETTh1, ETTh2 and Weather datasets (The time series datasets provided by the authors of DLinear, https://drive.google.com/drive/folders/1ZOYpTUa82_jCcxIdTmyr0LXQfvaM9vIy (accessed on 14 July 2025)). The ETTh1 and ETTh2 datasets monitor the operation of electrical transformers in a province in China, with a sampling frequency of one hour. Each data point includes the target variable “oil temperature” along with six electrical load features. The Weather dataset contains data collected from the Max Planck Institute for Biogeochemistry (Jena, Germany), including 21 meteorological parameters such as air temperature, humidity, and pressure. For each dataset, we used 96 time steps as input to predict the next 96, 192, 336, 720 time steps. Each dataset was split into training, validation, and test sets, with proportions of 60%, 20%, and 20%.

5.2. Baselines

For the traffic sensor datasets, we included two traditional statistical forecasting methods as baselines: HI (Historical Inertia) [34], which directly uses the most recent observation as the prediction, and VAR (Vector AutoRegression) [35], a classical multivariate time series model that captures linear dependencies among sensor nodes over time. In addition, we selected six state-of-the-art models for comparison: DCRNN [24], which uses a bidirectional diffusion process for the first time to capture spatial relationships between sensors; DGCRN [36], which employs a generated hypergraph to represent sensor connections; STID [37], which uses an MLP-based approach to embed spatiotemporal information into vectors for prediction; STAEformer [38], which utilizes a transformer to encode time series data; and GMMLP [39], which leverages a memory network to retain temporal sequence information.
For sensor datasets without spatial relationships, we also included HI and VAR as traditional baselines, and we further selected six state-of-the-art models for comparison in the field of time series forecasting: DRAIN [8], a temporal domain generalization method; MSGNet [3], which leverages frequency domain analysis and adaptive graph convolution; TimesNet [40], based on periodic decomposition; DLinear [22], which employs linear layers; and FEDformer [20] and Informer [1], both Transformer-based architectures.

5.3. Implementation Details

We used the Adam optimizer to train our model. During both training and testing, the batch size was set to 32, and the learning rate was set to 0.001. All models were trained for a maximum of 100 epochs, with early stopping applied if validation loss did not improve for 10 consecutive epochs. For the DCGRU-based encoder, we followed the setup by Li [24], using a two-layer GRU structure with 64 units per layer. The maximum diffusion steps K were set to 3. For the LSTM-based encoder used with non-spatial structured datasets, we used a two-layer LSTM structure with 64 units per layer. The latent domain representation z was set to a 64-dimensional vector. The self-attention module used for modeling inter-domain relationships was implemented as a Transformer encoder with two layers and two attention heads per layer. After passing through the self-attention mechanism, the decoder generates outputs through a multilayer perceptron (MLP) consisting of two layers. Furthermore, the parameter λ in the loss function was set to 0.1. For evaluation, we reported the average results across five runs using different random seeds. All experiments were conducted on an NVIDIA 24GB 4090D GPU (Nvidia, Santa Clara, CA, USA).

5.4. Results and Analysis

Prediction Results. Table 1 summarizes the performance of our method compared to other approaches across the three datasets. We evaluated using three metrics: MAE, RMSE, and MAPE. The best results for each metric are highlighted in bold. The results show that our model outperforms the latest state-of-the-art method, GMMLP, on the PEMS07 and PEMS08 datasets. On the PEMS04 dataset, our model achieved the best performance for prediction horizons of 3 and 6 time steps, though it was slightly outperformed by previous models at the 12-step horizon.
We present the forecasting results using the traffic dataset in Figure 2 to showcase the overall predictive performance of our model. It can be seen that our method effectively captures both the global trend and local fluctuations in the time series, outperforming the baseline model. In addition, to emphasize the robustness of the model under non-stationary conditions, we provide a zoomed-in view of a segment for Sensor 443 in the PEMS07 dataset with rapid changes. As shown in Figure 3, our model exhibits stronger adaptability to sudden variations, providing more accurate predictions, whereas the baseline model tends to oversmooth the outputs.
Table 2 shows the performance of our method on three sensor datasets without spatial relationships. We used MSE and MAE as evaluation metrics. The best results for each metric are highlighted in bold. As can be seen, on the Weather dataset, our method achieves the best performance for 96-step and 192-step forecasting, while MSGNet outperforms it at 336 and 720 steps. On the ETTh1 dataset, our method achieves the best results at 96, 192, and 336 steps, but is outperformed by MSGNet at 720 steps. On the ETTh2 dataset, our method achieves the best performance across all metrics.
Model Parameter Relationship Analysis. To validate the effectiveness of our proposed method in capturing domain relationships, we conducted experiments on the PEMS04 dataset. First, domain representations were extracted using the encoder, resulting in domain representation vectors. Next, domain relationships were modeled using a self-attention mechanism to produce domain relationship vectors. These vectors were then reduced to two dimensions via the t-SNE algorithm and visualized on a two-dimensional plane. A comparison of the domain relationship distributions is shown in Figure 4. Notably, the distribution of domain representations changes markedly after incorporating the domain relationship weighting. Prior to applying the self-attention mechanism, the representation vectors were dispersed relatively evenly across the plane. After modeling the domain relationships, the vectors exhibited clear clustering patterns. This demonstrates that the self-attention mechanism effectively captures and models relationships between domains, grouping together domains with similar characteristics.
Ablation Study. To validate the effectiveness of our proposed method, we conducted ablation experiments on the PEMS04 dataset. The key innovations of our approach lie in modeling domain relationships via the self-attention mechanism and extracting domain representations using variational inference. To assess the impact of these components, we performed ablation by selectively removing them from the model. The experimental configurations are as follows:
  • w/o Attention: This variant excludes the self-attention mechanism. Domain features are first extracted using the DCGRU-based encoder, but the relationships between domains are not modeled with self-attention. Instead, the representation of each domain is directly used to generate the parameters of the corresponding inference network.
  • w/o Variation: This variant omits variational inference. During training, the variational lower bound is not employed as a loss term to regularize the domain representation generation process.
  • w/o Attention +V ariation: In this variant, both the self-attention mechanism and variational inference are removed. The inference network parameters are generated directly from domain representations, and the variational lower bound is excluded from the loss function.
The ablation experiment results, shown in Figure 5, demonstrate that removing the self-attention mechanism and the variational lower bound significantly degrades model performance across all evaluation metrics—MAE, RMSE, and MAPE. The self-attention mechanism effectively captures similarity relationships between domains, enabling the inference network parameters to leverage information from related domains. Meanwhile, the variational lower bound acts as a constraint during domain representation generation, ensuring that the learned representations more accurately correspond to their respective domains.
Hyper-Parameters Analysis. In our work, there is a fundamental assumption that the data within the same time segment follow the same distribution and the domain division is performed manually based on empirical knowledge or some predefined rules. To investigate the impact of different division ways on the results, we conducted experiments on both a traffic sensor datasets and a sensor datasets without an explicit graph structure. For the traffic datasets, the domains were divided by half a day, one day, three days, and one week. For the ETTh1, ETTh2, and Weather datasets, we segmented the domains on bi-weekly, monthly, quarterly, and half-yearly scales. The experimental results are shown on the left and right sides of Figure 6, respectively.
As shown in the figure, dividing each day into a separate domain achieved the best performance for the three traffic sensor datasets. For the ETTh1 and ETTh2 datasets, dividing the data by quarters yielded the best results, while for the Weather dataset, monthly segmentation was more effective. If the segmentation span is too small, it can lead to overfitting; if the span is too large, the data distribution within the segments may differ significantly, which can also degrade the model’s performance.
In addition, we examine how the number of layers in the inference model affects performance. We selected the PEMS04 and ETTh2 dataset, and set the number of layers in the inference network between one and five. The MAE curves are shown in Figure 7. As can be seen, for both datasets, setting the inference network to two layers yielded the best results. If the number of layers is too small, the network cannot effectively extract information from historical data. If the number of layers is too large, the randomness in parameter generation increases the inference network’s error, thereby reducing its inference capability.
Finally, we conducted a set of controlled experiments on the PEMS04 dataset to analyze the impact of two key hyperparameters in our model: the number of attention heads and the number of Transformer encoder layers. The results are summarized in Figure 8. As shown in the left subfigure, setting the number of attention heads to two achieved the best forecasting performance. This can be attributed to the fact that two heads strike a balance between expressiveness and stability. One head may be insufficient to capture diverse inter-domain patterns, while using too many heads introduces redundancy and noise, potentially leading to overfitting or unstable training. Similarly, the right-hand side of the figure shows that setting the Transformer encoder depth to two layers yields the best results. A shallow encoder (e.g., one layer) may fail to model the complex dependencies among temporal domains, whereas deeper encoders tend to suffer from performance degradation due to overfitting or vanishing gradients, especially when the number of tasks is limited. These findings validate that a lightweight attention mechanism with moderate complexity is optimal for capturing global task relationships within our temporal domain generalization framework.

6. Conclusions

In this paper, we introduced METDG, an ensemble-based method for temporal domain generation focused on time series forecasting tasks. Our approach utilizes a meta-learning mechanism to capture diverse task contexts and generate task-specific model parameters. Additionally, it employs Transformers to automatically extract the relationships between tasks and adjust model parameters while accounting for the global temporal dynamics of the models. We evaluated the effectiveness of METDG across various datasets and consistently observed that it outperforms existing methods. One limitation is that the selection of segment lengths is based on predefined rules or empirical experience. In the future, we aim to introduce adaptive learning strategies, for example, those based on frequency characteristics.

Author Contributions

Conceptualization, L.Z.; methodology, L.Z. and J.L.; software, J.L.; validation, B.J.; formal analysis, L.Z. and X.W.; investigation, J.L.; data curation, J.L.; writing—original draft preparation, L.Z. and J.L.; writing—review and editing, B.J. and X.W.; visualization, J.L.; supervision, B.J. and X.W. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by National Natural Science Foundation of China No. 62202085 and the Fundamental Research Funds for the Central Universities (No. DUT23RC(3)063).

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

The data that support the findings of this study come from public resources.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Zhou, H.; Zhang, S.; Peng, J.; Zhang, S.; Li, J.; Xiong, H.; Zhang, W. Informer: Beyond efficient transformer for long sequence time-series forecasting. In Proceedings of the AAAI Conference on Artificial Intelligence, Virtually, 2–9 February 2021; Volume 35, pp. 11106–11115. [Google Scholar]
  2. Liu, M.; Zhu, T.; Ye, J.; Meng, Q.; Sun, L.; Du, B. Spatio-temporal autoencoder for traffic flow prediction. IEEE Trans. Intell. Transp. Syst. 2023, 24, 5516–5526. [Google Scholar] [CrossRef]
  3. Cai, W.; Liang, Y.; Liu, X.; Feng, J.; Wu, Y. Msgnet: Learning multi-scale inter-series correlations for multivariate time series forecasting. In Proceedings of the AAAI Conference on Artificial Intelligence, Virtually, 2–9 February 2024; Volume 38, pp. 11141–11149. [Google Scholar]
  4. Du, Y.; Wang, J.; Feng, W.; Pan, S.; Qin, T.; Xu, R.; Wang, C. Adarnn: Adaptive learning and forecasting of time series. In Proceedings of the 30th ACM International Conference on Information & Knowledge Management, Gold Coast, QLD, Australia, 1–5 November 2021; pp. 402–411. [Google Scholar]
  5. Bento, N.; Rebelo, J.; Carreiro, A.V.; Ravache, F.; Barandas, M. Exploring Regularization Methods for Domain Generalization in Accelerometer-Based Human Activity Recognition. Sensors 2023, 23, 6511. [Google Scholar] [CrossRef]
  6. Li, D.; Yang, Y.; Song, Y.Z.; Hospedales, T. Sequential learning for domain generalization. In Proceedings of the European Conference on Computer Vision, Glasgow, UK, 23–28 August 2020; pp. 603–619. [Google Scholar]
  7. Nasery, A.; Thakur, S.; Piratla, V.; De, A.; Sarawagi, S. Training for the future: A simple gradient interpolation loss to generalize along time. Adv. Neural Inf. Process. Syst. 2021, 34, 19198–19209. [Google Scholar]
  8. Bai, G.; Ling, C.; Zhao, L. Temporal Domain Generalization with Drift-Aware Dynamic Neural Networks. In Proceedings of the The Eleventh International Conference on Learning Representations, Kigali, Rwanda, 1–5 May 2023. [Google Scholar]
  9. Li, W.; Yang, X.; Liu, W.; Xia, Y.; Bian, J. Ddg-da: Data distribution generation for predictable concept drift adaptation. In Proceedings of the AAAI Conference on Artificial Intelligence, Kragujevac, Serbia, 19–20 May 2022; Volume 36, pp. 4092–4100. [Google Scholar]
  10. Fan, W.; Wang, P.; Wang, D.; Wang, D.; Zhou, Y.; Fu, Y. Dish-ts: A general paradigm for alleviating distribution shift in time series forecasting. In Proceedings of the AAAI Conference on Artificial Intelligence, Washington, DC, USA, 7–14 February 2023; Volume 37, pp. 7522–7529. [Google Scholar]
  11. Hochreiter, S.; Schmidhuber, J. Long short-term memory. Neural Comput. 1997, 9, 1735–1780. [Google Scholar] [CrossRef]
  12. Xu, Z.; Li, W.; Niu, L.; Xu, D. Exploiting low-rank structure from latent domains for domain generalization. In Proceedings of the Computer Vision—ECCV 2014: 13th European Conference, Zurich, Switzerland, 6–12 September 2014; pp. 628–643. [Google Scholar]
  13. Li, B.; Shen, Y.; Yang, J.; Wang, Y.; Ren, J.; Che, T.; Zhang, J.; Liu, Z. Sparse mixture-of-experts are domain generalizable learners. arXiv 2022, arXiv:2206.04046. [Google Scholar]
  14. Yao, H.; Yang, X.; Pan, X.; Liu, S.; Koh, P.W.; Finn, C. Leveraging domain relations for domain generalization. arXiv 2023, arXiv:2302.02609. [Google Scholar]
  15. Vaswani, A.; Shazeer, N.; Parmar, N.; Uszkoreit, J.; Jones, L.; Gomez, A.N.; Kaiser, L.U.; Polosukhin, I. Attention is All you Need. In Proceedings of the Advances in Neural Information Processing Systems; Guyon, I., Luxburg, U.V., Bengio, S., Wallach, H., Fergus, R., Vishwanathan, S., Garnett, R., Eds.; Curran Associates, Inc.: Red Hook, NY, USA, 2017; Volume 30. [Google Scholar]
  16. Makridakis, S.; Hibon, M. ARMA models and the Box–Jenkins methodology. J. Forecast. 1997, 16, 147–163. [Google Scholar] [CrossRef]
  17. de Bézenac, E.; Rangapuram, S.S.; Benidis, K.; Bohlke-Schneider, M.; Kurle, R.; Stella, L.; Hasson, H.; Gallinari, P.; Januschowski, T. Normalizing kalman filters for multivariate time series analysis. Adv. Neural Inf. Process. Syst. 2020, 33, 2995–3007. [Google Scholar]
  18. Hyndman, R.; Koehler, A.B.; Ord, J.K.; Snyder, R.D. Forecasting with Exponential Smoothing: The State Space Approach; Springer Science & Business Media: Berlin/Heidelberg, Germany, 2008. [Google Scholar]
  19. Salinas, D.; Flunkert, V.; Gasthaus, J.; Januschowski, T. DeepAR: Probabilistic forecasting with autoregressive recurrent networks. Int. J. Forecast. 2020, 36, 1181–1191. [Google Scholar] [CrossRef]
  20. Zhou, T.; Ma, Z.; Wen, Q.; Wang, X.; Sun, L.; Jin, R. Fedformer: Frequency enhanced decomposed transformer for long-term series forecasting. In Proceedings of the International Conference on Machine Learning, Baltimore, MD, USA, 17–23 July 2022; pp. 27268–27286. [Google Scholar]
  21. Liu, Y.; Wu, H.; Wang, J.; Long, M. Non-stationary transformers: Exploring the stationarity in time series forecasting. Adv. Neural Inf. Process. Syst. 2022, 35, 9881–9893. [Google Scholar]
  22. Zeng, A.; Chen, M.; Zhang, L.; Xu, Q. Are transformers effective for time series forecasting? In Proceedings of the AAAI Conference on Artificial Intelligence, Washington, DC, USA, 7–14 February 2023; Volume 37, pp. 11121–11128. [Google Scholar]
  23. Liu, Y.; Zhang, H.; Li, C.; Huang, X.; Wang, J.; Long, M. Timer: Generative Pre-trained Transformers Are Large Time Series Models. In Proceedings of the Forty-First International Conference on Machine Learning, Vienna, Austria, 21–27 July 2024. [Google Scholar]
  24. Li, Y.; Yu, R.; Shahabi, C.; Liu, Y. Diffusion Convolutional Recurrent Neural Network: Data-Driven Traffic Forecasting. In Proceedings of the International Conference on Learning Representations (ICLR ’18), Vancouver, BC, Canada, 30 April 30–3 May 2018. [Google Scholar]
  25. He, H.; Queen, O.; Koker, T.; Cuevas, C.; Tsiligkaridis, T.; Zitnik, M. Domain adaptation for time series under feature and label shifts. In Proceedings of the International Conference on Machine Learning, Honolulu, HI, USA, 23–29 July 2023; pp. 12746–12774. [Google Scholar]
  26. Lu, W.; Wang, J.; Sun, X.; Chen, Y.; Ji, X.; Yang, Q.; Xie, X. Diversify: A general framework for time series out-of-distribution detection and generalization. IEEE Trans. Pattern Anal. Mach. Intell. 2024, 46, 4534–4550. [Google Scholar] [CrossRef]
  27. Yang, Y.; Liu, Y.; Zhang, Y.; Shu, S.; Zheng, J. DEST-GNN: A double-explored spatio-temporal graph neural network for multi-site intra-hour PV power forecasting. Appl. Energy 2025, 378, 124744. [Google Scholar] [CrossRef]
  28. Fu, F.; Ai, W.; Yang, F.; Shou, Y.; Meng, T.; Li, K. SDR-GNN: Spectral Domain Reconstruction Graph Neural Network for incomplete multimodal learning in conversational emotion recognition. Knowl.-Based Syst. 2025, 309, 112825. [Google Scholar] [CrossRef]
  29. Hou, M.; Liu, Z.; Sa, G.; Wang, Y.; Sun, J.; Li, Z.; Tan, J. Parallel multi-scale dynamic graph neural network for multivariate time series forecasting. Pattern Recognit. 2025, 158, 111037. [Google Scholar] [CrossRef]
  30. Yanchenko, A.K.; Mukherjee, S. Stanza: A nonlinear state space model for probabilistic inference in non-stationary time series. arXiv 2020, arXiv:2006.06553. [Google Scholar]
  31. Gordon, J.; Bronskill, J.; Bauer, M.; Nowozin, S.; Turner, R. Meta-Learning Probabilistic Inference for Prediction. In Proceedings of the International Conference on Learning Representations, New Orleans, LA, USA, 6–9 May 2019. [Google Scholar]
  32. Javed, K.; White, M. Meta-learning representations for continual learning. Adv. Neural Inf. Process. Syst. 2019, 32, 1818–1828. [Google Scholar]
  33. Yoon, J.; Kim, T.; Dia, O.; Kim, S.; Bengio, Y.; Ahn, S. Bayesian model-agnostic meta-learning. Adv. Neural Inf. Process. Syst. 2018, 31, 7343–7353. [Google Scholar]
  34. Cui, Y.; Xie, J.; Zheng, K. Historical inertia: A neglected but powerful baseline for long sequence time-series forecasting. In Proceedings of the 30th ACM International Conference on Information & Knowledge Management, Gold Coast, QLD, Australia, 1–5 November 2021; pp. 2965–2969. [Google Scholar]
  35. Lu, Z.; Zhou, C.; Wu, J.; Jiang, H.; Cui, S. Integrating granger causality and vector auto-regression for traffic prediction of large-scale WLANs. KSII Trans. Internet Inf. Syst. 2016, 10, 136. [Google Scholar]
  36. Li, F.; Feng, J.; Yan, H.; Jin, G.; Yang, F.; Sun, F.; Jin, D.; Li, Y. Dynamic graph convolutional recurrent network for traffic prediction: Benchmark and solution. ACM Trans. Knowl. Discov. Data 2023, 17, 1–21. [Google Scholar] [CrossRef]
  37. Shao, Z.; Zhang, Z.; Wang, F.; Wei, W.; Xu, Y. Spatial-temporal identity: A simple yet effective baseline for multivariate time series forecasting. In Proceedings of the 31st ACM International Conference on Information & Knowledge Management, Atlanta, GA, USA, 17–21 October 2022; pp. 4454–4458. [Google Scholar]
  38. Liu, H.; Dong, Z.; Jiang, R.; Deng, J.; Deng, J.; Chen, Q.; Song, X. Spatio-temporal adaptive embedding makes vanilla transformer sota for traffic forecasting. In Proceedings of the 32nd ACM International Conference on Information and Knowledge Management, Birmingham, UK, 21–25 October 2023; pp. 4125–4129. [Google Scholar]
  39. Sun, L.; Dai, W.; Muhammad, G. Gating Memory Network Multi-Layer Perceptron for Traffic Forecasting in Internet-of-Vehicles systems. IEEE Internet Things J. 2024, 12, 4783–4793. [Google Scholar] [CrossRef]
  40. Wu, H.; Hu, T.; Liu, Y.; Zhou, H.; Wang, J.; Long, M. Timesnet: Temporal 2d-variation modeling for general time series analysis. arXiv 2022, arXiv:2210.02186. [Google Scholar]
Figure 1. The overall architecture of the METDG model, which contains three parts: (1) a GRU-based encoder; (2) a domain relation modeling module based on a self-attention mechanism; (3) an inference network. The left part of the architecture illustrates the training phase, while the right part corresponds to the testing phase.
Figure 1. The overall architecture of the METDG model, which contains three parts: (1) a GRU-based encoder; (2) a domain relation modeling module based on a self-attention mechanism; (3) an inference network. The left part of the architecture illustrates the training phase, while the right part corresponds to the testing phase.
Sensors 25 04434 g001
Figure 2. A visual comparison of the METDG and STID models on the PEMS04, PEMS07, and PEMS08 datasets. The top three images show the prediction results for sensors 75, 133, and 300 on the PEMS04 dataset. The middle three images represent the prediction results for sensors 13, 443, and 836 on the PEMS07 dataset. The bottom three images show the prediction results for sensors 8, 77, and 96 on the PEMS08 dataset.
Figure 2. A visual comparison of the METDG and STID models on the PEMS04, PEMS07, and PEMS08 datasets. The top three images show the prediction results for sensors 75, 133, and 300 on the PEMS04 dataset. The middle three images represent the prediction results for sensors 13, 443, and 836 on the PEMS07 dataset. The bottom three images show the prediction results for sensors 8, 77, and 96 on the PEMS08 dataset.
Sensors 25 04434 g002
Figure 3. Zoomed-in view of a non-stationary period for Sensor 443 in the PEMS07 dataset.
Figure 3. Zoomed-in view of a non-stationary period for Sensor 443 in the PEMS07 dataset.
Sensors 25 04434 g003
Figure 4. Domain representations after dimensionality reduction using the T-SNE algorithm. The left plot illustrates the representations before domain relationship modeling, while the right plot shows the representations after domain relationship modeling.
Figure 4. Domain representations after dimensionality reduction using the T-SNE algorithm. The left plot illustrates the representations before domain relationship modeling, while the right plot shows the representations after domain relationship modeling.
Sensors 25 04434 g004
Figure 5. The results of the ablation study on PEMS04.
Figure 5. The results of the ablation study on PEMS04.
Sensors 25 04434 g005
Figure 6. The impact of different domain divisions on the prediction results.
Figure 6. The impact of different domain divisions on the prediction results.
Sensors 25 04434 g006
Figure 7. The impact of different depths of inference network on model performance. The blue dots indicates the mean value, and the blue shaded area represents the standard error range.
Figure 7. The impact of different depths of inference network on model performance. The blue dots indicates the mean value, and the blue shaded area represents the standard error range.
Sensors 25 04434 g007
Figure 8. The impact of attention heads and transformer layers on model performance. The blue dots indicates the mean value, and the blue shaded area represents the standard error range.
Figure 8. The impact of attention heads and transformer layers on model performance. The blue dots indicates the mean value, and the blue shaded area represents the standard error range.
Sensors 25 04434 g008
Table 1. Comparison of the results for the the sensor datasets with spatial relationships.
Table 1. Comparison of the results for the the sensor datasets with spatial relationships.
PEMS04Horizon 3Horizon 6Horizon 12
MAERMSEMAPEMAERMSEMAPEMAERMSEMAPE
HI42.3361.6429.90%42.3561.6629.92%42.3761.6729.92%
VAR21.9434.3016.42%23.7236.5818.02%26.7640.2820.94%
DCRNN18.5329.4412.76%19.7931.313.57%21.7333.9815.12%
DGCRN17.9829.0812.20%18.9930.912.86%20.4433.2313.87%
STID17.5128.4812.00%18.2929.8612.46%19.5831.7913.38%
DRAIN19.5730.7413.37%21.8433.6214.27%23.2235.3215.28%
STAEformer17.4728.911.94%18.2030.3112.35%19.3032.1013.19%
GMMLP17.3928.4112.03%18.1829.8212.34%19.3731.5713.58%
Ours17.1728.3211.43%17.9729.6812.25%19.6331.9013.30%
PEMS07Horizon 3Horizon 6Horizon 12
MAERMSEMAPEMAERMSEMAPEMAERMSEMAPE
HI49.0271.1622.73%49.0371.1822.75%49.0671.2022.79%
VAR32.0248.8318.30%35.1852.9120.54%38.3756.8222.04%
DCRNN19.7531.748.31%21.635.129.00%24.7640.7510.39%
DGCRN18.4330.978.76%20.4334.128.69%21.4437.939.91%
STID18.3730.397.74%19.6632.828.28%21.5336.049.13%
DRAIN21.2334.189.02%23.2337.7110.14%27.2944.2413.26%
STAEformer18.0930.157.56%19.3832.998.97%21.4135.998.97%
GMMLP17.9830.057.67%19.2432.668.08%20.8935.768.77%
Ours17.8730.137.54%19.1732.407.96%20.6435.708.69%
PEMS08Horizon 3Horizon 6Horizon 12
MAERMSEMAPEMAERMSEMAPEMAERMSEMAPE
HI34.5550.4121.60%34.5750.4321.63%34.5950.4421.68%
VAR19.5229.7312.54%22.2530.3014.23%26.1738.9717.32%
DCRNN15.6425.4810.04%17.8827.6311.38%22.5134.2114.17%
DGCRN13.8922.079.19%14.9223.999.85%16.7326.8810.84%
STID13.8521.929.03%15.0024.049.78%16.7726.9110.93%
DRAIN16.8826.7311.13%18.8630.1713.22%23.2436.1614.84%
STAEformer13.8521.998.76%14.4123.729.26%15.3426.039.91%
GMMLP13.1821.628.55%14.0923.599.18%15.3226.069.90%
Ours13.1221.538.50%13.9923.249.01%15.2425.899.85%
Table 2. Comparison of results for the sensor datasets without spatial relationships.
Table 2. Comparison of results for the sensor datasets without spatial relationships.
MethodsOursHIVARDRAINMSGNetTimesnetDLinerFEDformerInformer
MetricMSEMAEMSEMAEMSEMAEMSEMAEMSEMAEMSEMAEMSEMAEMSEMAEMSEMAE
Weather960.1600.1990.8940.5530.4580.4910.2360.2780.1630.2120.2200.1960.1960.2550.2170.2960.3000.384
1920.2070.2440.6210.6280.6480.5800.2790.3010.2120.2540.2190.2610.2370.2960.2760.3360.5980.544
3360.2750.2940.7360.7530.7970.6590.3290.3650.2720.2990.2800.3060.2830.3550.3390.3800.5780.523
7200.3640.3601.0050.9340.8690.6720.3790.4280.3500.3480.3650.3590.3450.3810.4030.4281.0590.741
ETTh1960.3720.3951.2640.9340.8710.7490.4400.4510.3900.4110.3840.4020.3860.4000.3760.4190.8650.713
1920.4200.4321.4570.9801.5541.3170.4900.4820.4420.4420.4360.4290.4370.4320.4200.4481.0080.792
3360.4540.4572.0251.1381.4201.1280.5200.4960.4800.4680.4910.4690.4810.4590.4590.4651.1070.809
7200.5100.4912.3831.3761.9371.3220.5110.5020.4940.4880.5210.5000.5190.5160.5060.5071.1810.865
ETTh2960.3110.3302.5761.1481.5391.6180.3460.3880.3280.3710.3400.3740.3330.3870.3580.3973.7551.525
1920.3290.3473.3381.7832.8791.5340.3920.4070.4020.4140.4020.4140.4770.4760.4290.4395.6021.931
3360.3500.3902.9361.7803.4521.6930.4210.4340.4350.4430.4520.4520.5940.5410.4960.4874.7211.835
7200.3850.4404.6253.8215.3852.0970.4520.4730.4170.4410.4620.4680.8310.6570.4630.4743.6471.625
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

Zhang, L.; Liu, J.; Jin, B.; Wei, X. Meta-Learning Task Relations for Ensemble-Based Temporal Domain Generalization in Sensor Data Forecasting. Sensors 2025, 25, 4434. https://doi.org/10.3390/s25144434

AMA Style

Zhang L, Liu J, Jin B, Wei X. Meta-Learning Task Relations for Ensemble-Based Temporal Domain Generalization in Sensor Data Forecasting. Sensors. 2025; 25(14):4434. https://doi.org/10.3390/s25144434

Chicago/Turabian Style

Zhang, Liang, Jiayi Liu, Bo Jin, and Xiaopeng Wei. 2025. "Meta-Learning Task Relations for Ensemble-Based Temporal Domain Generalization in Sensor Data Forecasting" Sensors 25, no. 14: 4434. https://doi.org/10.3390/s25144434

APA Style

Zhang, L., Liu, J., Jin, B., & Wei, X. (2025). Meta-Learning Task Relations for Ensemble-Based Temporal Domain Generalization in Sensor Data Forecasting. Sensors, 25(14), 4434. https://doi.org/10.3390/s25144434

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