Introduction
sktime is an open-source Python library that extends the scikit-learn API to time series data. It provides a unified interface for multiple time series learning tasks, making it straightforward to apply, compare, and compose algorithms across forecasting, classification, regression, clustering, and annotation.
What sktime Does
- Provides scikit-learn-compatible estimators for time series forecasting, classification, and clustering
- Supports pipeline composition with transformers, feature extractors, and reducers
- Implements model selection tools including cross-validation strategies for temporal data
- Offers adapters to integrate algorithms from statsmodels, Prophet, and other libraries
- Includes benchmark datasets and evaluation utilities for reproducible experiments
Architecture Overview
sktime is built around a base class hierarchy that mirrors scikit-learn's estimator pattern. Each task type (forecaster, classifier, transformer) implements fit, predict, and transform methods with type-checked inputs. Pipelines chain transformers and estimators, while reduction strategies convert between task types (e.g., forecasting via regression). The framework uses a tagged object system for capability discovery.
Self-Hosting & Configuration
- Install via
pip install sktimeorconda install -c conda-forge sktime - Use extras for optional dependencies:
pip install sktime[all_extras] - Configure forecasters with
fh(forecasting horizon) as integer, list, orForecastingHorizonobject - Set up cross-validation with
SlidingWindowSplitterorExpandingWindowSplitter - Integrate with MLflow or other tracking tools using standard scikit-learn patterns
Key Features
- Consistent API across all time series tasks following scikit-learn conventions
- Composable pipelines with time series-specific transformers and reducers
- Extensive algorithm library covering classical, ML, and deep learning methods
- Built-in temporal cross-validation and performance metrics
- Active community with regular releases and comprehensive documentation
Comparison with Similar Tools
- Darts — Focused on forecasting with deep learning; sktime covers more task types
- tsfresh — Specializes in feature extraction; sktime provides a full ML pipeline
- statsmodels — Statistical models only; sktime wraps statsmodels and adds ML workflows
- scikit-learn — General ML; sktime adds time series-specific data types and methods
FAQ
Q: Is sktime compatible with scikit-learn? A: Yes. sktime follows scikit-learn's estimator interface, so pipelines, grid search, and cross-validation patterns work similarly.
Q: Can I use deep learning models with sktime? A: Yes. sktime integrates with PyTorch and TensorFlow through adapter classes and supports neural network forecasters.
Q: How does sktime handle panel (multi-instance) data? A: sktime uses a multi-index pandas DataFrame format for panel data, with instance and time indices.
Q: What license does sktime use? A: sktime is released under the BSD 3-Clause license.