Representation Learning of Tangled Key-Value Sequence Data for Early Classification

Tao Duan, Junzhou Zhao, Shuo Zhang, Jing Tao, Pinghui Wang

Abstract

In many real-world streaming scenarios, data arrives as a "tangled" sequence where multiple independent streams—such as network flows or user sessions—are interleaved. Traditional Time Series Early Classification (TSEC) methods often fail in these environments because they assume sequence independence, ignoring valuable inter-sequence correlations. This paper introduces KVEC (Key-Value sequence Early Co-classification), a framework that leverages both intra-sequence and inter-sequence relationships to achieve high-accuracy classification at the earliest possible stage. By combining a novel representation learning module with a reinforcement learning-based halting policy, KVEC outperforms state-of-the-art methods by up to 17.5% in early-stage accuracy.

Introduction

Time-sensitive applications, ranging from cyber-attack detection to real-time product recommendations, rely on the ability to classify data streams as early as possible. However, early classification presents a fundamental trade-off: waiting for more data increases classification accuracy but sacrifices the benefits of early intervention. This challenge is compounded in "tangled" data environments where a single stream contains interleaved data from various sources (keys). Existing models typically treat this tangledness as noise, processing each key in isolation. This paper argues that the temporal proximity of different keys—inter-sequence correlation—is actually a critical feature for improving representation learning when data for a specific key is scarce.

The KVEC Framework

The KVEC framework is composed of two synergistic modules designed to handle the complexities of tangled key-value sequences.

1. Key-Value Representation Learning (KVRL)

The KVRL module is responsible for extracting meaningful features from the tangled stream. Unlike standard sequence models, KVRL employs a specialized attention mechanism that distinguishes between two types of relationships:

  • Key Correlation (Intra-sequence): This captures the internal logic and patterns within items sharing the same key.
  • Value Correlation (Inter-sequence): This captures relationships between items that appear close together in time across different keys. These "bursts" of activity often signify shared context, such as a coordinated network event or a localized trend among different users.

To maintain temporal integrity, the module utilizes a dynamic mask matrix. This ensures causality (the model only looks at past data) while specifically focusing the attention mechanism on relevant key/value correlations to denoise the stream.

2. Early Co-classification Timing Learning (ECTL)

The ECTL module serves as the decision-making engine that determines the optimal moment to stop data collection and issue a classification. This is framed as a reinforcement learning problem using the REINFORCE algorithm. At each time step, the agent chooses between two actions:

  • Wait: Continue observing the stream to gather more information.
  • Halt: Stop and provide a classification based on the current representation.

The policy is optimized through a reward function that balances accuracy and earliness, penalizing the model for both incorrect predictions and excessive delays.

Experimental Evaluation

The authors evaluated KVEC across five diverse datasets, including public network traffic (USTC-TFC2016), user profiling (MovieLens-1M), and encrypted campus traffic (Traffic-FG and Traffic-App). A synthetic dataset was also utilized to test the halting policy's sensitivity to specific "stop signals."

Key Results

  • Superior Early Performance: KVEC demonstrated its greatest strengths in the "very early" stages of data collection (when only 2-8% of a sequence was available). In network traffic tasks, it improved accuracy by 4.7% to 17.5% over competitive baselines like EARLIEST.
  • Optimized Trade-offs: Using the Harmonic Mean (HM) of accuracy and earliness as a metric, KVEC showed improvements of 3.7% to 14.0%, indicating a more efficient balance between speed and precision.
  • Ablation Insights: The inclusion of "Value Correlation" was found to be the most critical component of the model. Removing inter-sequence attention led to the most significant drops in performance, confirming that the "tangled" nature of the data is a vital source of information rather than mere noise.

Discussion and Conclusion

A critical finding of this research is the necessity of synchronous training; the KVRL and ECTL modules must be trained together because the halting policy relies on the classifier's real-time confidence to learn the optimal stopping point.

While KVEC is highly effective, the authors note a potential limitation: as the number of concurrent sequences ($K$) grows extremely large, the inter-sequence correlations can introduce excessive noise. Future work will focus on developing more sophisticated filtering mechanisms to maintain performance in high-density tangled streams. Overall, KVEC represents a significant step forward in making early classification robust for complex, real-world data environments.

Summary updated

Abstract

Key-value sequence data has become ubiquitous and naturally appears in a variety of real-world applications, ranging from the user-product purchasing sequences in e-commerce, to network packet sequences forwarded by routers in networking. Classifying these key-value sequences is important in many scenarios such as user profiling and malicious applications identification. In many time-sensitive scenarios, besides the requirement of classifying a key-value sequence accurately, it is also desired to classify a key-value sequence early, in order to respond fast. However, these two goals are conflicting in nature, and it is challenging to achieve them simultaneously. In this work, we formulate a novel tangled key-value sequence early classification problem, where a tangled key-value sequence is a mixture of several concurrent key-value sequences with different keys. The goal is to classify each individual key-value sequence sharing a same key both accurately and early. To address this problem, we propose a novel method, i.e., Key-Value sequence Early Co-classification (KVEC), which leverages both inner- and inter-correlations of items in a tangled key-value sequence through key correlation and value correlation to learn a better sequence representation. Meanwhile, a time-aware halting policy decides when to stop the ongoing key-value sequence and classify it based on current sequence representation. Experiments on both real-world and synthetic datasets demonstrate that our method outperforms the state-of-the-art baselines significantly. KVEC improves the prediction accuracy by up to 4.7 -17.5% under the same prediction earliness condition, and improves the harmonic mean of accuracy and earliness by up to 3.7 -14.0%.
BibTeX
@inproceedings{duan2024representation,
  author = {Tao Duan and Junzhou Zhao and Shuo Zhang and Jing Tao and Pinghui Wang},
  title = {{Representation Learning of Tangled Key-Value Sequence Data for Early Classification}},
  booktitle = {ICDE},
  year = {2024},
  url = {https://openreview.net/forum?id=lpu57jTaTT},
}
Figure