standardizeΒΆ

Defined in fynance.features.scale

standardize(X, a=0, b=1, axis=0)[source]

Substitutes the mean and divid by the standard deviation.

Z-score scaling: shifts the data to zero mean and unit variance, then re-scales to [a, a + b] if the optional location/scale factors are provided. The standard preprocessing for ML models that assume features on comparable scales (linear regressions, SVMs, neural networks). For time-series with regime shifts, prefer roll_standardize to avoid leaking future statistics.

Parameters:
Xnp.ndarray[dtype, ndim=1 or 2]

Data to scale.

a, bfloat or array_like, optional

Respectively an additional and multiply factor.

axisint, optional

Axis along which to scale the data.

Returns:
np.ndarray[dtype, ndim=1 or 2]

The scaled data.

See also

Scale, normalize, roll_standardize