DirectStandardization#

class chemotools.adaptation.DirectStandardization[fuente]

Bases: DocLinkMixin, OneToOneFeatureMixin, TransformerMixin, BaseEstimator

Direct Standardization (DS) is a transformer used for domain adaptation (calibration ) applications. The transformer uses least squares to find a linear map from the target instrument space to the source instrument space, following the implementation by [1].

Variables:
  • T (np.ndarray of shape (n_features, n_features)) – Linear transformation matrix mapping target instrument space to source instrument space.

  • x_source_provided (bool) – Boolean value to flag if X_source was provided during fitting

Muestra:

ValueError – If X and X_source do not have the same shape.

Ver también

PiecewiseDirectStandardization

Localized version using windowed PLS regression.

Referencias

Ejemplos

Basic usage >>> import numpy as np >>> from chemotools.adaptation import DirectStandardization >>> >>> rng = np.random.default_rng(17) >>> X_source = rng.normal(size=(100, 20)) >>> X_target = X_source * 2 - rng.normal(size=(100, 20)) * 0.02 >>> >>> ds = DirectStandardization().fit(X_target, X_source=X_source) >>> X_transf = ds.transform(X_target)

Attributes

n_features_in_

T_

x_source_provided_

n_features_in_: int
T_: ndarray
x_source_provided_: bool
fit(X: ndarray, y=None, *, X_source: ndarray | None = None) DirectStandardization[fuente]

Fit the Direct Standardization model.

Parámetros:
  • X (np.ndarray of shape (n_samples, n_features)) – Data from the target instrument.

  • y (None) – Ignored to align with API.

  • X_source (np.ndarray of shape (n_samples, n_features), optional) – Data from the source instrument. If None, the transformer defaults to an identity transformation.

Devuelve:

self

Tipo del valor devuelto:

DirectStandardization

transform(X) ndarray[fuente]

Transform the data from the target space to the source space using the map self.T_.

Parámetros:

X (np.ndarray of shape (n_samples, n_features)) – The input data to transform

Devuelve:

X_transf – The data transformed

Tipo del valor devuelto:

np.ndarray of shape (n_samples, n_features)

set_fit_request(*, X_source: bool | None | str = '$UNCHANGED$') DirectStandardization

Configure whether metadata should be requested to be passed to the fit method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parámetros:

X_source (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for X_source parameter in fit.

Devuelve:

self – The updated object.

Tipo del valor devuelto:

object