tsmoothie

raw JSON →
1.0.5 verified Fri May 01 auth: no python

A Python library for timeseries smoothing and outlier detection in a vectorized way. It provides multiple smoothing techniques (e.g., Convolutional, Exponential, Lowess, Kalman, Spectral) and outlier detection methods. Current version is 1.0.5. Release cadence is intermittent.

pip install tsmoothie
error ImportError: cannot import name 'ConvolutionalSmoother' from 'tsmoothie'
cause The import path changed in v1.0.2; you need to import from submodule.
fix
Use 'from tsmoothie.smoother import ConvolutionalSmoother'
error ValueError: Data must be 2-dimensional
cause Passed a 1D array instead of 2D.
fix
Reshape data: data.reshape(1, -1) for a single series.
error TypeError: smooth() got an unexpected keyword argument 'window'
cause The smoother's __init__ may accept window parameter, but some like LowessSmoother use 'smooth_fraction'.
fix
Check the specific smoother's documentation for correct parameters.
error ModuleNotFoundError: No module named 'tsmoothie'
cause Library not installed.
fix
Run 'pip install tsmoothie'
gotcha Data must be 2D array-like of shape (n_series, n_points). Even a single series must be shaped (1, n_points) or a list of lists.
fix If you have a 1D array x, use x.reshape(1, -1) or [x] before passing to smoother.
gotcha Smoothers expect data in float dtype. Integer arrays may cause incorrect results or errors.
fix Convert data to float: data.astype(float).
breaking In v1.0.2, the code was restructured: many imports moved to submodules. Previously some classes might have been importable directly from tsmoothie.
fix Use from tsmoothie.smoother import ... instead of from tsmoothie import ...
deprecated The method 'get_intervals' parameter 'prediction_interval' is still valid, but future versions may change the API. No official deprecation yet.
fix Stay updated with CHANGELOG.

Basic smoothing with LowessSmoother. Tsmoothie operates on 2D arrays (time series in rows). Ensure data is float and shape (n_series, n_points).

import numpy as np
from tsmoothie.smoother import LowessSmoother

# Generate noisy data
np.random.seed(42)
data = np.cumsum(np.random.randn(100)) + 10

# Set up smoother
smoother = LowessSmoother(smooth_fraction=0.1, iterations=1)
smoother.smooth(data)

# Access smoothed and intervals
smoothed = smoother.smooth_data[0]
low, up = smoother.get_intervals('prediction_interval')

print('Smoothed:', smoothed[:5])