spectrochempy.MCRALSο
- class MCRALS(*args, log_level=30, warm_start=False, argsGetConc, argsGetSpec, closureConc=[], closureMethod='scaling', closureTarget='default', getC_to_C_idx='default', getConc=None, getSpec=None, getSt_to_St_idx='default', hardConc, hardSpec, kwargsGetConc, kwargsGetSpec, max_iter=50, maxdiv=5, monoDecConc, monoDecTol=1.1, monoIncConc, monoIncTol=1.1, nonnegConc='all', nonnegSpec='all', normSpec=None, solverConc='lstsq', solverSpec='lstsq', storeIterations=False, tol=0.1, unimodConc='all', unimodConcMod='strict', unimodConcTol=1.1, unimodSpec=[], unimodSpecMod='strict', unimodSpecTol=1.1)[source]ο
- Multivariate Curve Resolution Alternating Least Squares (MCRALS). - MCR-ALS ( - Multivariate Curve Resolution Alternating Least Squares) resolveβs a set (or several sets) of spectra \(X\) of an evolving mixture (or a set of mixtures) into the spectra \(S^t\) of βpureβ species and their concentration profiles \(C\).- In terms of matrix equation: \[X = C.S^t + E\]- where \(E\) is the matrix of residuals. - Parameters:
- log_level (any of [ - "INFO",- "DEBUG",- "WARNING",- "ERROR"], optional, default:- "WARNING") β The log level at startup. It can be changed later on using the- set_log_levelmethod or by changing the- log_levelattribute.
- warm_start ( - bool, optional, default:- False) β When fitting repeatedly on the same dataset, but for multiple parameter values (such as to find the value maximizing performance), it may be possible to reuse previous model learned from the previous parameter value, saving time.- When - warm_startis- True, the existing fitted model attributes is used to initialize the new model in a subsequent call to- fit.
- argsGetConc ( - tuple, optional, default: ()) β Supplementary positional arguments passed to the external function.
- argsGetSpec ( - tuple, optional, default: ()) β Supplementary positional arguments passed to the external function.
- closureConc (any of [βallβ] or a list, optional, default: []) β Defines the concentration profiles subjected to closure constraint. - []: no constraint is applied.
- 'all': all profile are constrained so that their weighted sum equals the- closureTarget
- listof indexes: the corresponding profiles are constrained so that their weighted sum equals- closureTarget.
 
- closureMethod (any value of [ - 'scaling',- 'constantSum'], optional, default:- 'scaling') β The method used to enforce closure (Omidikia et al. [2018]).- 'scaling'recompute the concentration profiles using least squares:\[C \leftarrow C \cdot \textrm{diag} \left( C_L^{-1} c_t \right)\]- where \(c_t\) is the vector given by - closureTargetand \(C_L^{-1}\) is the left inverse of \(C\).
- 'constantSum'normalize the sum of concentration profiles to- closureTarget.
 
- closureTarget (any of [βdefaultβ] or a numpy array, optional, default: - 'default') β The value of the sum of concentrations profiles subjected to closure.- 'default': the total concentration is set to- 1.0for all observations.
- array-like of size n_observations: the values of concentration for each observation. Hence, - np.ones(X.shape[0])would be equivalent to- 'default'.
 
- getC_to_C_idx (any of [βdefaultβ] or a list, optional, default: - 'default') β Correspondence of the profiles returned by- getConcand- C[:,hardConc].- 'default': the profiles correspond to those of- C[:,hardConc]. This is equivalent to- range(len(hardConc))
- listof indexes or of- None. For instance- [2, 1, 0]indicates that the third profile returned by- getC(index- 2) corresponds to the 1st profile of- C[:, hardConc], the 2nd returned profile (index- 1) corresponds to second profile of- C[:, hardConc], etcβ¦
 
- getConc (a callable or a unicode string, optional, default: - None) β An external function that provide- len(hardConc)concentration profiles.- It should be using one of the following syntax: - getConc(Ccurr, *argsGetConc, **kwargsGetConc) -> hardC
- getConc(Ccurr, *argsGetConc, **kwargsGetConc) -> hardC, newArgsGetConc
- getConc(Ccurr, *argsGetConc, **kwargsGetConc) -> hardC, newArgsGetConc, extraOutputGetConc
 - where: - Ccurris the current- Cdataset,
