SOFTSSharp
chronax.models.softssharp_model.SOFTSSharp ยท inherits BaseForecaster
Univariate SOFTSSharp forecaster (JAX/Flax-NNX port of neuralforecast.SOFTSSharp).
Maintenance status: Active univariate forecaster. Integrates with the BaseForecaster interface, including conformal prediction intervals via predict(level=...), pickle round-trip, and forecast(fitted=True).
__init__(self, h, input_size=-1, hidden_size=512, d_core=512, e_layers=2, d_ff=2048, dropout=0.1, pe_keep_prob=0.5, use_norm=True, use_boxcox=False, activation='gelu', max_steps=1000, learning_rate=1e-3, windows_batch_size=32, random_seed=1, alias='SOFTSSharp', loss='mae')
Initialize a SOFTSSharp forecaster. Stores hyperparameters; the network is built lazily at fit time so construction is cheap and side-effect free. Defaults match neuralforecast.SOFTSSharp (hidden_size=512, d_core=512, e_layers=2, d_ff=2048, dropout=0.1, pe_keep_prob=0.5, use_norm=True, max_steps=1000, learning_rate=1e-3, windows_batch_size=32). input_size=-1 resolves to 3 * h. loss is a registry name ("mae"/"mse"/"huber") or a callable; learning_rate is a scalar or an optax.ScalarOrSchedule; activation is "gelu" or "relu". If the fitted estimator will be pickled, any callable passed for loss/learning_rate must itself be picklable (a class-based callable or module-level function).
| Parameter | Type | Default | Description |
|---|---|---|---|
h |
int |
- | (undocumented) |
input_size |
int |
-1 |
(undocumented) |
hidden_size |
int |
512 |
(undocumented) |
d_core |
int |
512 |
(undocumented) |
e_layers |
int |
2 |
(undocumented) |
d_ff |
int |
2048 |
(undocumented) |
dropout |
float |
0.1 |
(undocumented) |
pe_keep_prob |
float |
0.5 |
The probability of applying the variable-position encoding during training; at inference the encoding is scaled by this value instead. pe_keep_prob=0.0 disables the encoding entirely in both modes, which reduces the block to plain SOFTS-with-extra-dropout. |
use_norm |
bool |
True |
(undocumented) |
use_boxcox |
bool |
False |
Applies a variance-stabilizing Box-Cox transform to the series before modelling and inverts it on the forecast, mirroring the use_boxcox option of :class:chronax.models.TBATS and the sibling :class:chronax.models.SOFTS. The lambda is selected once at fit time by maximizing the Box-Cox profile log-likelihood. It helps multiplicative / strongly-trending series (e.g. airline passengers) and requires strictly positive values. Left off, the model is a faithful port of neuralforecast.SOFTSSharp. |
activation |
str |
"gelu" |
(undocumented) |
max_steps |
int |
1000 |
(undocumented) |
learning_rate |
Union[float, Callable[[int], float]] |
1e-3 |
(undocumented) |
windows_batch_size |
int |
32 |
(undocumented) |
random_seed |
int |
1 |
(undocumented) |
alias |
str |
"SOFTSSharp" |
(undocumented) |
loss |
Union[str, LossFn] |
"mae" |
(undocumented) |
fit(self, y, X=None) -> Self
Fit the network on a 1-D series. Builds the network and runs max_steps Adam steps over rolling windows of length input_size + h, sampled per step the way neuralforecast does.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | 1-D series of length >= input_size + h. |
X |
jnp.ndarray \| None |
None |
Reserved for exogenous regressors; must be None. |
Returns: Self (the fitted forecaster; sets self.model_).
Raises:
NotImplementedError: If X is provided.
ValueError: If y is not 1-D or is shorter than input_size + h.
RuntimeError: If a non-finite training loss is observed (divergence).
predict(self, h, X=None, level=None) -> dict
Forecast h steps from the fitted context.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
h |
int |
- | Forecast horizon; must satisfy 1 <= h <= self.h (the model is direct-decoded for self.h steps and sliced). |
X |
jnp.ndarray \| None |
None |
Reserved for exogenous regressors; ignored. |
level |
list[int \| float] \| None |
None |
Optional confidence levels (e.g. [80, 95]). When set, returns conformal lo-XX/hi-XX keys via the inherited BaseForecaster path and requires self.conformal_params. Each call re-fits the model per CV window under vmap โ expect minutes. |
Returns: dict ({"mean": jnp.ndarray of shape (h,)} plus interval keys when level is provided.)
Raises:
RuntimeError: If called before fit.
ValueError: If h < 1 or h > self.h, or if level is given without self.conformal_params set.
forecast(self, y, h, X=None, X_future=None, level=None, fitted=False) -> dict
Stateless fit-then-predict on y. Equivalent to self.fit(y).predict(h=h, level=level), optionally adding a "fitted" key with one-step-ahead in-sample predictions.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | 1-D training series. |
h |
int |
- | Forecast horizon (<= self.h). |
X |
jnp.ndarray \| None |
None |
Reserved for exogenous regressors; must be None. |
X_future |
jnp.ndarray \| None |
None |
Reserved for exogenous regressors; must be None. |
level |
list[int \| float] \| None |
None |
Optional confidence levels; see predict. |
fitted |
bool |
False |
If True, include "fitted" โ one-step-ahead values over the training series, NaN for the first input_size entries. |
Returns: dict ({"mean": ..., optional "fitted": ...}.)
Raises:
NotImplementedError: If X or X_future is provided.
ValueError / RuntimeError: Forwarded from fit / predict.