BaseFitter1D¶
- class glue.core.fitters.BaseFitter1D(**params)[source]¶
Bases:
object
Base class for 1D fitters.
This abstract class must be overwritten.
Attributes Summary
A dict of the constraints on each parameter in
param_names
.A short label for the fit, used by the GUI
A dictionary of the current setting of each model hyperparameter.
list of parameter names that support restrictions
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[source]¶
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'¶
A short label for the fit, used by the GUI
- options[source]¶
A dictionary of the current setting of each model hyperparameter.
Hyperparameters are defined in subclasses by creating class-level
Option
attributes. This attribute dict maps{hyperparameter_name: current_value}
- param_names = []¶
list of parameter names that support restrictions
Methods Documentation
- build_and_fit(x, y, dy=None)[source]¶
Method which builds the arguments to fit, and calls that method
- fit(x, y, dy, constraints, **options)[source]¶
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
constraints
propertyoptions – kwargs for model hyperparameters.
- Returns:
An object representing the fit result.
- plot(fit_result, axes, x, linewidth=None, alpha=None, color=None, normalize=None)[source]¶
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)[source]¶
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:
- set_constraint(parameter_name, value=None, fixed=None, limits=None)[source]¶
Update a constraint.
- Parameters:
parameter_name (str) – name of the parameter to update
value – Set the default value (optional)
limits – Set the limits to[min, max] (optional)
fixed – Set whether the parameter is fixed (optional)