pybaselines.Baseline.collab_pls
- Baseline.collab_pls(data, average_dataset=True, method='asls', method_kwargs=None)[source]
Collaborative Penalized Least Squares (collab-PLS).
Averages the data or the fit weights for an entire dataset to get more optimal results. Uses any Whittaker-smoothing-based or weighted spline algorithm.
- Parameters:
- dataarray_like, shape (M, N)
An array with shape (M, N) where M is the number of entries in the dataset and N is the number of data points in each entry.
- average_datasetbool, optional
If True (default) will average the dataset before fitting to get the weighting. If False, will fit each individual entry in the dataset and then average the weights to get the weighting for the dataset.
- method
str
, optional A string indicating the Whittaker-smoothing-based or weighted spline method to use for fitting the baseline. Default is 'asls'.
- method_kwargs
dict
, optional A dictionary of keyword arguments to pass to the selected method function. Default is None, which will use an empty dictionary.
- Returns:
- baselines
np.ndarray
, shape (M, N) An array of all of the baselines.
- params
dict
A dictionary with the following items:
- 'average_weights': numpy.ndarray, shape (N,)
The weight array used to fit all of the baselines.
- 'average_alpha': numpy.ndarray, shape (N,)
Only returned if method is 'aspls' or 'pspline_aspls'. The alpha array used to fit all of the baselines for the
aspls()
orpspline_aspls()
methods.
- 'method_params': dict[str, list]
A dictionary containing the output parameters for each individual fit. Keys will depend on the selected method and will have a list of values, with each item corresponding to a fit.
- baselines
Notes
If method is 'aspls' or 'pspline_aspls', collab_pls will also calculate the alpha array for the entire dataset in the same manner as the weights.
References
Chen, L., et al. Collaborative Penalized Least Squares for Background Correction of Multiple Raman Spectra. Journal of Analytical Methods in Chemistry, 2018, 2018.