SOFTSSharp
chronax.models.SOFTSSharp · inherits BaseForecaster
SOFTSSharp (Self-Organizing Feature Transformation for Time Series) model. A univariate time series forecasting model based on the SOFTS architecture, implemented using Flax/NNX. This model is designed for short-term forecasting and uses a combination of feature transformation and self-organizing layers.
Attributes:
* uses_exog: False. This model does not use exogenous variables.
* alias: 'softs-sharp'.
__init__(self, h: int, input_size: int, hidden_size: int = 64, num_layers: int = 2, dropout_rate: float = 0.1, learning_rate: float = 0.001, max_epochs: int = 100, early_stopping_patience: int = 10, seed: int = 42)
Initializes the SOFTSSharp forecaster.
| Parameter | Type | Default | Description |
|---|---|---|---|
h |
int |
- | Forecast horizon. |
input_size |
int |
- | The lookback window size (context length). |
hidden_size |
int |
64 |
Dimension of the hidden layers. |
num_layers |
int |
2 |
Number of SOFTS layers. |
dropout_rate |
float |
0.1 |
Dropout probability. |
learning_rate |
float |
0.001 |
Learning rate for the optimizer. |
max_epochs |
int |
100 |
Maximum number of training epochs. |
early_stopping_patience |
int |
10 |
Patience for early stopping. |
seed |
int |
42 |
Random seed for reproducibility. |
fit(self, y: jnp.ndarray, X: jnp.ndarray = None) -> Self
Trains the SOFTSSharp model.
The model is built and trained using the provided time series data y. Exogenous variables X are ignored as uses_exog is False.
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | Univariate time series data (T, 1). |
X |
jnp.ndarray |
None |
Ignored. Exogenous variables. |
Returns: Self (the fitted forecaster; sets self.model_).
predict(self, h: int, X: jnp.ndarray = None, level: list[float] = None) -> dict
Generates point forecasts using the fitted model.
| Parameter | Type | Default | Description |
|---|---|---|---|
h |
int |
- | The forecast horizon (must match self.h). |
X |
jnp.ndarray |
None |
Ignored. Exogenous variables. |
level |
list[float] |
None |
Prediction intervals levels (e.g., [80, 95]). Currently ignored as SOFTSSharp is deterministic. |
Returns: dict
A dictionary containing the forecasts.
Keys:
* mean: jnp.ndarray (h, 1) - Point forecasts.
forecast(self, y: jnp.ndarray, h: int, X: jnp.ndarray = None, X_future: jnp.ndarray = None, level: list[float] = None, fitted: bool = False) -> dict
Fits the model and generates forecasts in one step.
If fitted is True, it uses the existing self.model_ for prediction. Otherwise, it calls fit(y) followed by predict(h).
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | Historical time series data (T, 1). |
h |
int |
- | Forecast horizon. |
X |
jnp.ndarray |
None |
Ignored. Historical exogenous variables. |
X_future |
jnp.ndarray |
None |
Ignored. Future exogenous variables. |
level |
list[float] |
None |
Prediction intervals levels. Ignored. |
fitted |
bool |
False |
Whether the model is already fitted. |
Returns: dict
Forecast results, same structure as predict.