Next Article in Journal
From Matryoshka and Fukuruma to Hierarchies of Criteria and Ranking Methods in Multi-Criteria Problems of Analysis and Decision Making
Previous Article in Journal
Evaluation of Bacterial Growth Ability and PHA Production Using Various Combinations of Fatty Acids
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Proceeding Paper

Efficient Forecasting of Large-Scale Hierarchical Time Series via Multilevel Clustering †

1
Department of Electrical and Computer Engineering, University of Texas at Austin, Austin, TX 78712, USA
2
Department of Computer Science, University of Texas at Austin, Austin, TX 78712, USA
3
Intuit, Mountain View, CA 94043, USA
4
Department of Statistics and Data Science, University of Texas at Austin, Austin, TX 78712, USA
*
Author to whom correspondence should be addressed.
Presented at the 9th International Conference on Time Series and Forecasting, Gran Canaria, Spain, 12–14 July 2023.
Eng. Proc. 2023, 39(1), 31; https://doi.org/10.3390/engproc2023039031
Published: 29 June 2023
(This article belongs to the Proceedings of The 9th International Conference on Time Series and Forecasting)

Abstract

:
We propose a novel approach to cluster hierarchical time series (HTS) for efficient forecasting and data analysis. Inspired by a practically important but unstudied problem, we found that leveraging local information when clustering HTS leads to a better performance. The clustering procedure we proposed can cope with massive HTS with arbitrary lengths and structures. In addition to providing better insights, this method can also speed up the forecasting process for a large number of HTS. Each time series is first assigned the forecast from its cluster representative, which can be considered as “prior shrinkage” for the set of time series it represents. Then, the base forecast can be efficiently adjusted to accommodate the specific attributes of the time series. We empirically show that our method substantially improves performance for large-scale clustering and forecasting tasks involving HTS.

1. Introduction

Time series with hierarchical aggregation constraints are commonly seen in many practical scenarios [1]. In applications such as finance or e-commerce, an HTS normally represents historical records from one user (e.g., the cash flow example in Figure 1). Normally, separately building a predictive model for each user is inefficient, particularly when the number of users is quite large, or the length of user records varies significantly. To address this problem, we design a novel clustering procedure. It effectively finds the cluster representatives of a large group of HTS, followed by fine-tuning forecasts on these representatives to obtain user-specific forecasts.
Clustering time series is an important tool for discovering patterns over sequential data when categorical information is not available. Most clustering approaches fall into discriminative and generative categories. Discriminative approaches normally define a proper distance measure [2] or construct features [3] that capture temporal information. Generative approaches [4] specify the model type (e.g., HMM) a priori and estimate the parameters using maximum likelihood algorithms. Deep learning has also been applied to time series clustering. Most state-of-the-art discriminative approaches first extract useful temporal representations followed by clustering in the embedding space [5]. However, there is no prior work on clustering HTS data. This problem is more challenging since data at different level of HTS have distinct properties. Regular clustering methods for time series lead to inferior performance, particularly when the hierarchy is complex. When clustering HTS, we need to leverage level-wise information, but it is difficult to completely respect the hierarchy since the data are not easy to partition given the imposed constraints.
There is little prior work on the clustering of multilevel-structured data. A pioneering effort [6] proposed to simultaneously partition data at both local and global levels and discover latent multilevel structures. This work proposed an optimization objective for two-level clustering based on Wasserstein metrics. Its core idea was to perform global clustering based on a set of local clusters. However, this work mainly applies to discrete and semi-structured data such as annotated images and documents. It cannot be applied to HTS involving continuous or structured data, which has more constraints. A follow-up work [7] extended this to continuous data by assuming that the data at the local level is generated by predefined exponential family distributions. The authors then performed model-based clustering at both levels. However, model-based clustering for time series is computationally expensive and crucially depends on the modelling assumptions. Moreover, both these works were limited to two-level structures, whereas for several HTS applications, given a set of pre-specified features as aggregation variables, it is possible to have a multilevel hierarchy. Note that, our problem is different from hierarchical clustering [8]: the hierarchy comes from the time series data instead of the method that builds a hierarchy of clusters.
In this paper, we propose HTS-Cluster, an efficient model-free clustering method that can handle HTS with various types of individual components and hierarchies. HTS-Cluster employs a combined objective that involves clustering terms from each aggregated level. This formulation uses Wasserstein distance metrics coupled with Soft-DTW divergence [9] to cater to variable length series that are grouped together. In addition to providing superior clustering results for multilevel hierarchies, HTS-Cluster significantly improves the efficiency of forecasts when applied to large HTS datasets containing hundreds of thousands of time series.

2. Backgrounds

