BaseFitter1D#
- class glue.core.fitters.BaseFitter1D(**params)#
Bases:
objectBase class for 1D fitters.
This abstract class must be overwritten.
Attributes Summary
A dict of the constraints on each parameter in
param_names.A dictionary of the current setting of each model hyperparameter.
Methods Summary
build_and_fit(x, y[, dy])Method which builds the arguments to fit, and calls that method
fit(x, y, dy, constraints, **options)Fit the model to data.
plot(fit_result, axes, x[, linewidth, ...])Plot the result of a fit.
predict(fit_result, x)Evaluate the model at a set of locations.
set_constraint(parameter_name[, value, ...])Update a constraint.
summarize(fit_result, x, y[, dy])Return a textual summary of the fit.
Attributes Documentation
- constraints#
A dict of the constraints on each parameter in
param_names. Each value is itself a dict with 3 items:- Key value:
The default value
- Key fixed:
True / False, indicating whether the parameter is fixed
- Key bounds:
[min, max] or None, indicating lower/upper limits
- label = 'Fitter'#
- options#
A dictionary of the current setting of each model hyperparameter.
Hyperparameters are defined in subclasses by creating class-level
Optionattributes. This attribute dict maps{hyperparameter_name: current_value}
- param_names = []#
Methods Documentation
- build_and_fit(x, y, dy=None)#
Method which builds the arguments to fit, and calls that method
- fit(x, y, dy, constraints, **options)#
Fit the model to data.
This must be overriden by a subclass.
- Parameters:
x (
numpy.ndarray) – The x values of the datay (
numpy.ndarray) – The y values of the datady (
numpy.ndarray) – 1 sigma uncertainties on each datum (optional)constraints – The current value of the
constraintspropertyoptions – kwargs for model hyperparameters.
- Returns:
An object representing the fit result.
- plot(fit_result, axes, x, linewidth=None, alpha=None, color=None, normalize=None)#
Plot the result of a fit.
- Parameters:
fit_result – The output from fit
axes – The Matplotlib axes to add the fit to
x – The values of X at which to visualize the model
- Returns:
A list of matplotlib artists. This is important: plots will not be properly cleared if this isn’t provided
- predict(fit_result, x)#
Evaluate the model at a set of locations.
This must be overridden in a subclass.
- Parameters:
fit_result – The result from the fit method
x (
numpy.ndarray) – Locations to evaluate model at
- Returns:
model(x)
- Return type: