DirectStandardization#
- class chemotools.adaptation.DirectStandardization[ソース]
ベースクラス:
DocLinkMixin,OneToOneFeatureMixin,TransformerMixin,BaseEstimatorDirect 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].
- 変数:
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
- 例外:
ValueError -- If X and X_source do not have the same shape.
参考
PiecewiseDirectStandardizationLocalized version using windowed PLS regression.
参照
サンプル
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[ソース]
Fit the Direct Standardization model.
- パラメータ:
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.
- 戻り値:
self
- 戻り値の型:
DirectStandardization
- transform(X) ndarray[ソース]
Transform the data from the target space to the source space using the map
self.T_.- パラメータ:
X (np.ndarray of shape (n_samples, n_features)) -- The input data to transform
- 戻り値:
X_transf -- The data transformed
- 戻り値の型:
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
fitmethod.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(seesklearn.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 tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.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.