romcomma.data.storage.Normalization§

class Normalization(fold, data=None)[source]§

Bases: object

Encapsulates the normalization of data. X data is assumed to follow a Uniform distribution, which is normalized to U[0,1] , then inverse probability transformed to N[0,1]. Y data is normalized to zero mean and unit variance.

Parameters:
  • fold (Repository) –

  • data (Optional[pd.DataFrame]) –

__init__(fold, data=None)[source]§

Initialize this Normalization. If the fold has already been Normalized, that Normalization is returned.

Parameters:
  • fold (Repository) – The fold to Normalize.

  • data (DataFrame | None) – The data from which to calculate Normalization.

Methods

X_gradient(X, m)

Computes the gradient of the unormalized inputs X[m] with respect to the normalized inputs Z[m].

__init__(fold[, data])

Initialize this Normalization.

apply_to(df)

Apply this normalization.

undo_from(df)

Undo this normalization.

unscale_Y(dfY)

Undo the Y-scaling of this normalization, without adding the Y-Mean.

Attributes

UNIFORM_MARGIN

csv

frame

apply_to(df)[source]§

Apply this normalization.

Parameters:

df (DataFrame) – The pd.DataFrame to Normalize.

Return type:

DataFrame

Returns: df, Normalized.

undo_from(df)[source]§

Undo this normalization.

Parameters:

df (DataFrame) – The (Normalized) pd.DataFrame to UnNormalize.

Return type:

DataFrame

Returns: df, UnNormalized.

unscale_Y(dfY)[source]§

Undo the Y-scaling of this normalization, without adding the Y-Mean. Suitable treatment for unNormalizing SD, for example.

Parameters:

dfY (DataFrame) – The (Normalized) pd.DataFrame to UnNormalize.

Return type:

DataFrame

Returns: dfY, UnNormalized.

X_gradient(X, m)[source]§

Computes the gradient of the unormalized inputs X[m] with respect to the normalized inputs Z[m].

Parameters:
  • X (ndarray) – An (N,M) matrix of unormalized inputs X[M]

  • m (int | List[int]) – A list of input axes to differentiate.

Returns: An (N,len(m)) matrix of derivatives