Esc
Ask AIAnswers may be inaccurate; check the linked pages.Esc
Ask anything about these docs, like how to get started or what a function does.

RobustScaler

chronax.data.RobustScaler

Median + MAD scaler with a std-based fallback when MAD == 0. Stateless: stats computes (shift, scale) so the same statistics can later invert predictions. Robust statistics (median/MAD) are preferred over mean/std because they are insensitive to the spikes common in real series.

__init__(self)

Median + MAD scaler with a std-based fallback when MAD == 0.

Parameter Type Default Description
(None)

stats(self, x: jnp.ndarray, axis: int = 1) -> Tuple[jnp.ndarray, jnp.ndarray]

Return (shift, scale) computed along axis (keepdims).

Parameter Type Default Description
x jnp.ndarray - (undocumented)
axis int 1 (undocumented)

Returns: Tuple[jnp.ndarray, jnp.ndarray] (shift is the median; scale is the MAD, falling back to a std-derived value when the MAD is zero (e.g. a near-constant window), and finally to 1 to avoid division by zero.)

transform(self, x: jnp.ndarray, shift: jnp.ndarray, scale: jnp.ndarray) -> jnp.ndarray

Normalise: (x - shift) / scale.

Parameter Type Default Description
x jnp.ndarray - (undocumented)
shift jnp.ndarray - (undocumented)
scale jnp.ndarray - (undocumented)

Returns: jnp.ndarray (Normalise: (x - shift) / scale.)

inverse(self, z: jnp.ndarray, shift: jnp.ndarray, scale: jnp.ndarray) -> jnp.ndarray

Invert the normalisation: z * scale + shift.

Parameter Type Default Description
z jnp.ndarray - (undocumented)
shift jnp.ndarray - (undocumented)
scale jnp.ndarray - (undocumented)

Returns: jnp.ndarray (Invert the normalisation: z * scale + shift.)

build_windows

chronax.data.build_windows

NF-style rolling windows with right-padding (ConstantPad1d((0, h))).

Right-pads y with h zeros before unfolding, yielding len(y) - input_size windows of length input_size + h — including partial-horizon windows whose context reaches the end of the series.

Parameter Type Default Description
y np.ndarray - (undocumented)
input_size int - (undocumented)
h int - (undocumented)

Returns: Tuple[np.ndarray, np.ndarray] (Returns (windows, mask) where mask is 1 on real points and 0 on the padded tail so the loss can drop padded horizon steps.) Raises: ValueError: When T < input_size + 1 (no window with a real outsample).

split_train_val_windows

chronax.data.split_train_val_windows

Chronological split: earliest windows train, latest validate.

A time-ordered split (no shuffling) avoids leaking future information into the training set. When val_fraction <= 0 all windows train (empty val).

Parameter Type Default Description
windows np.ndarray - (undocumented)
masks np.ndarray - (undocumented)
val_fraction float 0.1 (undocumented)

Returns: Tuple[Tuple[np.ndarray, np.ndarray], Tuple[np.ndarray, np.ndarray]] (Returns ((train_windows, train_masks), (val_windows, val_masks)).)

pad_sequence

chronax.data.pad_sequence

Left-pad / left-truncate a 1-D series to target_len.

Parameter Type Default Description
y np.ndarray - (undocumented)
target_len int - (undocumented)
pad_value float 0.0 (undocumented)

Returns: Tuple[np.ndarray, np.ndarray] (Returns (padded, mask) where mask is 1 on real observations and 0 on padding -- the mask is what the masked losses use to ignore padded steps.)

create_batch

chronax.data.create_batch

Build a single JAX batch from a list of complete time series.

Each series is split into (history, horizon); the history is padded/truncated to input_size (yielding available_mask) and the horizon to h (yielding sample_mask).

Parameter Type Default Description
y_series List[np.ndarray] - (undocumented)
input_size int - (undocumented)
h int - (undocumented)
sample_mask_list Optional[List[Optional[np.ndarray]]] None (undocumented)

Returns: Dict[str, Optional[jnp.ndarray]] (A dict of JAX arrays: insample_y [B, input_size, 1], outsample_y [B, h, 1], available_mask [B, input_size, 1] (1 = real, 0 = padded), sample_mask [B, h, 1] (1 = compute loss, 0 = ignore).)

batch_generator

chronax.data.batch_generator

Iterate over y_series yielding fully-prepared JAX batches.

Parameter Type Default Description
y_series List[np.ndarray] - (undocumented)
input_size int - (undocumented)
h int - (undocumented)
batch_size int - (undocumented)
sample_mask_list Optional[List[Optional[np.ndarray]]] None (undocumented)
shuffle bool True (undocumented)
seed int 42 (undocumented)

Returns: Iterator[Dict[str, Optional[jnp.ndarray]]] (Iterate over y_series yielding fully-prepared JAX batches.)