Hierarchical time series: Given the time stamps t = 1 , , T , let x t R n be the value of HTS at time t, where x t , i R is the value of the i th (out of n) univariate time series. Figure 1 shows an example of HTS with a three-level structure. We refer to the time series at the leaf nodes of the hierarchy as bottom-level time series and the remaining nodes as aggregated-level time series. We split the vector of x t into m-bottom time series and l-aggregated time series such that x t = [ a t b t ] where a t R l and b t R m with n = l + m . The summation matrix S { 0 , 1 } n × m satisfies x t = S · b t , which can later be used to calibrate forecasting results to be aligned with a given hierarchical structure. For notational simplicity, we omit the time stamp of each series in the following discussion.
Dynamic Time Warping (DTW) [10]: DTW is a popular method for computing the optimal alignment between two time series with arbitrary lengths. Given X and Y of length T 1 and T 2 , respectively, DTW computes the T 1 × T 2 pairwise distance matrix between each time stamp and solves a dynamic program (DP) using Bellman’s recursion in O ( T 1 · T 2 ) time. DTW discrepancy can be used to describe the average similarity within a set of time series [2]. However, DTW is not a differentiable metric given its DP recursion nature. To address this issue, the authors of [11] proposed Soft-DTW by smoothing the min operation using the log-sum-exp trick. Specifically, we assume A { 0 , 1 } T 1 × T 2 is the alignment matrix between two time series and C R T 1 × T 2 is the cost matrix, the formulation of the Soft-DTW can be written as
SDTW γ ( C ( X , Y ) ) = min A A ( T 1 , T 2 ) γ A , C = γ log A A ( T 1 , T 2 ) exp ( A , C / γ ) ,
where γ > 0 is a parameter that controls the trade-off between the approximation and smoothness, and A ( T 1 , T 2 ) is the collection of all possible alignments between two time series. Soft-DTW is differentiable with respect to all of its variables and can be used for a variety of tasks such as averaging, clustering, and prediction of time series. However, Soft-DTW also has several drawbacks. Ref. [9] recently showed that Soft-DTW is not a valid divergence given its minimum is not achieved when two time series are equal; furthermore, the value of Soft-DTW is not always non-negative. Ref. [9] proposed Soft-DTW divergence, which can address these issues and achieves a better performance. This divergence D can be written as
D ( X , Y ) : = SDTW γ ( C ( X , Y ) ) 1 2 SDTW γ ( C ( X , X ) ) 1 2 SDTW γ ( C ( Y , Y ) ) .
Our method incorporates the Soft-DTW divergence as a base distance measure for variable length sequences, and use it as a differentiable loss during the clustering procedure.
Wasserstein distance: For any given subset Θ R d , let P ( Θ ) denote the space of Borel probability measures on Θ . The Wasserstein space of order r of probability measures on Θ is defined as P r ( Θ ) = G P ( Θ ) : x r d G ( x ) < , where · denotes the Euclidean metric in R d . For any P or Q in P r ( Θ ) , the r-Wasserstein distance W r between P and Q is
W r ( P , Q ) = inf π Π ( P , Q ) Θ 2 x y r d π ( x , y ) 1 / r ,
where Π ( P , Q ) contains all the joint (coupling) distributions whose margins are P and Q, and the π coupling that achieves the minimum of Equation (3) is called the transportation plan. In other words, W r ( P , Q ) is the optimal cost of moving mass from P to Q, which is proportional to the r-power of the Euclidean distance in Θ . Furthermore, by recursion of concepts, we define P r ( P r ( Θ ) ) as the space of Borel measures on P r ( Θ ) , then P , Q P r ( P r ( Θ ) ) ,
W r ( 2 ) ( P , Q ) = inf π Π ( P , Q ) P r ( Θ ) 2 W r r ( P , Q ) d π ( P , Q ) 1 / r .
Similarly, the cost of moving unit mass in its space of support P r ( Θ ) is proportional to the r-power of the W r distance in P r ( Θ ) . The Wasserstein distance can be thought of as a special case of the Wasserstein barycenter problem. Computation of the Wasserstein distance and Wasserstein barycenter has been studied by many prior works, where [12] proposed an efficient algorithm to find its local solutions. The well-known K-means clustering algorithm can also be viewed as a method to solve the Wasserstein means problem [6].

3. Hierarchical Time Series Clustering

In this section, we present the HTS-Cluster for clustering time series with both two-level and multilevel hierarchical structures. We use x j , i to denote the i th univariate time series of the j th HTS, where 1 j N and 1 i n j . We assume the index i of each series is given by the level-order traversal of the hierarchical tree from left to right at each level. We will use a j , i and b j , i for the corresponding aggregated and bottom-level series, respectively.

3.1. Two-Level Time Series Clustering

