sidpy.proc.fitter.SidFitter¶
- class sidpy.proc.fitter.SidFitter(sidpy_dataset, fit_fn, xvec=None, ind_dims=None, guess_fn=None, num_fit_parms=None, km_guess=False, n_clus=None, return_cov=False, return_std=False, return_fit=False, fit_parameter_labels=None, num_workers=2, threads=2)[source]¶
Bases:
object
- Parameters:
sidpy_dataset ((sidpy.Dataset) Sidpy dataset object to be fit)
fit_fn ((function) Function used for fitting.)
arguments. (Should take xvec as the first argument and parameters as the rest of the)
xvec ((numpy ndarray or list of numpy ndarrays) (Optional))
xvec
array (Independent variable for fitting. Should be an)
provided (If the guess_fn is NOT)
xvecs (the dimension arrays are assumed to be)
ind_dims ((tuple) (Optional) Tuple with integer entries of the dimensions) – over which to parallelize. These should be the independent variable for the fitting. If NOT provided, it is assumed that all the non-spectral dimensions are independent dimensions.
guess_fn ((function) (optional) This optional function should be utilized to generate priors for the full fit)
(xvec (It takes)
parameters. (yvec) as inputs and should return the fit)
provided
num_fit_parms. (then the user MUST input the)
num_fit_parms ((int) Number of fitting parameters. This is needed IF the guess function is not provided to set)
function. (the priors for the parameters for the curve_fit)
km_guess ((bool) (default False) When set to True: Divides the spectra into clusters using)
sklearn.optimize.kMeans
centers (applies the fitting function on the cluster)
:param : :param uses the results as priors to each spectrum of the cluster.: :param n_clus: :type n_clus: (int) (default None) Used only when km_guess is set to True. Determines the number of clusters to be :param formed for sklearn.optimize.kmeans. If not provided then n_clus = self.num_computations/100: :param return_std: :type return_std: (bool) (default False) Returns the dataset with estimated standard deviation of the parameter :param values. Square roots of the diagonal of the covariance matrix.: :param return_cov: :type return_cov: (bool) (default False) Returns the estimated covariance of fitting parameters. Confer :param scipy.optimize.curve_fit for further details: :param return_fit: when set to true :type return_fit: (bool) (default False) Returns the fitted sidpy dataset using the optimal parameters :param fit_parameter_labels: :type fit_parameter_labels: (list) (default None) List of parameter labels :param num_workers: :type num_workers: (int) (default =2) Number of workers to use when setting up Dask client :param threads: :type threads: (int) (default =2) Number of threads to use when setting up Dask client :param Returns: :param ——-: :param sidpy.dataset: :type sidpy.dataset: if return_cov and return_fit are both set to False :param List: :type List: containing sidpy.dataset objects, if either of return_cov or return fit is set to True :param If multiple datasets are expected: :param the order of the returned datasets is: :param [sidpy.dataset with mean parameter values: :param : :param sidpy.dataset with estimated covariances of the fitting parameters: :param : :param sidpy.dataset that is fit with the parameters obtained after fitting]:
Methods
default_curve_fit
Perform the fit. **kwargs: extra parameters passed to scipy.optimize.curve_fit, e.g. bounds, type of lsq algorithm, etc.
If a guess_fn is provided: Applies the guess_fn to get priors for the fitting parameters.
This method returns the fitted dataset using the parameters generated by the fit function
get_km_priors
Calls the interactive visualizer for comparing raw and fit datasets.
- do_fit(**kwargs)[source]¶
Perform the fit. **kwargs: extra parameters passed to scipy.optimize.curve_fit, e.g. bounds, type of lsq algorithm, etc.
- do_guess()[source]¶
If a guess_fn is provided: Applies the guess_fn to get priors for the fitting parameters. self.prior is set as the output of guess function at each of the ind_dims
Returns: None ——-