lamatrix.model#
Abstract base class for a Model object
Classes
|
Class for holding equations so we can have an HTML repr in Jupyter. |
|
Abstract base class to implement the Model class, used by all model types in lamatrix. |
- class lamatrix.model.Model(priors: List[Tuple] | None = None, posteriors: List[Tuple] | None = None)[source]#
Bases:
ABC
Abstract base class to implement the Model class, used by all model types in lamatrix.
Initialization function for all models. All models must be provided with input priors and posteriors that match their width.
- abstract property arg_names#
Returns a set of the user defined strings for all the arguments that the design matrix requires.
- property equation#
Provides the equation for the model in latex.
If accessed within a jupyter instance will return the equation in displayed latex, otherwise will return the equation in raw latex.
- evaluate(**kwargs)[source]#
Given an input set of arguments, will evaluate the model with the current best fit weights.
- fit(data: ndarray[Any, dtype[_ScalarType_co]], errors: ndarray[Any, dtype[_ScalarType_co]] | None = None, mask: ndarray[Any, dtype[_ScalarType_co]] | None = None, **kwargs)[source]#
Fit the design matrix of this model object.
Executing this function will update the posteriors argument to the best fit posteriors.
- Parameters:
data (np.ndarray) – Input data to fit
errors (np.ndarray, optional) – Errors on the input data
mask (np.ndarray, optional) – Mask to apply when fitting. Values where mask is False will not be used during the fit.
- abstract property nvectors#
Returns the number of vectors required to build the object.
- sample(**kwargs)[source]#
Given an input set of arguments, will evaluate the model with a sample of the best fit weights drawn from the posteriors.
- abstract property width#
Returns the width of the design matrix once built.