PyPOTS

raw JSON →
1.4 verified Mon Apr 27 auth: no python

A Python toolbox for machine learning on partially-observed time series. Current version 1.4, released with bug fixes. Active development with frequent releases.

pip install pypots
error ValueError: Expected data to be 3D, got 2D
cause Input data is 2D instead of 3D (n_samples, n_timesteps, n_features).
fix
Reshape data to 3D: data = data.reshape(n_samples, -1, n_features) or add a dimension.
error ModuleNotFoundError: No module named 'pypots.data'
cause Trying to import from the old 'pypots.data' subpackage which was removed in v1.0.
fix
Use 'from pypots.utils.random import set_random_seed' or other correct imports from actual subpackages.
error AttributeError: 'NoneType' object has no attribute 'endswith'
cause Known bug in TimeLLM model when loading pretrained LLM, fixed in v1.2.
fix
Upgrade to pypots>=1.2.
gotcha PyPOTS requires data in 3D numpy arrays (samples, timesteps, features). Passing 2D or 4D arrays will cause errors.
fix Ensure input shape is (n_samples, n_timesteps, n_features).
deprecated The old import 'from pypots.data import ...' is deprecated. Use 'from pypots.utils.random import ...' instead.
fix Use correct import paths as shown in official docs.
breaking In v1.0, the API changed significantly. Many model classes and utilities moved to new subpackages.
fix Refer to the migration guide at https://pypots.readthedocs.io/en/latest/release.html

Impute missing values in 3D time series data using SAITS.

import pypots
from pypots.utils.random import set_random_seed
import numpy as np

# Generate random data with missing values
X = np.random.randn(100, 10, 5)
X[X < -1] = np.nan  # introduce missing values

# Impute using a simple model
from pypots.imputation import SAITS

model = SAITS(
    n_steps=10,
    n_features=5,
    n_layers=2,
    d_model=32,
    d_ffn=64,
    n_heads=4,
    d_k=16,
    d_v=16,
    epochs=10,
    batch_size=32,
    loss_fn='mse',
    optimizer='adam',
    lr=1e-3,
    verbose=True
)
model.fit(X)
imputed_X = model.impute(X)
print(imputed_X.shape)