We define a new Wasserstein distance measure W sdtw as
W sdtw ( P , Q ) = inf π Π ( P , Q ) Θ 2 D ( x , y ) d π ( x , y ) .
For any j = 1 , , N , we denote the empirical measure of all bottom-level series as P N = 1 N j = 1 N i = 1 n j δ b j , i , where N N given that each HTS has at least one bottom-level series. For local (bottom-level) clustering, we assume that at most k 2 clusters can be obtained, we perform K-means that can be viewed as finding a finite discrete measure G = k = 1 k 2 u k δ μ k O k 2 ( Θ ) that minimizes W sdtw ( G , P N ) , where μ k R T is the “cluster mean” time series to be optimized in support of the finite discrete measure G and u Δ k 2 , where Δ k = w R k : w i 0 , i = 1 k w i = 1 is the probability simplex for any k 1 .
Although this approach can be extended to any aggregated level, such a method cannot leverage the connections with adjacent levels. As Figure 2 shows, aggregation of data will cause the loss of information: it is less likely to obtain reasonable results by simply clustering data at the aggregated level. Therefore, we believe that with the help of bottom-level information, clustering at the aggregated level can be further improved.
Problem formulation: A direct solution is to replace each top-level series with a large feature vector obtained by concatenating all bottom-level series, but this will introduce redundancy and require large training datasets due to the induced high dimensionality. Instead, we propose to leverage local information by utilizing local clustering results. For the j th HTS, we denote F j ( i ) as the set that contains all descendant indices of its i th series, and assume each top-level series a j , 1 is aggregated from the bottom-level series { b j , i } i F j ( 1 ) . First, we cluster all bottom-level series { b j , i } j [ N ] , i F j ( 1 ) into k 2 clusters { C k } k [ k 2 ] with C k centred at μ k . We then assign the following probability measure to each a j , 1 :
a ˜ j , 1 = 1 | F j ( 1 ) | i F j ( 1 ) k [ k 2 ] 1 μ k 1 b j , i C k ,
that is, we represent the top-level time series as an empirical distribution of { μ k } k [ k 2 ] , where the weight of each μ k is determined by the number of b j , i that belongs to cluster C k . Note that, we distinguish a ˜ j , 1 from a j , 1 , where a ˜ j , 1 is its corresponding probability measure of a j , 1 . This formulation represents the top-level time series using a finite number of bottom-level clusters, reducing computation time from concatenating bottom-level time series while simultaneously leveraging local information. We now define the objective function to jointly optimize both local and global clusters as follows
inf G O k 2 ( Θ ) , H O k 1 ( P r ( Θ ) ) W sdtw ( G , P N ) + W sdtw ( 2 ) ( H , 1 N j = 1 N δ a ˜ j , 1 ) ,
where k 1 is the number of clusters at the top-level, and H is the distribution over top-level cluster centroids. Similar to each top-level time series a ˜ j , 1 , the supports of H are also finite discrete measures. Specifically, H = k = 1 k 1 v k δ ν k P r ( P r ( Θ ) ) , where v Δ k 1 , ν k O n ¯ ( Θ ) and n ¯ = 1 N j = 1 N F j ( 1 ) . Equation (6) is our formulation for the two-level HTS clustering problem, where the first term W sdtw ( G , P N ) is the Wasserstein distance defined in the space of measures P r ( Θ ) and the second term is defined in P r ( P r ( Θ ) ) .

3.2. Multilevel Time Series Clustering

For HTS with multiple levels, we employ a “bottom-up” clustering procedure that recursively uses lower-level information for higher-level clustering, till the root is reached. We assume we are given N HTS with L levels; we denote by x 1 : N l a collection of the l th -level time series from the first N HTS and x 1 : N l as the replacement of the corresponding time series represented by lower-level clusters. We formulate the objective function to cluster multilevel time series as
inf G O k L ( Θ ) , H l O k l ( P r ( Θ ) ) W sdtw ( G , P N ) + l = 1 L 1 W sdtw ( 2 ) ( H l , 1 G ( l ) j = 1 G ( l ) δ x 1 : N l [ j ] ) ,
where G ( l ) is the total number of time series at level l among N HTS. Similarly, we have H l = k = 1 k l v k δ ν k l , v Δ k l and ν k l O n ¯ l ( Θ ) . Algorithm 1 shows the full procedure of the bottom-up clustering for HTS with arbitrary levels, while its core steps also apply to two-level HTS clustering. Specifically, steps 4 and 5 are the centring and cluster assignment steps for clustering time series at the L th (bottom) level, which uses Soft-DTW divergence as a distance measure between each input pair. After obtaining the clustering result at the L th -level, its cluster indices and means are used to construct probability measures for each time series at the L 1 level (step 8). Meanwhile, we still have access to the original time series in the aggregated levels. Steps 10 and 11 perform clustering in the space of probability measures. To efficiently compute the Wasserstein barycenter, we optimize the support of the barycenter ν k l , featured as the free-support method studied in [12]. For cluster assignment, we compute the Wasserstein distance between pairs of probability measures in the Soft-DTW divergence space. Both the assignment and centring steps utilize information from lower aggregation levels, where these steps are repeated until the cluster assignments are stable. We then use the results of the cluster assignment to compute the cluster means of the original time series at that level, used as supports of the probability measure to represent time series in the next aggregation level, until the clustering procedure for all levels is finished.
Computational efficiency: Compared with model-based clustering, HTS-Cluster waives the extensive computation of HMM parameters and the data assumptions. Note that, computing the Wasserstein barycenter at step 10 is very efficient since one just needs to compute the Soft-DTW divergence between the supports of each distribution, which can be obtained beforehand. The process of finding the optimal barycenter (steps 4 and 10) is differentiable. Therefore, the clustering time is progressively reduced as we proceed to higher levels.
Algorithm 1 HTS-Cluster.
1:
Input: L , total aggregation level; x 1 : N l , collection of the l th level series from #1 to #N HTS
2:
Initialize: cluster assignment: { C k l } k [ k l ] , l [ L ]
3:
while not converged do
4:
    μ k L = arg min μ R T 1 | C k L | i C k L D ( x 1 : N L [ i ] , μ )
