edges.modeling.core¶
Core classes for linear modelling.
- class edges.modeling.core.FixedLinearModel(*, model: Model, x, init_basis=None)[source]¶
A base class for a linear model fixed at a certain set of co-ordinates.
Using this class caches the basis functions at the particular coordinates, and thus speeds up the fitting of multiple sets of data at those co-ordinates.
- Parameters:
model (edges.modeling.core.Model) – The linear model to evaluate at the co-ordinates
x (numpy.ndarray) – A set of co-ordinates at which to evaluate the model.
init_basis – If the basis functions of the model, evaluated at x, are known already, they can be input directly to save computation time.
- at_x(x: ndarray) Self[source]¶
Return a new
FixedLinearModelat given co-ordinates.
- fit(ydata: ndarray, weights: ndarray | float = 1.0, xdata: ndarray | None = None, **kwargs) ModelFit[source]¶
Create a linear-regression fit object.
- Parameters:
ydata – The data to fit.
weights – The weights to apply to the data.
xdata – The co-ordinates at which to fit the data. If not given, use
self.x.
- Returns:
fit – The
ModelFitobject.- Other Parameters:
All other parameters used to construct the :class:`ModelFit` object. Includes
``method`` to specify the lstsq solving method.
- property n_terms¶
The number of terms/parameters in the model.
- with_nterms(n_terms: int, parameters: Sequence | None = None) Self[source]¶
Return a new
FixedLinearModelwith given nterms and parameters.
- with_params(parameters: Sequence) Self[source]¶
Return a new
FixedLinearModelwith givne parameters.
- class edges.modeling.core.Model(*, parameters=None, n_terms=NOTHING, transform: XTransform = IdentityTransform(), xtransform: XTransform | None = NOTHING, basis_scaler: Callable | None = None, data_transform: DataTransform = IdentityTransform())[source]¶
A base class for a linear model.
- at(**kwargs) FixedLinearModel[source]¶
Get an evaluated linear model.
- fit(xdata: ndarray, ydata: ndarray, weights: ndarray | float = 1.0, **kwargs) ModelFit[source]¶
Create a linear-regression fit object.
- abstractmethod get_basis_term(indx: int, x: ndarray) ndarray[source]¶
Define the basis terms for the model.
- get_basis_term_transformed(indx: int, x: ndarray, with_scaler: bool = True) ndarray[source]¶
Get the basis term after coordinate transformation.
- get_basis_terms(x: ndarray, with_scaler: bool = True) ndarray[source]¶
Get a 2D array of all basis terms at
x.