21 releases
| new 0.2.0 | Feb 15, 2026 |
|---|---|
| 0.1.3 | Jan 26, 2026 |
| 0.1.1 | Dec 30, 2025 |
| 0.1.0-rc.2 | Oct 19, 2025 |
| 0.1.0-alpha.6 | Jun 25, 2025 |
#26 in Machine learning
2,059 downloads per month
Used in 27 crates
(3 directly)
23MB
489K
SLoC
SciRS2 Series
Production-ready time series analysis module for the SciRS2 scientific computing library (v0.1.5). Following the SciRS2 POLICY, this Stable Release provides comprehensive, tested, and optimized tools for analyzing, decomposing, and forecasting time series data with feature parity to leading Python libraries, zero-warning code quality, and ecosystem consistency through scirs2-core abstractions.
Features
Core Capabilities:
- Advanced Decomposition: STL, TBATS, SSA, STR, Multi-seasonal decomposition, Robust variants
- State-of-the-Art Forecasting: ARIMA/SARIMA, Auto-ARIMA, Exponential Smoothing (ETS), Holt-Winters
- Comprehensive Analysis: Autocorrelation, partial autocorrelation, cross-correlation functions
- Change Point & Anomaly Detection: PELT, CUSUM, Bayesian online detection, multiple anomaly methods
- Feature Engineering: 60+ statistical, frequency, and complexity features with automated selection
- Transformations: Box-Cox, differencing, normalization, stationarity tests
- State-Space Models: Kalman filtering, structural time series, dynamic linear models
- Causality Analysis: Granger causality, transfer entropy, causal impact analysis
- Dimensionality Reduction: PCA, functional PCA, symbolic approximation
- Clustering & Classification: Time series clustering, DTW-based methods, shapelet discovery
Production Features:
- Zero-warning Codebase: All clippy warnings resolved, production-ready code quality
- Comprehensive Testing: 137 unit tests, 43 doc tests, 100% core functionality coverage
- Performance Optimized: SIMD acceleration, parallel processing, memory-efficient algorithms
- Rust Ecosystem Integration: Full ndarray support, compatible with scientific Rust ecosystem
Installation
Stable Release - Production Ready
Add the following to your Cargo.toml:
[dependencies]
scirs2-series = "0.1.5"
Recommended for Production: Enable performance optimizations:
[dependencies]
scirs2-series = { version = "0.1.5", features = ["parallel", "simd"] }
scirs2-core = { version = "0.1.5", features = ["parallel", "simd"] }
Available Features:
parallel: Multi-threaded processing for large datasetssimd: SIMD acceleration for numerical operationscaching: Advanced caching for repeated computations
Usage
Basic usage examples:
use scirs2_series::{utils, decomposition, forecasting, features};
use scirs2_core::error::CoreResult;
use scirs2_core::ndarray::array;
// Create a simple time series
fn time_series_example() -> CoreResult<()> {
// Sample time series data
let data = array![10.0, 11.0, 12.0, 11.5, 11.0, 10.5, 11.2, 12.5, 13.0, 12.7,
12.0, 11.8, 12.2, 13.5, 14.0, 13.5, 13.0, 12.5, 13.0, 14.5];
// Autocorrelation
let acf = utils::autocorrelation(&data, 5)?;
println!("Autocorrelation: {:?}", acf);
// Partial autocorrelation
let pacf = utils::partial_autocorrelation(&data, 5)?;
println!("Partial autocorrelation: {:?}", pacf);
// Decompose time series
let decomposition = decomposition::seasonal_decompose(&data, 4, None, None)?;
println!("Trend: {:?}", decomposition.trend);
println!("Seasonal: {:?}", decomposition.seasonal);
println!("Residual: {:?}", decomposition.resid);
// Extract features
let mean = features::mean(&data)?;
let std_dev = features::standard_deviation(&data)?;
let min = features::minimum(&data)?;
let max = features::maximum(&data)?;
println!("Time series features:");
println!("Mean: {}", mean);
println!("Standard deviation: {}", std_dev);
println!("Min: {}", min);
println!("Max: {}", max);
// Forecast future values (simple moving average)
let forecast = forecasting::moving_average_forecast(&data, 3, 5)?;
println!("Forecast (next 5 points): {:?}", forecast);
Ok(())
}
Components
Time Series Utilities
Functions for time series analysis:
use scirs2_series::utils::{
autocorrelation, // Calculate autocorrelation function
partial_autocorrelation, // Calculate partial autocorrelation function
cross_correlation, // Calculate cross-correlation between two series
lag_plot, // Create lag plot data
seasonal_plot, // Create seasonal plot data
difference, // Difference a time series
seasonal_difference, // Apply seasonal differencing
inverse_difference, // Invert differencing
lag_series, // Create lagged versions of a time series
};
Decomposition
Methods for time series decomposition:
use scirs2_series::decomposition::{
seasonal_decompose, // Seasonal decomposition (additive or multiplicative)
stl_decompose, // STL decomposition (Seasonal-Trend decomposition using LOESS)
hp_filter, // Hodrick-Prescott filter
};
Forecasting
Time series forecasting methods:
use scirs2_series::forecasting::{
moving_average_forecast, // Moving average forecast
exponential_smoothing, // Simple exponential smoothing
double_exponential_smoothing, // Double exponential smoothing (Holt's method)
triple_exponential_smoothing, // Triple exponential smoothing (Holt-Winters method)
arima_forecast, // ARIMA forecast
sarima_forecast, // Seasonal ARIMA forecast
};
Feature Extraction
Functions for extracting features from time series:
use scirs2_series::features::{
// Basic Statistics
mean, // Calculate mean
standard_deviation, // Calculate standard deviation
minimum, // Find minimum value
maximum, // Find maximum value
// Trend Features
trend_strength, // Calculate trend strength
seasonality_strength, // Calculate seasonality strength
// Complexity Measures
entropy, // Calculate entropy
approximate_entropy, // Calculate approximate entropy
sample_entropy, // Calculate sample entropy
// Spectral Features
spectral_entropy, // Calculate spectral entropy
dominant_frequency, // Find dominant frequency
// Other Features
turning_points, // Count turning points
crossing_points, // Count crossing points
autocorrelation_features, // Extract autocorrelation features
};
Advanced Features
STL Decomposition
Seasonal-Trend decomposition using LOESS (STL):
use scirs2_series::decomposition::stl_decompose;
use scirs2_core::ndarray::Array1;
// Sample time series
let data = Array1::from_vec(vec![/* time series data */]);
// STL decomposition parameters
let period = 12; // For monthly data
let robust = true;
let seasonal_degree = 1;
let seasonal_jump = 1;
let seasonal_window = 13;
let trend_degree = 1;
let trend_jump = 1;
let trend_window = 21;
let inner_iter = 2;
let outer_iter = 1;
// Perform STL decomposition
let decomposition = stl_decompose(&data, period, robust,
seasonal_degree, seasonal_jump, seasonal_window,
trend_degree, trend_jump, trend_window,
inner_iter, outer_iter).unwrap();
println!("Trend component: {:?}", decomposition.trend);
println!("Seasonal component: {:?}", decomposition.seasonal);
println!("Residual component: {:?}", decomposition.resid);
ARIMA Forecasting
Autoregressive Integrated Moving Average (ARIMA) model:
use scirs2_series::forecasting::arima_forecast;
use scirs2_core::ndarray::Array1;
// Sample time series
let data = Array1::from_vec(vec![/* time series data */]);
// ARIMA parameters
let p = 1; // AR order
let d = 1; // Differencing order
let q = 1; // MA order
// Forecast horizon
let steps = 10;
// Perform ARIMA forecast
let (forecast, conf_intervals) = arima_forecast(&data, p, d, q, steps, 0.95).unwrap();
println!("ARIMA({},{},{}) forecast: {:?}", p, d, q, forecast);
println!("95% confidence intervals: {:?}", conf_intervals);
Contributing
See the CONTRIBUTING.md file for contribution guidelines.
License
This project is Licensed under the Apache License 2.0. See LICENSE for details.
You can choose to use either license. See the LICENSE file for details.
Dependencies
~20–39MB
~653K SLoC