5:
    C k L = { i : D ( x 1 : N L [ i ] , μ k L ) = min k [ k L ] D ( x 1 : N L [ i ] , μ k L ) }
6:
end while
7:
for  l = [ L 1 , L 2 , , 1 ]  do
8:
    x j l [ n ] = 1 | F j ( n ) | i F j ( n ) k [ k l + 1 ] 1 ν k l + 1 1 x j l + 1 [ i ] C k l + 1
9:
   while not converged do
10:
      ν k l = arg min ν i C k l λ i W sdtw ( x 1 : N l [ i ] , ν )
11:
      C k l = { i : W sdtw ( x 1 : N l [ i ] , ν k l ) = min k [ k l ] W sdtw ( x 1 : N l [ i ] , ν k l ) }
12:
   end while
13:
    ν k l = arg min ν R T 1 | C k l | i C k l D ( x 1 : N l [ i ] , ν )
14:
end for
HTS forecasting; Forecasts for individual HTS can “borrow strength” from the forecasts of the nearest cluster means at each level. Specifically, we first perform forecasts for the bottom- and aggregated-level cluster-mean time series { μ k L } k [ k L ] and { ν k l } k [ k l ] , l [ L 1 ] , respectively. The forecast for each time series can be represented as the weighted combination of forecasts of the corresponding cluster means at that level. We define the weight between time series i and cluster mean j at level l as
w i , j l = 1 k = 1 k l D ( x i l , ν j l ) D ( x i l , ν k l ) 2 m 1 , m ( 1 , ) ,
where the closer x i l is to a certain cluster mean, the higher its weight is. Equation (8) is well known in fuzzy clustering, where a data point can belong to more than one cluster, and m is the parameter that controls how fuzzy the cluster assignments are. One can use post-reconciliation methods, such as in [1], to calibrate the results for individual forecasts.

4. Experiments

We evaluate HTS-Cluster in multiple applications. Overall, our experiments include (1) clustering time series with multilevel structures (Section 4.1); (2) facilitating time series forecasting with the help of clusters (Section 4.2).

4.1. HTS Clustering

