HotellingT2#

class chemotools.outliers.HotellingT2(model: _BasePCA | _PLS | Pipeline, confidence: float = 0.95)[源代码]

基类:_ModelResidualsBase

Calculate Hotelling's T-squared statistics for PCA or PLS like models.

参数:
  • model (Union[ModelType, Pipeline]) -- A fitted PCA/PLS model or Pipeline ending with such a model

  • confidence (float, default=0.95) -- Confidence level for statistical calculations (between 0 and 1)

变量:
  • estimator (ModelType) -- The fitted model of type _BasePCA or _PLS

  • transformer (Optional[Pipeline]) -- Preprocessing steps before the model

  • n_features_in (int) -- Number of features in the input data

  • n_components (int) -- Number of components in the model

  • n_samples (int) -- Number of samples used to train the model

  • critical_value (float) -- The calculated critical value for outlier detection

引用

[1] Johan A. Westerhuis, Stephen P. Gurden, Age K. Smilde

Generalized contribution plots in multivariate statistical process monitoring Chemometrics and Intelligent Laboratory Systems 51 2000 95–114 (2001).

示例

>>> from chemotools.datasets import load_fermentation_train
>>> from chemotools.outliers import HotellingT2
>>> from sklearn.decomposition import PCA
>>> # Load sample data
>>> X, _ = load_fermentation_train()
>>> # Instantiate the PCA model
>>> pca = PCA(n_components=3).fit(X)
>>> # Initialize HotellingT2 with the fitted PCA model
>>> hotelling_t2 = HotellingT2(model=pca, confidence=0.95)
HotellingT2(model=PCA(n_components=3), confidence=0.95)
>>> hotelling_t2.fit(X)
>>> # Predict outliers in the dataset
>>> outliers = hotelling_t2.predict(X)
>>> # Calculate Hotelling's T-squared statistics
>>> t2_stats = hotelling_t2.predict_residuals(X)

Attributes

critical_value_