- argsGetConcare the parameters needed to completely specify the function.
- hardCis a- ndarrayor- NDDatasetof shape (n_observations , len(- hardConc),
- newArgsGetConcare the updated parameters for the next iteration (can be- None),
- extraOutputGetConccan be any other relevant output to be kept in- extraOutputGetConcattribute, a list of- extraOutputGetConcat each MCR ALS iteration.
 - Note - getConccan be also a serialized function created using dill and base64 python libraries. Normally not used directly, it is here for internal process.
- getSpec (a callable or a unicode string, optional, default: - None) β An external function that will provide- len(hardSpec)concentration profiles.- It should be using one of the following syntax: - getSpec(Stcurr, *argsGetSpec, **kwargsGetSpec) -> hardSt
- getSpec(Stcurr, *argsGetSpec, **kwargsGetSpec) -> hardSt, newArgsGetSpec
- getSpec(Stcurr, *argsGetSpec, **kwargsGetSpec) -> hardSt, newArgsGetSpec, extraOutputGetSpec
 - with: 
- *argsGetSpecand- **kwargsGetSpec: the parameters needed to completely specify the function.
- hardSt:- ndarrayor- NDDatasetof shape- (n_observations, len(hardSpec),
- newArgsGetSpec: updated parameters for the next ALS iteration (can be None),
- extraOutputGetSpec: any other relevant output to be kept in- extraOutputGetSpecattribute, a list of- extraOutputGetSpecat each iterations.
 - Note - getSpeccan be also a serialized function created using dill and base64 python libraries. Normally not used directly, it is here for internal process.
- getSt_to_St_idx (any of [βdefaultβ] or a list, optional, default: - 'default') β Correspondence between the indexes of the spectra returned by- getSpecand- St.- 'default': the indexes correspond to those of- St. This is equivalent to- range(len(hardSpec)).
- listof indexes : corresponding indexes in- St, i.e.- [2, None, 0]indicates that the first returned profile corresponds to the third- Stprofile (index- 2), the 2nd returned profile does not correspond to any profile in- St, the 3rd returned profile corresponds to the first- Stprofile (index- 0).
 
- hardConc ( - list, optional, default: []) β Defines hard constraints on the concentration profiles.
- hardSpec ( - list, optional, default: []) β Defines hard constraints on the spectral profiles.
- kwargsGetConc ( - dict, optional, default: {}) β Supplementary keyword arguments passed to the external function.
- kwargsGetSpec ( - dict, optional, default: {}) β Supplementary keyword arguments passed to the external function.
- max_iter ( - int, optional, default: 50) β Maximum number of ALS iteration.
- maxdiv ( - int, optional, default: 5) β Maximum number of successive non-converging iterations.
- monoDecConc ( - list, optional, default: []) β Monotonic decrease constraint on concentrations.- []: no constraint is applied.
- listof indexes: the corresponding profiles are considered to decrease monotonically, not the others. For instance- [0, 2]indicates that profile- #0and- #2are decreasing while profile- #1can increase.
 
- monoDecTol ( - float, optional, default: 1.1) β Tolerance parameter for monotonic decrease.- Correction is applied only if: - C[i,j] > C[i-1,j] * unimodTol.
- monoIncConc ( - list, optional, default: []) β Monotonic increase constraint on concentrations.- []: no constraint is applied.
- listof indexes: the corresponding profiles are considered to increase monotonically, not the others. For instance- [0, 2]indicates that profile- #0and- #2are increasing while profile- #1can decrease.
 
- monoIncTol ( - float, optional, default: 1.1) β Tolerance parameter for monotonic decrease.- Correction is applied only if - C[i,j] < C[i-1,j] * unimodTolalong profile- #j.
- nonnegConc (any of [βallβ] or a list, optional, default: - 'all') β Non-negativity constraint on concentrations.- 'all': all concentrations profiles are considered non-negative.
- listof indexes: the corresponding profiles are considered non-negative, not the others. For instance- [0, 2]indicates that profile #0 and #2 are non-negative while profile #1 can be negative.
- []: all profiles can be negative.
 
- nonnegSpec (any of [βallβ] or a list, optional, default: - 'all') β Non-negativity constraint on spectra.- 'all': all profiles are considered non-negative.
- listof indexes : the corresponding profiles are considered non-negative, not the others. For instance- [0, 2]indicates that profile- #0and- #2are non-negative while profile- #1can be negative.
- []: all profiles can be negative.
 
- normSpec (any value of [ - 'None',- 'euclid',- 'max'], optional, default:- None) β Defines whether the spectral profiles should be normalized.- None: no normalization is applied.
- 'euclid': spectra are normalized with respect to their total area,
- 'max': spectra are normalized with respect to their maximum value.
 
- solverConc (any value of [ - 'lstsq',- 'nnls',- 'pnnls'], optional, default:- 'lstsq') β Solver used to get- Cfrom- Xand- St.- 'lstsq': uses ordinary least squares with- lstsq
- 'nnls': non-negative least squares (- nnls) are applied sequentially on all profiles
- 'pnnls': non-negative least squares (- nnls) are applied on profiles indicated in- nonnegConcand ordinary least squares on other profiles.
 
- solverSpec (any value of [ - 'lstsq',- 'nnls',- 'pnnls'], optional, default:- 'lstsq') β Solver used to get- Stfrom- Xand- C.- 'lstsq': uses ordinary least squares with- lstsq
- 'nnls': non-negative least squares (- nnls) are applied sequentially on all profiles
- 'pnnls': non-negative least squares (- nnls) are applied on profiles indicated in- nonnegConcand ordinary least squares on other profiles.
 
- storeIterations ( - bool, optional, default: False) β Whether to store the C and St generated at each iteration.
- tol ( - float, optional, default: 0.1) β Convergence criterion on the change of residuals (percent change of standard deviation of residuals).
- unimodConc (any of [βallβ] or a list, optional, default: - 'all') β Unimodality constraint on concentrations.- 'all': all concentrations profiles are considered unimodal.
- listof indexes: the corresponding profiles are considered unimodal, not the others. For instance- [0, 2]indicates that profile- #0and- #2are unimodal while profile- #1can be multimodal.
- []: all profiles can be multimodal.
 
- unimodConcMod (any value of [ - 'strict',- 'smooth'], optional, default:- 'strict') β Method to apply unimodality.- 'strict': values deviating from unimodality are reset to the value of the previous point.
- 'smooth': both values (deviating point and previous point) are modified to avoid steps in the concentration profile.
 
- unimodConcTol ( - float, optional, default: 1.1) β Tolerance parameter for unimodality.- Correction is applied only if: - C[i,j] > C[i-1,j] * unimodTolon the decreasing branch of profile- #j,
- C[i,j] < C[i-1,j] * unimodTolon the increasing branch of profile- #j.
 
- unimodSpec (any of [βallβ] or a list, optional, default: []) β Unimodality constraint on Spectra. - []: all profiles can be multimodal.
- 'all': all profiles are unimodal (equivalent to- range(n_components)).
- array of indexes : the corresponding profiles are considered unimodal, not the others. For instance - [0, 2]indicates that profile- #0and- #2are unimodal while profile- #1can be multimodal.
 
- unimodSpecMod (any value of [ - 'strict',- 'smooth'], optional, default:- 'strict') β Method used to apply unimodality.- 'strict': values deviating from unimodality are reset to the value of the previous point.
- 'smooth': both values (deviating point and previous point) are modified to avoid steps in the concentration profile.
 
- unimodSpecTol ( - float, optional, default: 1.1) β Tolerance parameter for unimodality.- Correction is applied only if the deviating point - St[j, i]is larger than- St[j, i-1] * unimodSpecTolon the decreasing branch of profile- #j, or lower than- St[j, i-1] * unimodTolon the increasing branch of profile- #j.
 
 - See also - EFA
- Perform an Evolving Factor Analysis (forward and reverse). 
- FastICA
- Perform Independent Component Analysis with a fast algorithm. 
- IRIS
- Integral inversion solver for spectroscopic data. 
- NMF
- Non-Negative Matrix Factorization. 
- PCA
- Perform Principal Components Analysis. 
- SIMPLISMA
- SIMPLe to use Interactive Self-modeling Mixture Analysis. 
- SVD
- Perform a Singular Value Decomposition. 
 - Initialize the BaseConfigurable class. - Parameters:
- log_level (int, optional) β The log level at startup. Default is logging.WARNING. 
- **kwargs (dict) β Additional keyword arguments for configuration. 
 
 - Attributes Summary - The final concentration profiles. - The last constrained concentration profiles, i.e. after applying the hard and soft constraints. - The list of constrained concentration profiles at each ALS iteration. - The list of concentration profiles obtained by least square optimization and scaling at each ALS iteration. - Deprecated. - The final spectra profiles. - The list of constrained spectral profiles at each ALS iteration. - The last spectral profiles obtained by least-square optimization, before constraints. - The list of optimized spectral profiles at each ALS iteration. - Deprecated. - Return the X input dataset (eventually modified by the model). - The - Yinput.- Supplementary positional arguments passed to the external function. - Supplementary positional arguments passed to the external function. - Defines the concentration profiles subjected to closure constraint. - The method used to enforce closure (Omidikia et al. [2018]). - The value of the sum of concentrations profiles subjected to closure. - NDDatasetwith components in feature space (n_components, n_features).- traitlets.config.Configobject.- The extra outputs of the external function used to get concentrations. - The extra outputs of the external function used to get spectra. - Correspondence of the profiles returned by - getConcand- C[:,hardConc].- An external function that provide - len(hardConc)concentration profiles.- An external function that will provide - len(hardSpec)concentration profiles.- Correspondence between the indexes of the spectra returned by - getSpecand- St.- Defines hard constraints on the concentration profiles. - Defines hard constraints on the spectral profiles. - Supplementary keyword arguments passed to the external function. - Supplementary keyword arguments passed to the external function. - Return - logoutput.- Maximum number of ALS iteration. - Maximum number of successive non-converging iterations. - Monotonic decrease constraint on concentrations. - Tolerance parameter for monotonic decrease. - Monotonic increase constraint on concentrations. - Tolerance parameter for monotonic decrease. - Number of components that were fitted. - Object name - Non-negativity constraint on concentrations. - Non-negativity constraint on spectra. - Defines whether the spectral profiles should be normalized. - Whether to store the C and St generated at each iteration. - Convergence criterion on the change of residuals (percent change of standard deviation of residuals). - Unimodality constraint on concentrations. - Method to apply unimodality. - Tolerance parameter for unimodality. - Unimodality constraint on Spectra. - Method used to apply unimodality. - Tolerance parameter for unimodality. - Methods Summary - fit(X,Β Y)- Fit the MCRALS model on an X dataset using initial concentration or spectra. - fit_transform(X,Β Y,Β **kwargs)- Fit the model with - Xand apply the dimensionality reduction on- X.- get_components([n_components])- Return the component's dataset: (selected n_components, n_features). - inverse_transform([X_transform])- Transform data back to its original space. - parameters([replace,Β removed,Β default])- Alias for - paramsmethod.- params([default])- Return current or default configuration values. - plotmerit([X,Β X_hat])- Plot the input ( - X), reconstructed (- X_hat) and residuals.- reconstruct([X_transform])- Transform data back to its original space. - reduce([X])- Apply dimensionality reduction to - X.- reset()- Reset configuration parameters to their default values. - to_dict()- Return config value in a dict form. - transform([X])- Apply dimensionality reduction to - X.- Attributes Documentation - Cο
- The final concentration profiles. 
 - C_constrainedο
- The last constrained concentration profiles, i.e. after applying the hard and soft constraints. 
 - C_constrained_listο
- The list of constrained concentration profiles at each ALS iteration. - Requires - MCRALS.storeIterationsset to True.
 - C_ls_listο
- The list of concentration profiles obtained by least square optimization and scaling at each ALS iteration. - Requires - MCRALS.storeIterationsset to True.
 - Stο
- The final spectra profiles. 
 - St_constrained_listο
- The list of constrained spectral profiles at each ALS iteration. - Requires - MCRALS.storeIterationsset to True.
 - St_lsο
- The last spectral profiles obtained by least-square optimization, before constraints. - Spectra obtained after solving \(C_{\textrm{constrained}} \cdot St = X\) for \(St\). 
 - St_ls_listο
- The list of optimized spectral profiles at each ALS iteration. - Requires - MCRALS.storeIterationsset to True.
 - Xο
- Return the X input dataset (eventually modified by the model). 
 - argsGetConcο
- Supplementary positional arguments passed to the external function. 
 - argsGetSpecο
- Supplementary positional arguments passed to the external function. 
 - closureConcο
- Defines the concentration profiles subjected to closure constraint. - []: no constraint is applied.
- 'all': all profile are constrained so that their weighted sum equals the- closureTarget
- listof indexes: the corresponding profiles are constrained so that their weighted sum equals- closureTarget.
 
 - closureMethodο
- The method used to enforce closure (Omidikia et al. [2018]). - 'scaling'recompute the concentration profiles using least squares:\[C \leftarrow C \cdot \textrm{diag} \left( C_L^{-1} c_t \right)\]- where \(c_t\) is the vector given by - closureTargetand \(C_L^{-1}\) is the left inverse of \(C\).
- 'constantSum'normalize the sum of concentration profiles to- closureTarget.
 
 - closureTargetο
- The value of the sum of concentrations profiles subjected to closure. - 'default': the total concentration is set to- 1.0for all observations.
- array-like of size n_observations: the values of concentration for each observation. Hence, - np.ones(X.shape[0])would be equivalent to- 'default'.
 
 - componentsο
- NDDatasetwith components in feature space (n_components, n_features).- See also - get_components
- Retrieve only the specified number of components. 
 
 - configο
- traitlets.config.Configobject.
 - extraOutputGetConcο
- The extra outputs of the external function used to get concentrations. 
 - extraOutputGetSpecο
- The extra outputs of the external function used to get spectra. 
 - getC_to_C_idxο
- Correspondence of the profiles returned by - getConcand- C[:,hardConc].- 'default': the profiles correspond to those of- C[:,hardConc]. This is equivalent to- range(len(hardConc))
- listof indexes or of- None. For instance- [2, 1, 0]indicates that the third profile returned by- getC(index- 2) corresponds to the 1st profile of- C[:, hardConc], the 2nd returned profile (index- 1) corresponds to second profile of- C[:, hardConc], etcβ¦
 
 - getConcο
- An external function that provide - len(hardConc)concentration profiles.- It should be using one of the following syntax: - getConc(Ccurr, *argsGetConc, **kwargsGetConc) -> hardC
- getConc(Ccurr, *argsGetConc, **kwargsGetConc) -> hardC, newArgsGetConc
- getConc(Ccurr, *argsGetConc, **kwargsGetConc) -> hardC, newArgsGetConc, extraOutputGetConc
 - where: - Ccurris the current- Cdataset,
- argsGetConcare the parameters needed to completely specify the function.
- hardCis a- ndarrayor- NDDatasetof shape (n_observations , len(- hardConc),
- newArgsGetConcare the updated parameters for the next iteration (can be- None),
- extraOutputGetConccan be any other relevant output to be kept in- extraOutputGetConcattribute, a list of- extraOutputGetConcat each MCR ALS iteration.
 - Note - getConccan be also a serialized function created using dill and base64 python libraries. Normally not used directly, it is here for internal process.
 - getSpecο
- An external function that will provide - len(hardSpec)concentration profiles.- It should be using one of the following syntax: - getSpec(Stcurr, *argsGetSpec, **kwargsGetSpec) -> hardSt
- getSpec(Stcurr, *argsGetSpec, **kwargsGetSpec) -> hardSt, newArgsGetSpec
- getSpec(Stcurr, *argsGetSpec, **kwargsGetSpec) -> hardSt, newArgsGetSpec, extraOutputGetSpec
 - with: 
- *argsGetSpecand- **kwargsGetSpec: the parameters needed to completely specify the function.
- hardSt:- ndarrayor- NDDatasetof shape- (n_observations, len(hardSpec),
- newArgsGetSpec: updated parameters for the next ALS iteration (can be None),
- extraOutputGetSpec: any other relevant output to be kept in- extraOutputGetSpecattribute, a list of- extraOutputGetSpecat each iterations.
 - Note - getSpeccan be also a serialized function created using dill and base64 python libraries. Normally not used directly, it is here for internal process.
 - getSt_to_St_idxο
- Correspondence between the indexes of the spectra returned by - getSpecand- St.- 'default': the indexes correspond to those of- St. This is equivalent to- range(len(hardSpec)).
- listof indexes : corresponding indexes in- St, i.e.- [2, None, 0]indicates that the first returned profile corresponds to the third- Stprofile (index- 2), the 2nd returned profile does not correspond to any profile in- St, the 3rd returned profile corresponds to the first- Stprofile (index- 0).
 
 - hardConcο
- Defines hard constraints on the concentration profiles. 
 - hardSpecο
- Defines hard constraints on the spectral profiles. 
 - kwargsGetConcο
- Supplementary keyword arguments passed to the external function. 
 - kwargsGetSpecο
- Supplementary keyword arguments passed to the external function. 
 - logο
- Return - logoutput.
 - maxdivο
- Maximum number of successive non-converging iterations. 
 - monoDecConcο
- Monotonic decrease constraint on concentrations. - []: no constraint is applied.
- listof indexes: the corresponding profiles are considered to decrease monotonically, not the others. For instance- [0, 2]indicates that profile- #0and- #2are decreasing while profile- #1can increase.
 
 - monoDecTolο
- Tolerance parameter for monotonic decrease. - Correction is applied only if: - C[i,j] > C[i-1,j] * unimodTol.
 - monoIncConcο
- Monotonic increase constraint on concentrations. - []: no constraint is applied.
- listof indexes: the corresponding profiles are considered to increase monotonically, not the others. For instance- [0, 2]indicates that profile- #0and- #2are increasing while profile- #1can decrease.
 
 - monoIncTolο
- Tolerance parameter for monotonic decrease. - Correction is applied only if - C[i,j] < C[i-1,j] * unimodTolalong profile- #j.
 - n_componentsο
- Number of components that were fitted. 
 - nameο
- Object name 
 - nonnegConcο
- Non-negativity constraint on concentrations. - 'all': all concentrations profiles are considered non-negative.
- listof indexes: the corresponding profiles are considered non-negative, not the others. For instance- [0, 2]indicates that profile #0 and #2 are non-negative while profile #1 can be negative.
- []: all profiles can be negative.
 
 - nonnegSpecο
- Non-negativity constraint on spectra. - 'all': all profiles are considered non-negative.
- listof indexes : the corresponding profiles are considered non-negative, not the others. For instance- [0, 2]indicates that profile- #0and- #2are non-negative while profile- #1can be negative.
- []: all profiles can be negative.
 
 - normSpecο
- Defines whether the spectral profiles should be normalized. - None: no normalization is applied.
- 'euclid': spectra are normalized with respect to their total area,
- 'max': spectra are normalized with respect to their maximum value.
 
 - solverConcο
- Solver used to get - Cfrom- Xand- St.- 'lstsq': uses ordinary least squares with- lstsq
- 'nnls': non-negative least squares (- nnls) are applied sequentially on all profiles
- 'pnnls': non-negative least squares (- nnls) are applied on profiles indicated in- nonnegConcand ordinary least squares on other profiles.
 
 - solverSpecο
- Solver used to get - Stfrom- Xand- C.- 'lstsq': uses ordinary least squares with- lstsq
- 'nnls': non-negative least squares (- nnls) are applied sequentially on all profiles
- 'pnnls': non-negative least squares (- nnls) are applied on profiles indicated in- nonnegConcand ordinary least squares on other profiles.
 
 - storeIterationsο
- Whether to store the C and St generated at each iteration. 
 - tolο
- Convergence criterion on the change of residuals (percent change of standard deviation of residuals). 
 - unimodConcο
- Unimodality constraint on concentrations. - 'all': all concentrations profiles are considered unimodal.
- listof indexes: the corresponding profiles are considered unimodal, not the others. For instance- [0, 2]indicates that profile- #0and- #2are unimodal while profile- #1can be multimodal.
- []: all profiles can be multimodal.
 
 - unimodConcModο
- Method to apply unimodality. - 'strict': values deviating from unimodality are reset to the value of the previous point.
- 'smooth': both values (deviating point and previous point) are modified to avoid steps in the concentration profile.
 
 - unimodConcTolο
- Tolerance parameter for unimodality. - Correction is applied only if: - C[i,j] > C[i-1,j] * unimodTolon the decreasing branch of profile- #j,
- C[i,j] < C[i-1,j] * unimodTolon the increasing branch of profile- #j.
 
 - unimodSpecο
- Unimodality constraint on Spectra. - []: all profiles can be multimodal.
- 'all': all profiles are unimodal (equivalent to- range(n_components)).
- array of indexes : the corresponding profiles are considered unimodal, not the others. For instance - [0, 2]indicates that profile- #0and- #2are unimodal while profile- #1can be multimodal.
 
 - unimodSpecModο
- Method used to apply unimodality. - 'strict': values deviating from unimodality are reset to the value of the previous point.
- 'smooth': both values (deviating point and previous point) are modified to avoid steps in the concentration profile.
 
 - unimodSpecTolο
- Tolerance parameter for unimodality. - Correction is applied only if the deviating point - St[j, i]is larger than- St[j, i-1] * unimodSpecTolon the decreasing branch of profile- #j, or lower than- St[j, i-1] * unimodTolon the increasing branch of profile- #j.
 - Methods Documentation - fit(X, Y)[source]ο
- Fit the MCRALS model on an X dataset using initial concentration or spectra. - Parameters:
- X ( - NDDatasetor array-like of shape (n_observations, n_features)) β Training data.
- Y (array-like or list of array-like) β Initial concentration or spectra. 
 
- Returns:
- self β The fitted instance itself. 
 - See also - fit_transform
- Fit the model with an input dataset - Xand apply the dimensionality reduction on- X.
- fit_reduce
- Alias of - fit_transform(Deprecated).
 
 - fit_transform(X, Y, **kwargs)[source]ο
- Fit the model with - Xand apply the dimensionality reduction on- X.- Parameters:
- X ( - NDDatasetor array-like of shape (n_observations, n_features)) β Training data.
- Y (array-like or list of array-like) β Initial concentration or spectra. 
- **kwargs (keyword parameters, optional) β See Other Parameters. 
 
- Returns:
- NDDatasetβ Dataset with shape (n_observations, n_components).
- Other Parameters:
- n_components ( - int, optional) β The number of components to use for the reduction. If not given the number of components is eventually the one specified or determined in the- fitprocess.
 
 - get_components(n_components=None)ο
- Return the componentβs dataset: (selected n_components, n_features). - Parameters:
- n_components ( - int, optional, default:- None) β The number of components to keep in the output dataset. If- None, all calculated components are returned.
- Returns:
- NDDatasetβ Dataset with shape (n_components, n_features)
 
 - inverse_transform(X_transform=None, **kwargs)[source]ο
- Transform data back to its original space. - In other words, return an input - X_originalwhose reduce/transform would be X.- Parameters:
- X_transform (array-like of shape (n_observations, n_components), optional) β Reduced - Xdata, where- n_observationsis the number of observations and- n_componentsis the number of components. If- X_transformis not provided, a transform of- Xprovided in- fitis performed first.
- Y_transform ( - NDDatasetor array-like of shape (n_observations,- n_components), optional) β New data, where n_targets is the number of variables to predict. If- Y_transformis not provided, a transform of- Yprovided in- fitis performed first.
- **kwargs (keyword parameters, optional) β See Other Parameters. 
 
- Returns:
- NDDatasetβ Dataset with shape (n_observations, n_features).
- Other Parameters:
- n_components ( - int, optional) β The number of components to use for the reduction. If not given the number of components is eventually the one specified or determined in the- fitprocess.
 
 - parameters(replace="params", removed="0.8.0") def parameters(self, default=False)[source]ο
- Alias for - paramsmethod.- Deprecated since version 0.8.0: Use - paramsinstead.
 - plotmerit(X=None, X_hat=None, **kwargs)[source]ο
- Plot the input ( - X), reconstructed (- X_hat) and residuals.- \(X\) and \(\hat{X}\) can be passed as arguments. If not, the - Xattribute is used for \(X`and :math:\)hat{X}`is computed by the- inverse_transformmethod- Parameters:
- X ( - NDDataset, optional) β Original dataset. If is not provided (default), the- Xattribute is used and X_hat is computed using- inverse_transform.
- X_hat ( - NDDataset, optional) β Inverse transformed dataset. if- Xis provided,- X_hatmust also be provided as compuyed externally.
- **kwargs (keyword parameters, optional) β See Other Parameters. 
 
- Returns:
- Axesβ Matplotlib subplot axe.
- Other Parameters:
- colors ( - tupleor- ndarrayof 3 colors, optional) β Colors for- X,- X_hatand residuals- E. in the case of 2D, The default colormap is used for- X. By default, the three colors are- NBlue,- NGreenand- NRed(which are colorblind friendly).
- offset ( - float, optional, default:- None) β Specify the separation (in percent) between the \(X\) , \(X_hat\) and \(E\).
- nb_traces ( - intor- 'all', optional) β Number of lines to display. Default is- 'all'.
- **others (Other keywords parameters) β Parameters passed to the internal - plotmethod of the- Xdataset.
 
 
 - reconstruct(X_transform=None, **kwargs)[source]ο
- Transform data back to its original space. - In other words, return an input - X_originalwhose reduce/transform would be- X_transform.- Parameters:
- X_transform (array-like of shape (n_observations, n_components), optional) β Reduced - Xdata, where- n_observationsis the number of observations and- n_componentsis the number of components. If- X_transformis not provided, a transform of- Xprovided in- fitis performed first.
- **kwargs (keyword parameters, optional) β See Other Parameters. 
 
- Returns:
- NDDatasetβ Dataset with shape (n_observations, n_features).
- Other Parameters:
- n_components ( - int, optional) β The number of components to use for the reduction. If not given the number of components is eventually the one specified or determined in the- fitprocess.
 - See also - reconstruct
- Alias of inverse_transform (Deprecated). 
 - Notes - Deprecated in version 0.6. 
 - reduce(X=None, **kwargs)[source]ο
- Apply dimensionality reduction to - X.- Parameters:
- X ( - NDDatasetor array-like of shape (n_observations, n_features), optional) β New data, where n_observations is the number of observations and n_features is the number of features. if not provided, the input dataset of the- fitmethod will be used.
- **kwargs (keyword parameters, optional) β See Other Parameters. 
 
- Returns:
- NDDatasetβ Dataset with shape (n_observations, n_components).
- Other Parameters:
- n_components ( - int, optional) β The number of components to use for the reduction. If not given the number of components is eventually the one specified or determined in the- fitprocess.
 - Notes - Deprecated in version 0.6. 
 - transform(X=None, **kwargs)ο
- Apply dimensionality reduction to - X.- Parameters:
- X ( - NDDatasetor array-like of shape (n_observations, n_features), optional) β New data, where n_observations is the number of observations and n_features is the number of features. if not provided, the input dataset of the- fitmethod will be used.
- **kwargs (keyword parameters, optional) β See Other Parameters. 
 
- Returns:
- NDDatasetβ Dataset with shape (n_observations, n_components).
- Other Parameters:
- n_components ( - int, optional) β The number of components to use for the reduction. If not given the number of components is eventually the one specified or determined in the- fitprocess.
 
 
Examples using spectrochempy.MCRALS
 