Two-level HTS: We first conduct experiments on synthetic data using ARMA simulations, to provide a feel for the setting and the results attainable. We generate a simple HTS with two levels: one parent node with four children vertices, i.e., for the j th hierarchy X j = { x i } i = 1 5 , x 1 = i = 2 5 x i . The length of each X is different, ranging from 80 to 300. We use the following simulation function for each time series x 1 : T
x t = 0.75 x t 1 0.25 x t 2 + 0.65 ε t 1 + 0.35 ε t 2 + ε t + c ,
where ε t is a white noise error term at time t, and c is an offset that is used to separate different clusters. We simulate four clusters, each having 30 HTS as members. Additionally, the evaluation is performed on a real-world HTS dataset containing financial records from multiple users for tax purposes. This dataset contains 12,000 users’ electronic records of expenses in different categories. The bottom-level time series are summed across all categories to obtain the total expenses. Each user owns an HTS but the length of records varies from user to user.
Multilevel HTS: We also test our method on HTS with multiple aggregated levels. It is simple to extend simulated two-level HTS to multiple levels by modifying the summation matrix S. The evaluation is also performed on a large, real-world financial dataset that contains HTS with ≥3 aggregated levels. Each HTS represents the expense records of a small business, where the bottom level (or the lowest two levels) time series are user-defined accounts (or sub-accounts), which are then aggregated by different tax purposes to obtain the middle-level time series. The top-level time series are the total expenses aggregated from the middle level, including the overall information of the business. The dataset contains 18,568 HTS with 222,989 bottom-level time series in total.
Experiment baselines: Our baselines for evaluating HTS-Cluster include the recent state-of-the-art method DTCR [5], which employs an encoder–decoder structure integrated with a fake sample generation strategy. The authors of [5] showed that DTCR can learn better temporal representations for time series data that improve the clustering performance. Here, we implement DTCR to treat HTS as regular multivariate time series data. In addition, we implemented independent level-wise clustering using Soft-DTW divergence (Soft-DTW), i.e., without local information and clustering aggregated-level data via simply concatenating lower-level time series (concat). We used three prevalent methods for clustering evaluation: normalized mutual information (NMI) [13], adjusted mutual information (AMI) [14], and adjusted rand index (ARI) [15].
Clustering results: We conducted 10 experiments, with different random seeds, on both simulated and real datasets. As shown in Table 1 (upper), for the synthetic two-level HTS, our method is superior to the baseline methods in both clustering performance and computational efficiency. Specifically, in terms of clustering performance, level-wise clustering approaches are better than DTCR, at both global (aggregated) and local (bottom) levels, since separating information from different granularities can improve the partitioning of data. As for computation time, DTCR training consists of two stages: it first learns temporal representations and then performs K-means clustering. This results in a longer computation time compared with HTS-Cluster. For level-wise approaches, clustering using Soft-DTW divergence and simple concatenation yield the same results at the bottom level, but concatenating bottom-level data provides better results at the top level since aggregation causes the loss of information. Finally, the alternating updates using the global and local cluster formulations of Equation (6), lead to improved performance due to leveraging both local and global information. Specifically, the top-level time series are represented by empirical distributions over bottom-level cluster means, and the cluster means at the top level can be obtained more efficiently via fast computation of the Wasserstein barycenter. Based on user-specified domain knowledge or constraints, we utilize the global cluster assignment to calibrate local time series that are far from the nearest cluster centre. This procedure improves both the local and global clustering results while simultaneously reducing the total computation time.
HTS-Cluster also demonstrates improved performance over baseline methods on multilevel HTS. As shown in Table 2, all methods are evaluated on HTS datasets with four aggregation levels, where level one is the top level and four is the bottom level. Here, HTS-Cluster employs the bottom-up procedure of Algorithm 1, where the clustering results from the lower level are leveraged for upper-level clustering until the root is reached. Therefore, the level-wise clustering methods (Soft-DTW, Concat, and HTS-Cluster) share the same results at the bottom level. At aggregated levels, HTS-Cluster consistently outperforms DTCR and Soft-DTW with the help of local information and achieves a competitive performance with Concat at a much smaller computational cost.
For the financial data, there are no cluster labels. Therefore, we use the “business type”, included in the metadata of each HTS, as a weak “ground truth” label for clustering. Unsurprisingly, the results metrics for all the methods are low (Table 1 bottom), and the utility of HTS-Cluster really emerges when we examine the downstream forecasting results later on. For now, to show that the clusters are still meaningful, we visualize the HTS metadata at the tax code level using our method (Figure 3). We see that HTS-Cluster does create meaningful partitions for HTS by accounting for features from a local time series. Finally, we monitor the level-wise clustering time of each method. The compared baselines include (1) level-wise clustering using Soft-DTW divergence without leveraging local clustering results; (2) simple concatenation of lower-level time series for higher-level clustering. All three methods are conducted in a bottom-up fashion, with the same bottom-level clustering procedure. As shown in Table 3 (left), HTS-Cluster provides the most efficient method for clustering aggregated-level time series. This is because (1) computing the Wasserstein barycenter at aggregated levels based on [12] is more efficient than obtaining the barycenters using Soft-DTW divergence; (2) HTS-Cluster only leverages lower-level clustering result instead of the entire set of time series at that level.

4.2. HTS Forecasting

We propose two forecasting applications that can utilize our proposed method. We use the mean absolute scaled error (MASE) [16] to evaluate the forecasting accuracy.
Case 1: Forecast single-HTS with complex structure: Many public datasets comprise a single hierarchy that includes a large number of time series; this is common when HTS has many categorical variables to be aggregated. Forecasting a large number of correlated time series requires extensive computation for global models or parameter tuning for local models. HTS-Cluster provides an efficient way of modelling such HTS. For the bottom k-levels that have large numbers of time series, one just needs to forecast their cluster means obtained from clustering “sub-trees” at these levels. The forecasts of each time series at the bottom k-levels can be “reconstructed” using a soft combination of cluster means in Equation (8). We test our method using two popular models: DeepAR [17] and LSTNet [18] and two public HTS: Wiki and M5 [19]. In Table 4, this strategy achieves competitive results with less computation compared with the original methods. This could also improve aggregated levels without applying clustering.
Case 2: Forecast massive HTS with simple structures: Similarly, we forecast cluster means obtained from each level of HTS, and then use Equation (8) to obtain a prediction for each HTS. To ensure forecasts are consistent with respect to the hierarchy, we apply reconciliation from [1] to the forecasts of each HTS. Table 3 shows the effectiveness of the clustering, where the total time is normalized by the method without cluster. From the results, HTS-Cluster can greatly reduce the overall computation time without compromising the forecasting accuracy.

