chemometrics.IHM¶
- class chemometrics.IHM(features, peak_parameters, bl_order=2, spectra_generator=<function pseudo_voigt_spectra>, method='LG', gradient_truncation=20)¶
Bases:
TransformerMixin
,MultiOutputMixin
,BaseEstimator
Indirect Hard Modeling (IHM) without linear regression
IHM models spectra based on a mechanistic model of multiple pure component spectra each consisting of flexible peaks. The spectra are described by the peak parameters. For new spectra, the mechanistic spectral model is adjusted by a parameter optimization. This allows to correct for a variety of effects such as instrument specific shifts or sensor variability. IHM returns the parameters of the fitted model.
- Parameters
features (ndarray of shape (n_features, 1), default=None) – feature-related x variable
peak_parameters (list of ndarrays) – List of peak parameter arrays
bl_order (int (default: 2)) – Order of background polynome
spectra_generator (function, default=pseudo_voigt_spectra) – Reference to spectra-generating function
method ({'LG'}) –
- Algorithm for spectral fit:
- ’LG’ (default): largest gradient method as descirbed in
[EKriesten].
gradient_truncation (int (default: 20)) – For peak_parameter fitting, only step along the most important gradient directions up to the number of directions given by gradient_truncation.
- n_components_¶
Number of components in model
- Type
int
- linearized_breakpoints_¶
Vector which indicates at what point different sections of the linarized parameter vector end. Structure: (backkground parameters, component weights, component shifts, spectra parameters)
- Type
ndarray
Notes
The current optimization strategy follows the largest gradient approach described in [EKriesten] . To reduce the complexity of the optimization problem, first global parameters are optimized (background, spectral shift, spectral weights). Peak parameters are optimized one by one depending on the gradient size up to a certain number of parameters.
- features:
vector of feature or spectral dimension (e.g. wavelength, wavenumber)
- peak:
a feature-associated effect described by a scaled probablity function
- component:
a chemical species described by a linear combination of peaks
- baseline:
slowely varying effect not associated to a specific component
- spectra:
a linear combination of multiple components and baseline effects
References
Implemented according to .. [EKriesten] Kriesten et al. Chemometrics and Intelligent Laboratory
Systems 91 (2008) 181-193.
- __init__(features, peak_parameters, bl_order=2, spectra_generator=<function pseudo_voigt_spectra>, method='LG', gradient_truncation=20)¶
Methods
__init__
(features, peak_parameters[, ...])fit
(X[, y])fit_transform
(X[, y])Fit to data, then transform it.
get_params
([deep])Get parameters for this estimator.
set_params
(**params)Set the parameters of this estimator.
transform
(X[, y])Transform spectra in IHM parameter set
- fit_transform(X, y=None, **fit_params)¶
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
- Parameters
X (array-like of shape (n_samples, n_features)) – Input samples.
y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) – Target values (None for unsupervised transformations).
**fit_params (dict) – Additional fit parameters.
- Returns
X_new – Transformed array.
- Return type
ndarray array of shape (n_samples, n_features_new)
- get_params(deep=True)¶
Get parameters for this estimator.
- Parameters
deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns
params – Parameter names mapped to their values.
- Return type
dict
- set_params(**params)¶
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline
). The latter have parameters of the form<component>__<parameter>
so that it’s possible to update each component of a nested object.- Parameters
**params (dict) – Estimator parameters.
- Returns
self – Estimator instance.
- Return type
estimator instance
- transform(X, y=None)¶
Transform spectra in IHM parameter set