Registry / ai-ml / sktime

sktime

JSON →
library1.1.0pypypi✓ verified 22d ago

sktime is a Python library for machine learning with time series. It provides a unified interface for various time series tasks, including forecasting, classification, regression, and transformation. It integrates seamlessly with `scikit-learn` and offers a modular architecture for building complex time series pipelines. The project is actively maintained with frequent minor and patch releases, typically every few weeks.

pip install sktime
INSTALL
IMPORT
SIG · SKTIME
S
sktime
ai-mlpythonv1.1.0
Install
27.0s avg
Import
6907ms
Disk
522MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.915 runs
build_error
glibc
py 3.103.915 runs
installs and imports cleanly · install 27.0s · import 6.907s · 432MB
522MB installed
● package 522MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Forecaster
from sktime.forecasting.base import BaseForecaster
from sktime.forecasting.model_selection import ForecastingGridSearchCV
Users often mistake `model_selection` for base estimator imports. Estimators are generally in `sktime.<task>.<model_name>`.
ThetaForecaster
from sktime.forecasting.theta import ThetaForecaster
temporal_train_test_split
from sktime.forecasting.model_selection import temporal_train_test_split
StandardScaler
from sktime.transformations.series.scaling import StandardScaler

This quickstart demonstrates a basic time series forecasting workflow using `sktime`. It covers data preparation, model initialization, fitting, and prediction with the `ThetaForecaster`. Note that plotting requires the `matplotlib` library, which is an optional dependency.

import pandas as pd from sktime.forecasting.model_selection import temporal_train_test_split from sktime.forecasting.theta import ThetaForecaster from sktime.utils.plotting import plot_series # requires 'matplotlib' optional dependency # 1. Data loading and splitting y = pd.Series([10, 12, 13, 15, 18, 20, 22, 25, 28, 30]) y.index = pd.to_datetime(pd.date_range("2020-01-01", periods=10, freq="M")) y_train, y_test = temporal_train_test_split(y, test_size=3) # 2. Model selection and fitting forecaster = ThetaForecaster(sp=1) forecaster.fit(y_train) # 3. Prediction fh = [1, 2, 3] # forecast horizon for next 3 periods y_pred = forecaster.predict(fh=fh) print("Training data:\n", y_train) print("Test data:\n", y_test) print("Predictions:\n", y_pred) # To plot, ensure matplotlib is installed (pip install matplotlib) # plot_series(y_train, y_test, y_pred, labels=["y_train", "y_test", "y_pred"])
Debug
Known issues
gotchasktime relies heavily on 'soft dependencies'. Many estimators (especially advanced or classical statistical models) require additional packages that are not installed by default with `pip install sktime`. Attempting to use these estimators without their dependencies will result in `ModuleNotFoundError` or similar.
fix
Install `sktime` with specific extras, e.g., `pip install sktime[forecasting]` or `pip install sktime[all_extras]` to ensure all necessary dependencies for your desired models are present.
affects: All versions
breakingsktime undergoes regular API refinements and deprecations. Features, classes, or functions marked for deprecation in one release are often removed in subsequent major/minor releases (e.g., 0.38.0, 0.39.0 introduced scheduled deprecations).
fix
Always check the official `sktime` changelog and release notes when upgrading versions. Pay close attention to deprecation warnings in your code and update your imports/API calls accordingly.
affects: 0.38.x, 0.39.x, 0.40.x and newer
gotchasktime has specific Python version requirements (currently `>=3.10, <3.15`). Using an unsupported Python version can lead to installation issues or runtime errors, particularly with dependencies.
fix
Ensure your Python environment meets the `sktime`'s `requires_python` specification. Use a virtual environment to manage dependencies and Python versions.
affects: All versions after 0.39.x
gotchaCompatibility with `scikit-learn` versions can be sensitive. Hotfixes are frequently released to address `scikit-learn` version updates (e.g., 0.38.1 for `scikit-learn 1.7`).
fix
If encountering issues after a `scikit-learn` upgrade, check `sktime`'s latest patch releases for compatibility fixes. Consider pinning `scikit-learn` to a known compatible version in production environments.
affects: All versions, particularly sensitive to new `scikit-learn` releases.
Errors
Common errors & fixes
ValueError: X must be a pd.Series or pd.DataFrame, but found type <class 'numpy.ndarray'>
sktime estimators strictly expect input data X and target variable y to be pandas Series or DataFrame objects with a time-like index (e.g., pd.DatetimeIndex, pd.PeriodIndex, or pd.RangeIndex).
fix
Convert your input data to the correct pandas type with an appropriate index before passing it to fit or predict.