5. Conclusions

In this paper, we addressed an important but understudied problem for clustering time series with hierarchical structures. Given that time series at different aggregated levels possess distinct properties, regular clustering methods are not ideal. We introduced a new clustering procedure for HTS such that when clustering is conducted at the same aggregated level it simultaneously utilizes clustering results from an adjacent level. In each clustering iteration, both local and global information are leveraged. Our proposed method shows improved clustering performance in both simulated and real-world HTS and proves to be an effective solution when a large number of HTS forecasting is required as a downstream task. For future work, we plan to extend this framework to model-based clustering for HTS with some known statistical properties.

Author Contributions

Conceptualization, X.H., T.R. and N.H.; methodology, X.H. and T.R.; software, X.H.; validation, X.H. and J.H.; formal analysis, X.H., T.R. and N.H.; investigation, X.H.; resources, X.H.; data curation, X.H.; writing—original draft preparation, X.H.; writing—review and editing, X.H., T.R., J.G. and N.H.; visualization, X.H.; supervision, J.G. and N.H. All authors have read and agreed to the published version of the manuscript.

Funding

This work is funded by Intuit AI.

Data Availability Statement

This study applied a simulation dataset and open access datasets (M5 [19], Wiki https://www.kaggle.com/code/muonneutrino/wikipedia-traffic-data-exploration (accessed on 1 April 2023)), which is referenced accordingly. The financial record dataset cannot be publicly accessed due to privacy concerns.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Wickramasuriya, S.L.; Athanasopoulos, G.; Hyndman, R.J. Optimal forecast reconciliation for hierarchical and grouped time series through trace minimization. J. Am. Stat. Assoc. 2019, 114, 804–819. [Google Scholar] [CrossRef]
  2. Petitjean, F.; Ketterlin, A.; Gançarski, P. A global averaging method for dynamic time warping, with applications to clustering. Pattern Recognit. 2011, 44, 678–693. [Google Scholar] [CrossRef]
  3. Aghabozorgi, S.; Shirkhorshidi, A.S.; Wah, T.Y. Time-series clustering–a decade review. Inf. Syst. 2015, 53, 16–38. [Google Scholar] [CrossRef]
  4. Zhong, S.; Ghosh, J. A unified framework for model-based clustering. J. Mach. Learn. Res. 2003, 4, 1001–1037. [Google Scholar]
  5. Ma, Q.; Zheng, J.; Li, S.; Cottrell, G.W. Learning representations for time series clustering. Adv. Neural Inf. Process. Syst. 2019, 32, 3781–3791. [Google Scholar] [CrossRef]
  6. Ho, N.; Nguyen, X.; Yurochkin, M.; Bui, H.H.; Huynh, V.; Phung, D. Multilevel clustering via Wasserstein means. In Proceedings of the International Conference on Machine Learning, PMLR, Sydney, Australia, 6–11 August 2017; pp. 1501–1509. [Google Scholar]
  7. Ho, N.; Huynh, V.; Phung, D.; Jordan, M. Probabilistic multilevel clustering via composite transportation distance. In Proceedings of the 22nd International Conference on Artificial Intelligence and Statistics, PMLR, Okinawa, Japan, 16–18 April 2019; pp. 3149–3157. [Google Scholar]
  8. Rodrigues, P.P.; Gama, J.; Pedroso, J. Hierarchical clustering of time-series data streams. IEEE Trans. Knowl. Data Eng. 2008, 20, 615–627. [Google Scholar] [CrossRef]
  9. Blondel, M.; Mensch, A.; Vert, J.P. Differentiable divergences between time series. In Proceedings of the International Conference on Artificial Intelligence and Statistics, PMLR, Virtual, 13–15 April 2021; pp. 3853–3861. [Google Scholar]
  10. Müller, M. Dynamic time warping. Inf. Retr. Music. Motion 2007, 69–84. [Google Scholar]
  11. Cuturi, M.; Blondel, M. Soft-dtw: A differentiable loss function for time-series. In Proceedings of the International Conference on Machine Learning, PMLR, Sydney, Australia, 6–11 August 2017; pp. 894–903. [Google Scholar]
  12. Cuturi, M.; Doucet, A. Fast computation of Wasserstein barycenters. In Proceedings of the International Conference on Machine Learning, PMLR, Beijing, China, 21—26 June 2014; pp. 685–693. [Google Scholar]
  13. Schütze, H.; Manning, C.D.; Raghavan, P. Introduction to Information Retrieval; Cambridge University Press: Cambridge, UK, 2008; Volume 39. [Google Scholar]
  14. Hubert, L.; Arabie, P. Comparing partitions. J. Classif. 1985, 2, 193–218. [Google Scholar] [CrossRef]
  15. Vinh, N.X.; Epps, J.; Bailey, J. Information theoretic measures for clusterings comparison: Variants, properties, normalization and correction for chance. J. Mach. Learn. Res. 2010, 11, 2837–2854. [Google Scholar]
  16. Hyndman, R.J.; Koehler, A.B. Another look at measures of forecast accuracy. Int. J. Forecast. 2006, 22, 679–688. [Google Scholar] [CrossRef] [Green Version]
  17. 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]
  18. Lai, G.; Chang, W.C.; Yang, Y.; Liu, H. Modeling long-and short-term temporal patterns with deep neural networks. In Proceedings of the 41st International ACM SIGIR Conference on Research & Development in Information Retrieval, Ann Arbor, MI, USA, 8–12 July 2018; pp. 95–104. [Google Scholar]
  19. Makridakis, S.; Spiliotis, E.; Assimakopoulos, V. The M5 accuracy competition: Results, findings and conclusions. Int. J. Forecast. 2022, 38, 1346–1364. [Google Scholar] [CrossRef]
