Abstract
Signature kernels provide a robust mathematical framework for analyzing time series data by capturing the geometric properties of sequential paths. However, their adoption has been limited by high computational costs that scale quadratically with sequence length and sample size. This paper introduces KSig, a high-performance Python library designed to overcome these barriers through GPU acceleration and novel randomized approximations. By implementing optimized "dual" kernels and scalable "primal" feature-map approaches, KSig enables the analysis of time series up to 100x longer than previously feasible.
1. Introduction
In the domain of machine learning for sequential data, the "signature" of a path serves as a powerful descriptor, offering invariance to reparameterization and robustness to varying sampling rates. Despite these theoretical advantages, signature kernels have historically suffered from a "quadratic curse." Traditional exact methods scale quadratically ($O(L^2)$) with the length of the sequences ($L$) and the number of samples ($N$), making them computationally prohibitive for large-scale datasets.
KSig addresses this bottleneck by providing a Scikit-Learn compatible interface that leverages GPU acceleration (via Numba and CUDA JIT) and introduces efficient approximation techniques. The library allows researchers to transition from small-scale experiments to "big data" time series analysis without sacrificing the theoretical rigor of the signature framework.
2. Methodology
KSig categorizes signature kernel computation into two primary routes: the exact Dual Approach and the approximate Primal Approach.
2.1 The Dual Approach (Exact)
The dual approach involves computing the kernel matrix directly. KSig optimizes the classic recursive algorithm and PDE-based solvers using CUDA JIT. A significant innovation in KSig's implementation is the reduction of the memory footprint for PDE solvers; by retaining only the necessary "antidiagonals" of the computation matrix in memory, the library maximizes the utility of limited GPU VRAM.
2.2 The Primal Approach (Approximate)
To achieve linear scaling, KSig utilizes Random Fourier Signature Features (RFSF) to create low-dimensional feature maps ($\Phi$). This transforms the problem into a linear one, where the kernel is approximated by the inner product of these maps. To manage the dimensionality of these maps, KSig implements three projection techniques:
- Diagonal Projection (DP): A method that averages independent RFSF samples, noted for its low memory footprint.
- Tensor Random Projection (TRP): Utilizes factorized Gaussian tensors to project features.
- Tensor Sketch (TS): The paper’s primary algorithmic contribution. TS employs Count Sketches and Fast Fourier Transforms (FFTs) to implement tensor products as circular convolutions. This method is computationally more efficient than TRP while maintaining high approximation accuracy.
3. Experimental Setup
The authors benchmarked KSig using three distinct data types to evaluate performance, scalability, and accuracy:
- FingerMovements (UEA Archive): EEG recordings used to assess real-world classification performance.
- PenDigits (UEA Archive): A handwritten digit dataset used to test the scalability of the library's linear SVM wrapper.
- Synthetic Brownian Motion: $d$-dimensional paths used to measure runtime and memory usage against varying sequence lengths ($L$) and sample sizes ($N$).
4. Key Results and Insights
4.1 Scalability and Speed
The most significant finding is the scalability gap between traditional and KSig-optimized methods. While dual methods typically fail due to memory exhaustion at sequence lengths of $L \approx 10^3$, KSig’s primal methods (specifically RFSF-TS) handle sequences where $L \geq 10^5$. On an NVIDIA A100 GPU, computing the Gram matrix for the FingerMovements dataset required only 2.3 seconds.
4.2 Accuracy and Performance
On the FingerMovements classification task, KSig achieved an accuracy of 0.60, surpassing the previous state-of-the-art benchmark of 0.56. Furthermore, the Diagonal Projection (DP) methods demonstrated the lowest Mean Absolute Percentage Error (MAPE) when operating under strict memory constraints, making it the recommended "economic" choice for large-scale problems.
5. Conclusion and Future Work
KSig represents a significant step forward in making signature-based methods accessible for modern data science. By shifting the computational burden to the GPU and providing scalable approximations like Tensor Sketch, the library enables the processing of millions of time series.
Future development of KSig aims to address remaining bottlenecks, such as the memory cost of initial "static" kernel evaluations for extremely long sequences. Additionally, the authors propose exploring "forgetting" mechanisms to weight recent events more heavily and extending these kernels to non-Euclidean domains, such as graph-structured data.
Availability: The KSig package is open-source and available at https://github.com/tgcsaba/ksig.
Summary updated