Signature calculator module
The signature_calculator module implements path signature computation using the roughpy library with Lie increment calculations. Path signatures provide a mathematically rigourous framework for capturing geometric and temporal features of advertising creative performance data, enabling detection of creative fatigue patterns in advertising campaigns.
Mathematical Foundation
Section titled “Mathematical Foundation”The module computes signatures as elements of the free Lie algebra, which offers computational efficiency while maintaining the full expressiveness of tensor algebra representations. For a d-dimensional path X:[0,T] → ℝ^d, the signature S(X) encodes:
- Level 1: Path increments (directional changes)
- Level 2: Signed areas and path curvature
- Higher levels: Complex geometric interactions
Key Implementation Details
Section titled “Key Implementation Details”- Lie Increments: Uses
roughpywith Lie algebra computations rather than tensor products - Normalization: All paths are normalized to [0,1]×[0,1] before signature computation
- Numerical Stability: Adds ε=10^-8 to prevent division by zero for constant metrics
- Default Parameters:
- Signature depth: 2 (captures up to quadratic variations)
- Window size: 7 (weekly patterns in daily data)
Core Functions
Section titled “Core Functions”Public functions and classes are available under creativedynamics.core.signature_calculator.
Usage Example
Section titled “Usage Example”from creativedynamics.core.signature_calculator import SignatureCalculator
# Initialize calculatorcalc = SignatureCalculator(depth=2)
# Compute signature for a time seriesimport numpy as nptime_series = np.array([1.0, 1.2, 1.1, 1.3, 1.4, 1.2, 1.0])signature = calc.compute_signature(time_series)
# The signature is a vector containing Lie increments# that capture the geometric properties of the pathAlgorithm Complexity
Section titled “Algorithm Complexity”The computational complexity for signature calculation is O(T·d²) where:
- T is the length of the time series
- d is the signature depth
- This assumes a fixed window size w
This efficiency enables real-time analysis of advertising performance data at scale.