patchtsmixer_model
PatchTSMixer model for multivariate time series forecasting.
PatchTSMixer is a lightweight MLP-Mixer architecture that mixes across patches, channels, and hidden features — providing native multivariate support with cross-channel correlation learning.
Output: deterministic (point forecasts via MSE loss). Multivariate: native channel-mixing. Covariates: not supported. Autoregressive: no (direct multi-step).
Trained from scratch on context data via sliding-window optimization (same pattern as PatchTST in Tempus Bench).
Paper: "TSMixer: Lightweight MLP-Mixer Model for Multivariate Time Series Forecasting" (arXiv:2306.09364, KDD 2023)
PatchtsmixerModel
chronax.models.patchtsmixer_model.PatchtsmixerModel · inherits BaseModel
PatchTSMixer model with native multivariate channel-mixing.
Initialized from a configuration (not a pretrained checkpoint) and briefly fit on the provided context data via sliding-window training.
__init__(self, params: Dict[str, Any], settings: Dict[str, Any])
Initializes the model and validates hyperparameters against PatchtsmixerHyperparams.
| Parameter | Type | Default | Description |
|---|---|---|---|
params |
Dict[str, Any] |
- | Dictionary containing model hyperparameters (see below). |
settings |
Dict[str, Any] |
- | (undocumented) |
Hyperparameters (contained within params):
| Parameter | Type | Default | Description |
|---|---|---|---|
context_length |
int |
256 |
HF config context_length (capped in train). |
patch_length |
int |
8 |
(undocumented) |
stride |
int |
8 |
(undocumented) |
num_epochs |
int |
25 |
Sliding-window fine-tune epochs on context. |
learning_rate |
float |
0.001 |
Adam learning rate for fine-tuning. |
train(self, y_context, y_target, timestamps_context, timestamps_target, x_context=None, x_target=None, **kwargs) -> PatchtsmixerModel
Trains the PatchTSMixer model using sliding-window optimization on the context data.
| Parameter | Type | Default | Description |
|---|---|---|---|
y_context |
np.ndarray |
- | (undocumented) |
y_target |
np.ndarray |
- | (undocumented) |
timestamps_context |
np.ndarray |
- | (undocumented) |
timestamps_target |
np.ndarray |
- | (undocumented) |
x_context |
Optional[np.ndarray] |
None |
(undocumented) |
x_target |
Optional[np.ndarray] |
None |
(undocumented) |
**kwargs |
- | (undocumented) |
Returns: PatchtsmixerModel (the fitted model).
predict(self, y_context, timestamps_context, timestamps_target, x_context=None, x_target=None, **kwargs) -> np.ndarray
Generates forecasts based on the provided context data.
| Parameter | Type | Default | Description |
|---|---|---|---|
y_context |
np.ndarray |
- | (undocumented) |
timestamps_context |
np.ndarray |
- | (undocumented) |
timestamps_target |
np.ndarray |
- | (undocumented) |
x_context |
Optional[np.ndarray] |
None |
(undocumented) |
x_target |
Optional[np.ndarray] |
None |
(undocumented) |
**kwargs |
- | (undocumented) |
Returns: np.ndarray (The predicted values, shape (prediction_length, num_channels)).
Raises: ValueError if train() has not been called.