Figure 1. Left: an example of hierarchical time series (HTS) with five bottom-level time series and three-level hierarchical structure. Each vertex ( V = { v i } i = 1 8 ) represents time series aggregated on different variables related through a domain-specific conceptual hierarchy (e.g., product categories, locations, etc.). Right: the summation matrix S { 0 , 1 } 8 × 5 used to denote the given hierarchy.
Figure 1. Left: an example of hierarchical time series (HTS) with five bottom-level time series and three-level hierarchical structure. Each vertex ( V = { v i } i = 1 8 ) represents time series aggregated on different variables related through a domain-specific conceptual hierarchy (e.g., product categories, locations, etc.). Right: the summation matrix S { 0 , 1 } 8 × 5 used to denote the given hierarchy.
Engproc 39 00031 g001
Figure 2. Leveraging local clustering results for HTS clustering. We improve the clustering performance at the aggregated level by clustering empirical distributions over cluster representatives obtained from the bottom-level.
Figure 2. Leveraging local clustering results for HTS clustering. We improve the clustering performance at the aggregated level by clustering empirical distributions over cluster representatives obtained from the bottom-level.
Engproc 39 00031 g002
Figure 3. Word cloud visualization of time series metadata from massive financial records. The keywords represent different types of expenses for tax purpose. The results show keywords from three representative clusters at the expense level, by leveraging the local information of clustering results obtained at the user level. The clusters provide meaningful partitions, such as “payroll expenses”, “administrative expenses”, and “service cost”, which are from distinct categories.
Figure 3. Word cloud visualization of time series metadata from massive financial records. The keywords represent different types of expenses for tax purpose. The results show keywords from three representative clusters at the expense level, by leveraging the local information of clustering results obtained at the user level. The clusters provide meaningful partitions, such as “payroll expenses”, “administrative expenses”, and “service cost”, which are from distinct categories.
Engproc 39 00031 g003
Table 1. Level-wise clustering results on HTS with two aggregated levels. The upper part shows the results of simulated data. The lower part gives the results on real-world financial record data using a weak proxy for the cluster labels.
Table 1. Level-wise clustering results on HTS with two aggregated levels. The upper part shows the results of simulated data. The lower part gives the results on real-world financial record data using a weak proxy for the cluster labels.
Method∖MetricTime (s)GlobalLocal
NMIAMIARINMIAMIARI
DTCR1320.325 ± 0.0120.257 ± 0.0230.21 ± 0.0110.392 ± 0.0140.313 ± 0.0060.284 ± 0.009
Soft-DTW670.412 ± 0.0090.326 ± 0.0190.277 ± 0.0080.411 ± 0.0220.342 ± 0.0090.304 ± 0.014
Concat1860.436 ± 0.0150.342 ± 0.0140.314 ± 0.0160.411 ± 0.0220.342 ± 0.0090.304 ± 0.014
HTS-Cluster370.455 ± 0.0180.354 ± 0.0150.302 ± 0.0130.424 ± 0.0180.366 ± 0.0130.321 ± 0.018
DTCR720.065 ± 0.0020.015 ± 0.0010.008 ± 0.0020.105 ± 0.0110.059 ± 0.0020.054 ± 0.003
Soft-DTW490.119 ± 0.0050.043 ± 0.0030.027 ± 0.0030.126 ± 0.0080.082 ± 0.0060.061 ± 0.005
Concat1740.135 ± 0.0040.073 ± 0.0070.045 ± 0.0060.126 ± 0.0080.082 ± 0.0060.061 ± 0.005
HTS-Cluster340.134 ± 0.0050.075 ± 0.0050.041 ± 0.0040.128 ± 0.0140.064 ± 0.0050.065 ± 0.002
Table 2. Level-wise clustering results on HTS with multiple aggregated levels. On the left are the results on simulated data while the right shows the results on real-world user financial record data. Since cluster labels are not available for the financial data, scores obtained from a weak proxy are lower than expected.
Table 2. Level-wise clustering results on HTS with multiple aggregated levels. On the left are the results on simulated data while the right shows the results on real-world user financial record data. Since cluster labels are not available for the financial data, scores obtained from a weak proxy are lower than expected.
LevelMetricSimulationFinancial Record
DTCRSoft-DTWConcatHTS-ClusterDTCRSoft-DTWConcatHTS-Cluster
1NMI0.280.3130.3420.3560.0370.1240.1560.154
AMI0.2430.2770.3010.3220.0210.0790.1120.106
ARI0.2210.2650.2850.3040.0090.0560.0940.092
2NMI0.2980.3170.3570.3750.0560.1160.1470.152
AMI0.2710.2820.3140.3460.0340.0870.1150.121
ARI0.2360.2590.3020.3170.0160.0340.0830.092
3NMI0.2720.3240.3640.3720.0550.1340.1630.172
AMI0.2340.2950.3220.330.0280.0980.1320.141
ARI0.2170.2680.3070.3090.0120.0570.1060.113
4NMI0.3030.3690.3690.3690.0760.1360.1360.136
AMI0.2750.3410.3410.3410.0430.1020.1020.102
ARI0.2640.3160.3160.3160.0260.0610.0610.061
Table 3. Left: level-wise computation time of different clustering approaches, DTCR is excluded since it is not a level-wise approach and requires a much longer time. Right: forecasting massive HTS with the help of clustering, results are measured by MASE and relative computing time. Results are averaged across ten runs on four-level simulated HTS.
Table 3. Left: level-wise computation time of different clustering approaches, DTCR is excluded since it is not a level-wise approach and requires a much longer time. Right: forecasting massive HTS with the help of clustering, results are measured by MASE and relative computing time. Results are averaged across ten runs on four-level simulated HTS.
Method/Level1234Total Time
Without cluster62.3976.2678.2584.141
Engproc 39 00031 i001DTCR82.3596.09104.85104.330.39
Soft-DTW78.6193.0493.1296.760.27
Concat74.2484.6583.7396.760.57
HTS-Cluster72.9980.0785.2996.760.16
Table 4. HTS-Cluster can be used to improve HTS forecasting when a large number of forecasts are required. Results are measured by the mean absolute scaled error (MASE, the lower the better) using two multivariate time series models. Both Wiki and M5 possess a single hierarchy with many time series; we cluster “sub-trees” at the bottom two levels (out of five) of Wiki and the bottom three levels (out of twelve; we only show levels eight to twelve) of M5 to reduce the total number of time series to be modelled.
Table 4. HTS-Cluster can be used to improve HTS forecasting when a large number of forecasts are required. Results are measured by the mean absolute scaled error (MASE, the lower the better) using two multivariate time series models. Both Wiki and M5 possess a single hierarchy with many time series; we cluster “sub-trees” at the bottom two levels (out of five) of Wiki and the bottom three levels (out of twelve; we only show levels eight to twelve) of M5 to reduce the total number of time series to be modelled.
DatasetWikiM5
Levels1234589101112
LSTNet76.3676.8979.6581.1386.2263.7469.4373.3576.4682.36
LSTNet-Cluster76.3376.5677.6878.0795.1662.4869.1471.1176.5298.78
DeepAR73.9874.5477.4279.1284.7759.3667.1872.0476.4180.24
DeepAR-Cluster74.2174.3777.3677.5689.6758.7465.4674.3975.0490.49
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

Han, X.; Ren, T.; Hu, J.; Ghosh, J.; Ho, N. Efficient Forecasting of Large-Scale Hierarchical Time Series via Multilevel Clustering. Eng. Proc. 2023, 39, 31. https://doi.org/10.3390/engproc2023039031

AMA Style

Han X, Ren T, Hu J, Ghosh J, Ho N. Efficient Forecasting of Large-Scale Hierarchical Time Series via Multilevel Clustering. Engineering Proceedings. 2023; 39(1):31. https://doi.org/10.3390/engproc2023039031

Chicago/Turabian Style

Han, Xing, Tongzheng Ren, Jing Hu, Joydeep Ghosh, and Nhat Ho. 2023. "Efficient Forecasting of Large-Scale Hierarchical Time Series via Multilevel Clustering" Engineering Proceedings 39, no. 1: 31. https://doi.org/10.3390/engproc2023039031

Article Metrics

Back to TopTop