kan_scaler
chronax.kan_scaler
Per-window scalers for KAN: identity (NF default) and robust (median/MAD).
Scaler
chronax.kan_scaler.Scaler
A protocol defining the interface for per-window scalers.
stats(self, x, axis=1)
Calculates the shift and scale parameters necessary for normalization.
| Parameter | Type | Default | Description |
|---|---|---|---|
x |
jnp.ndarray |
- | The input array to calculate statistics from. |
axis |
int |
1 |
The axis over which to calculate statistics. |
Returns: tuple[jnp.ndarray, jnp.ndarray] (shift, scale).
transform(self, x, shift, scale)
Applies the normalization transformation.
| Parameter | Type | Default | Description |
|---|---|---|---|
x |
jnp.ndarray |
- | The input array to transform. |
shift |
jnp.ndarray |
- | The calculated shift parameter. |
scale |
jnp.ndarray |
- | The calculated scale parameter. |
Returns: jnp.ndarray (The normalized array).
inverse(self, z, shift, scale)
Applies the inverse normalization transformation.
| Parameter | Type | Default | Description |
|---|---|---|---|
z |
jnp.ndarray |
- | The normalized input array. |
shift |
jnp.ndarray |
- | The calculated shift parameter. |
scale |
jnp.ndarray |
- | The calculated scale parameter. |
Returns: jnp.ndarray (The denormalized array).
IdentityScaler
chronax.kan_scaler.IdentityScaler
No-op scaler (shift=0, scale=1). Matches neuralforecast's scaler_type='identity'.
stats(self, x, axis=1)
Calculates shift (zeros) and scale (ones).
| Parameter | Type | Default | Description |
|---|---|---|---|
x |
jnp.ndarray |
- | (undocumented) |
axis |
int |
1 |
(undocumented) |
Returns: tuple[jnp.ndarray, jnp.ndarray]
transform(self, x, shift, scale)
Returns x unchanged.
| Parameter | Type | Default | Description |
|---|---|---|---|
x |
jnp.ndarray |
- | (undocumented) |
shift |
jnp.ndarray |
- | (undocumented) |
scale |
jnp.ndarray |
- | (undocumented) |
Returns: jnp.ndarray
inverse(self, z, shift, scale)
Returns z unchanged.
| Parameter | Type | Default | Description |
|---|---|---|---|
z |
jnp.ndarray |
- | (undocumented) |
shift |
jnp.ndarray |
- | (undocumented) |
scale |
jnp.ndarray |
- | (undocumented) |
Returns: jnp.ndarray
RobustScaler
chronax.kan_scaler.RobustScaler
Median + MAD scaler with 0.6745*std fallback when MAD=0.
stats(self, x, axis=1)
Calculates median (shift) and MAD (scale), using a standard deviation fallback when MAD is zero.
| Parameter | Type | Default | Description |
|---|---|---|---|
x |
jnp.ndarray |
- | (undocumented) |
axis |
int |
1 |
(undocumented) |
Returns: tuple[jnp.ndarray, jnp.ndarray]
transform(self, x, shift, scale)
Applies the transformation: (x - shift) / scale.
| Parameter | Type | Default | Description |
|---|---|---|---|
x |
jnp.ndarray |
- | (undocumented) |
shift |
jnp.ndarray |
- | (undocumented) |
scale |
jnp.ndarray |
- | (undocumented) |
Returns: jnp.ndarray
inverse(self, z, shift, scale)
Applies the inverse transformation: z * scale + shift.
| Parameter | Type | Default | Description |
|---|---|---|---|
z |
jnp.ndarray |
- | (undocumented) |
shift |
jnp.ndarray |
- | (undocumented) |
scale |
jnp.ndarray |
- | (undocumented) |
Returns: jnp.ndarray
resolve_scaler
chronax.kan_scaler.resolve_scaler
Resolve a scaler from a name ('identity'/'robust') or a Scaler instance.
| Parameter | Type | Default | Description |
|---|---|---|---|
scaler |
str \| Scaler |
- | The name of the scaler ('identity' or 'robust') or an existing Scaler instance. |
Returns: Scaler
Raises: ValueError (If an unknown string name is provided).