RobustNormalVariate#

class chemotools.scatter.RobustNormalVariate(percentile: float = 25, epsilon: float = 1e-10)[source]

Bases: TransformerMixin, OneToOneFeatureMixin, BaseEstimator

A transformer that calculates the robust normal variate of the input data.

Parameters:
  • percentile (float, optional, default=25) – The percentile to use for the robust normal variate. The value should be between 0 and 100. The default is 25.

  • epsilon (float, optional, default=1e-10) – A small value added to the denominator to avoid numerical instability (division by zero). The default is 1e-10.

Variables:

n_features_in (int) – The number of features in the training data.

Raises:

UserWarning – If the standard deviation of the values below the specified percentile is zero, a warning and a small epsilon is added to the denominator to avoid NaNs.

References

[1] Q. Guo, W. Wu, D.L. Massart.

“The robust normal variate transform for pattern recognition with near-infrared data.” doi:10.1016/S0003-2670(98)00737-5

Examples

>>> from chemotools.datasets import load_fermentation_train
>>> from chemotools.scatter import RobustNormalVariate
>>> # Load sample data
>>> X, _ = load_fermentation_train()
>>> # Initialize RobustNormalVariate
>>> rnv = RobustNormalVariate()
RobustNormalVariate()
>>> # Fit and transform the data
>>> X_scaled = rnv.fit_transform(X)
fit(X: ndarray, y=None) RobustNormalVariate[source]

Fit the transformer to the input data.

Parameters:
  • X (np.ndarray of shape (n_samples, n_features)) – The input data to fit the transformer to.

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

Returns:

self – The fitted transformer.

Return type:

RobustNormalVariate

transform(X: ndarray, y=None) ndarray[source]

Transform the input data by calculating the standard normal variate.

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

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

Returns:

X_transformed – The transformed data.

Return type:

np.ndarray of shape (n_samples, n_features)