```python
import pandas as pd
import numpy as np

# Assuming X_np is a numpy array and y_np is another
X_np = np.random.rand(10, 3)
y_np = np.random.rand(10)

# For X (features):
X_correct = pd.DataFrame(X_np, index=pd.date_range(start='2023-01-01', periods=len(X_np), freq='D'))

# For y (target):
y_correct = pd.Series(y_np, index=pd.date_range(start='2023-01-01', periods=len(y_np), freq='D'))

# If you only have a list or array for y and it's univariate
# y_correct = pd.Series([1, 2, 3], index=pd.RangeIndex(start=0, stop=3)) # Simple integer index
```
ModuleNotFoundError: No module named 'sktime.transformations.panel.tsfresh'
The TSFreshFeatureExtractor transformer relies on the optional `tsfresh` package, which is not installed by default with sktime.
fix
Install the `tsfresh` package separately.

```bash
pip install tsfresh
# or install sktime with its tsfresh extras to include it:
# pip install sktime[tsfresh]
```
ModuleNotFoundError: No module named 'pmdarima'
The `AutoARIMA` forecaster in sktime relies on the `pmdarima` library, which is an optional dependency and must be installed separately.
fix
Install the `pmdarima` package.

```bash
pip install pmdarima
# or install sktime with its arima extras to include it:
# pip install sktime[arima]
```
ValueError: The forecast horizon must not contain values in the past relative to the last observation in y.
The forecast horizon (fh) passed to the `predict` method must contain future time points relative to the end of the training data `y`. Providing an `fh` that overlaps with or precedes the training data will result in this error.
fix
Ensure `fh` specifies future time points. It can be a relative integer array (e.g., `[1, 2, 3]`), a `pd.PeriodIndex`, or `pd.DatetimeIndex` representing dates strictly after the training data's end.

```python
import pandas as pd
from sktime.forecasting.naive import NaiveForecaster

# Example training data
y_train = pd.Series([10, 12, 15, 13, 16], index=pd.to_datetime(['2023-01-01', '2023-01-02', '2023-01-03', '2023-01-04', '2023-01-05']))

forecaster = NaiveForecaster()
forecaster.fit(y_train)

# Correct fix: relative forecast horizon (1, 2, 3 steps ahead)
fh_relative = [1, 2, 3]
y_pred_relative = forecaster.predict(fh=fh_relative)

# Correct fix: absolute forecast horizon (dates must be in the future)
last_date = y_train.index[-1]
fh_absolute = pd.to_datetime([last_date + pd.Timedelta(days=1), last_date + pd.Timedelta(days=2)])
y_pred_absolute = forecaster.predict(fh=fh_absolute)
```
Upgrade
Version history
1.1.0latest on PyPI · released Jul 28, 2026
Audit
Dependencies
scikit-learnrequiredCore dependency for API compatibility and transformers.
numpyrequiredCore numerical operations.
pandasrequiredData handling.
statsmodelsoptionalMany classical forecasting models and statistical tests.
pmdarimaoptionalAuto ARIMA forecasting.
numbaoptionalPerformance critical operations for some estimators.
tensorflowoptionalDeep learning models (e.g., InceptionTime, LSTMForecaster).
torchoptionalDeep learning models (e.g., ChronosForecaster, TinyTimeMixerForecaster).
Agent activity
16 hits · last 30 days
node
12
OpenAI (training)
1
Resources
sktime — pip install sktime · libregistry