mescla.prep.transform.Standardizer

class mescla.prep.transform.Standardizer(standardize=True, center_=None, scale_=None, species_=None)[source]

Bases: object

Z-score standardiser fitted on mixed samples and reused for everything else.

Parameters:
  • standardize (bool, default True) – When False the transform only centres the data, giving a covariance-matrix PCA. Use this when all species share units and you deliberately want large-concentration species to dominate.

  • center_ (ndarray | None)

  • scale_ (ndarray | None)

  • species_ (tuple[str, ...] | None)

Variables:
  • center (ndarray, shape (ns,)) – Column means of the fitted data.

  • scale (ndarray, shape (ns,)) – Column standard deviations (ddof=1), or ones when standardize=False.

  • species (tuple of str)

Examples

>>> std = Standardizer().fit(samples)
>>> Z  = std.transform(samples)
>>> Ze = std.transform(endmembers)             # same centre and scale
standardize: bool = True
center_: ndarray | None = None
scale_: ndarray | None = None
species_: tuple[str, ...] | None = None
fit(X)[source]

Learn the centre and scale from X (the mixed samples).

Parameters:

X (Any)

Return type:

Standardizer

transform(X)[source]

Apply the fitted centre and scale. Works for samples and end-members alike.

Parameters:

X (Any)

Return type:

ndarray

inverse_transform(Z)[source]

Return standardised values to original concentration units.

Parameters:

Z (ndarray)

Return type:

ndarray

fit_transform(X)[source]
Parameters:

X (Any)

Return type:

ndarray