Kalax is a high-performance Rust library for Time Series Feature Extraction, designed to extract meaningful statistical and structural features from time series data.
Origin of the Name
Kalax is a portmanteau of two Sanskrit concepts, representing the essence of time-series analysis:
- Kāla (काल): Time — The fundamental flow and dimension of data.
- Lakṣaṇa (लक्षण): Feature — The distinctive marks and characteristics of a dataset.
The terminal "x" stands for Extraction. Together, Kalax signifies the "Signs of Time," reflecting our mission to distill raw temporal data into meaningful, high-performance features using Rust.
Features
- Statistical Features: Mean, median, variance, standard deviation, minimum, maximum, absolute maximum, root mean square, sum values, and length
- Dual API Design: Both functional and object-oriented APIs for flexibility
- High Performance: Optimized for time series operations on
&[f64]slices with parallel processing - Type Safety: Strong typing throughout the library with comprehensive error handling
- Memory Efficient: Minimal allocations in hot paths, designed for large datasets
- Batch Processing: Extract features from multiple time series efficiently using parallel execution
Installation
Add Kalax to your Cargo.toml:
[]
= "0.1.0"
Usage
Kalax provides two API styles: functional and object-oriented.
Functional API
Simple function calls for individual features:
use ;
let time_series = vec!;
let mean_value = mean;
let variance_value = variance;
let std_dev = standard_deviation;
println!; // 3.0
println!; // 2.0
println!; // ~1.414
Object-Oriented API
Use the FeatureFunction trait for more structured code:
use ;
let time_series = vec!;
let result = DEFAULT.apply;
println!; // mean: 3.0
Extract All Minimal Features
Use MinimalFeatureSet to extract all supported features at once:
use ;
let time_series = vec!;
let features = new.apply;
for feature in features
// Output: absolute_maximum, mean, median, variance, standard_deviation,
// length, maximum, minimum, root_mean_square, sum_values
Batch Processing
Process multiple time series efficiently using the extractor:
use HashMap;
use extract_features;
// Prepare data as a vector of HashMaps (column name -> time series values)
let data = vec!;
// Extract features in parallel
let results = extract_features;
// results[0]["sensor1"] contains features for sensor1 from the first series
// results[1]["sensor2"] contains features for sensor2 from the second series
Available Features
All features are available through both the functional and OOP APIs.
Statistical Features
- Mean: Average value of the time series
- Median: Middle value when sorted
- Variance: Measure of spread
- Standard Deviation: Square root of variance
- Minimum: Smallest value
- Maximum: Largest value
- Absolute Maximum: Largest absolute value
- Root Mean Square: RMS value
- Sum Values: Sum of all values
- Length: Number of data points
API Styles
Functional API
Import and call functions directly:
use ;
let m = mean;
OOP API
Use feature structs and the FeatureFunction trait:
use ;
let result = DEFAULT.apply;
Performance
Kalax is designed for high-performance time series analysis:
- Parallel Processing: Uses Rayon for parallel feature extraction across multiple time series
- Memory Efficient: Minimal allocations in feature extraction
- Optimized Algorithms: Efficient implementations of statistical features
- Zero-Copy Operations: Operates on
&[f64]slices without copying data - Scalable: Handles large datasets effectively with batch processing
Testing
Run the test suite:
# Run all tests
# Run specific test
# Show test output
Development
Building
Linting and Formatting
Documentation
API Design Philosophy
Kalax provides two API styles to accommodate different use cases:
- Functional API: Best for simple, one-off feature extraction where you need direct access to specific features
- OOP API: Best when you need consistent interfaces, want to chain features, or need to work with feature collections
Both APIs provide identical performance; the choice is primarily about code organization and developer preference.
License
This project is licensed under the LICENSE file.
Contributing
Contributions are welcome! Please ensure:
- Code follows Rust conventions and passes
cargo clippy - All tests pass
- Documentation is updated for new features
- New features include both functional and OOP implementations
Comparison with tsfresh
Kalax provides a subset of features comparable to Python's tsfresh library, with focus on core statistical features. Key advantages:
- Better Performance: Rust's zero-cost abstractions, efficient memory management, and parallel processing
- Type Safety: Compile-time guarantees and comprehensive error handling
- Memory Efficiency: Minimal allocations and optimized data structures
- Dual API: Both functional and object-oriented APIs for flexibility
- Validation: Features tested against tsfresh reference implementation for correctness