RobustScaler
chronax.data.RobustScaler
Median + MAD scaler with std-based fallback when MAD == 0.
Stateless: stats returns (shift, scale) so the same values can be reused to inverse-transform predictions.
scaler = RobustScaler()
shift, scale = scaler.stats(insample, axis=1) # [B,L] -> [B,1]
z = scaler.transform(insample, shift, scale)
pred = scaler.inverse(z_hat, shift, scale)
stats(self, x: jnp.ndarray, axis: int = 1) -> Tuple[jnp.ndarray, jnp.ndarray]
| Parameter | Type | Default | Description |
|---|---|---|---|
x |
jnp.ndarray |
- | (undocumented) |
axis |
int |
1 |
(undocumented) |
Returns: Tuple[jnp.ndarray, jnp.ndarray]
transform(self, x: jnp.ndarray, shift: jnp.ndarray, scale: jnp.ndarray) -> jnp.ndarray
| Parameter | Type | Default | Description |
|---|---|---|---|
x |
jnp.ndarray |
- | (undocumented) |
shift |
jnp.ndarray |
- | (undocumented) |
scale |
jnp.ndarray |
- | (undocumented) |
Returns: jnp.ndarray
inverse(self, z: jnp.ndarray, shift: jnp.ndarray, scale: jnp.ndarray) -> jnp.ndarray
| Parameter | Type | Default | Description |
|---|---|---|---|
z |
jnp.ndarray |
- | (undocumented) |
shift |
jnp.ndarray |
- | (undocumented) |
scale |
jnp.ndarray |
- | (undocumented) |
Returns: jnp.ndarray
build_windows
chronax.data.build_windows
Return [n_windows, input_size + h] rolling windows (stride = 1).
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | 1-D float32 series of length T. |
input_size |
int |
- | History window length L. |
h |
int |
- | Forecast horizon. |
Returns: jnp.ndarray
Raises: ValueError: When T < input_size + h.
split_train_val_windows
chronax.data.split_train_val_windows
Chronological split: earliest windows train, latest windows validate.
When val_fraction <= 0 all windows go to the training set.
| Parameter | Type | Default | Description |
|---|---|---|---|
windows |
jnp.ndarray |
- | (undocumented) |
val_fraction |
float |
0.1 |
(undocumented) |
Returns: Tuple[jnp.ndarray, jnp.ndarray]
pad_sequence
chronax.data.pad_sequence
Left-pad / left-truncate a 1-D series to target_len.
Returns (padded, mask) where mask is 1 on real observations.
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | (undocumented) |
target_len |
int |
- | (undocumented) |
pad_value |
float |
0.0 |
(undocumented) |
Returns: Tuple[jnp.ndarray, jnp.ndarray]
align_covariates
chronax.data.align_covariates
Align per-series exogenous arrays to model input expectations.
hist_exog → left-padded to [input_size, X].
futr_exog → left-padded to [input_size + h, F].
stat_exog → cast to float32, returned as-is.
| Parameter | Type | Default | Description |
|---|---|---|---|
hist_exog |
Optional[jnp.ndarray] |
- | (undocumented) |
futr_exog |
Optional[jnp.ndarray] |
- | (undocumented) |
stat_exog |
Optional[jnp.ndarray] |
- | (undocumented) |
input_size |
int |
- | (undocumented) |
h |
int |
- | (undocumented) |
Returns: Dict[str, Optional[jnp.ndarray]]
create_batch
chronax.data.create_batch
Build a single JAX batch from a list of complete time series.
Each series is split at the -h cut point. History is left-padded to input_size (real observations tracked by available_mask); horizon is padded to h (loss tracked by sample_mask).
| Parameter | Type | Default | Description |
|---|---|---|---|
y_series |
List[jnp.ndarray] |
- | (undocumented) |
input_size |
int |
- | (undocumented) |
h |
int |
- | (undocumented) |
hist_exog_list |
Optional[List[Optional[jnp.ndarray]]] |
None |
(undocumented) |
futr_exog_list |
Optional[List[Optional[jnp.ndarray]]] |
None |
(undocumented) |
stat_exog_list |
Optional[List[Optional[jnp.ndarray]]] |
None |
(undocumented) |
sample_mask_list |
Optional[List[Optional[jnp.ndarray]]] |
None |
(undocumented) |
Returns: Dict[str, Optional[jnp.ndarray]] (Dict with keys: insample_y [B, L, 1], outsample_y [B, h, 1], available_mask [B, L, 1], sample_mask [B, h, 1], hist_exog [B, L, X] or None, futr_exog [B, L+h, F] or None, stat_exog [B, S] or None)
batch_generator
chronax.data.batch_generator
Iterate over y_series yielding fully-prepared JAX batches.
| Parameter | Type | Default | Description |
|---|---|---|---|
y_series |
List[jnp.ndarray] |
- | (undocumented) |
input_size |
int |
- | (undocumented) |
h |
int |
- | (undocumented) |
batch_size |
int |
- | (undocumented) |
hist_exog_list |
Optional[List[Optional[jnp.ndarray]]] |
None |
(undocumented) |
futr_exog_list |
Optional[List[Optional[jnp.ndarray]]] |
None |
(undocumented) |
stat_exog_list |
Optional[List[Optional[jnp.ndarray]]] |
None |
(undocumented) |
sample_mask_list |
Optional[List[Optional[jnp.ndarray]]] |
None |
(undocumented) |
shuffle |
bool |
True |
(undocumented) |
seed |
int |
42 |
(undocumented) |
Returns: Iterator[Dict[str, Optional[jnp.ndarray]]]