ScaleTransformer#

class ScaleTransformer(scaler, /, name=None)[source]#

Scale (nondimensionalize) snapshots as a whole or by row.

If the provided scaler is a number \(\alpha \neq 0\), this transformation simply multiplies the input by that scaler. For a vector \(\q\in\RR^n\), the transformation is \(\q \mapsto \q' = \alpha\q\) with inverse transformation \(\q' \mapsto \q = \frac{1}{\alpha}\q'\), and similarly for matrices.

If the scaler is a vector \(\boldsymbol{\alpha}\in\RR^{n}\), this transformation multiplies each row of the input by the corresponding entry of \(\boldsymbol{\alpha}\). For a vector \(\q\in\RR^n\), the transformation is \(\q\mapsto\q' = \boldsymbol{\alpha}\ast\q\) where \(\ast\) is the elementwise (Hadamard) product (* in NumPy). The inverse transformation performs elementwise division (/ in NumPy). For a matrix \(\Q\in\RR^{n \times k}\), the transformation is applied columnwise: writing \(\Q = [~\q_0~~\q_1~~\cdots~~\q_{k-1}~]\),

\[\begin{split}\Q \mapsto \Q' = \Q \ast \boldsymbol{\alpha}\1\trp = \left[\begin{array}{c|c|c|c} &&& \\ \q_0 \ast \boldsymbol{\alpha} & \q_1 \ast \boldsymbol{\alpha} & \cdots & \q_{k-1} \ast \boldsymbol{\alpha} \\ &&& \end{array}\right],\end{split}\]

with the inverse transformation defined similarly.

Parameters:
scalerfloat or (n,) ndarray

Scaling factor. If a float, data are scaled as a whole; if an array, data are scaled by row. Must be nonzero or have all nonzero entries.

namestr or None

Label for the state variable that this transformer acts on.

Notes

In this class, the scaler \(\alpha\) or \(\boldsymbol{\alpha}\) is provided explicitly. Use ShiftScaleTransformer to learn different types of scaling from training data.

Properties:
byrow#

Whether data are scaled by row (True, scaler is an array) or as a whole (False, scaler is a float).

name#

Label for the state variable that this transformer acts on.

scaler#

Scaling factor. If a float, data are scaled as a whole; if an array, data are scaled by row. Must be nonzero or have all nonzero entries.

state_dimension#

Dimension \(n\) of the state.

Methods:

fit

Set the state_dimension if scaler is not an array, otherwise do nothing.

fit_transform

Set the state_dimension if scaler is not an array, and apply the scaling.

inverse_transform

Apply the inverse scaling.

load

Load a previously saved transformer from an HDF5 file.

save

Save the transformer to an HDF5 file.

transform

Apply the scaling.

transform_ddts

Apply the scaling; the transformation for derivatives is the same as for snapshots.

verify

Verify that transform() and inverse_transform() are consistent and that transform_ddts(), if implemented, is consistent with transform().