pycsa.core.lin_reg¶
Linear regression module with buffer pool and sparse solver support
Functions
|
Does the linear regression with optional buffer pool and sparse solver |
|
Assembles the Fourier coefficients from the sine and cosine terms generated in the |
- pycsa.core.lin_reg.get_coeffs(fobj, ctx=None, buffer_pool=None)¶
Assembles the Fourier coefficients from the sine and cosine terms generated in the
Fourier transformer class.- Parameters:
fobj (
pycsa.core.fourier.f_transinstance) – instance of the Fourier transformer class.ctx (ComputeContext, optional) – Compute context bundling the buffer pool. If absent, defaults to
fobj.ctx(set byf_trans.__init__).buffer_pool (BufferPool, optional) – Deprecated. Pass
ctx=ComputeContext(buffer_pool=...)instead.
- Returns:
2D array corresponding to the
Mmatrix.- Return type:
array-like
- pycsa.core.lin_reg.do(fobj, cell, lmbda=0.0, iter_solve=True, save_coeffs=False, ctx=None, buffer_pool=None, use_sparse=False, prior=None)¶
Does the linear regression with optional buffer pool and sparse solver
- Parameters:
fobj (
pycsa.core.fourier.f_transinstance) – instance of the Fourier transformer class.cell (
pycsa.data.cell.topo_cellinstance) – cell object instancelmbda (float, optional) – regularisation parameter, by default 0.0
iter_solve (bool, optional) – toggles between using direct or iterative solver, by default True
save_coeffs (bool, optional) – skips the linear regression and just saves the generated
Mmatrix for diagnostics and debugging, by default Falsectx (ComputeContext, optional) – Compute context bundling the buffer pool. If absent, defaults to
fobj.ctx. Ifctx.prioris set and thepriorkwarg isNone, the context’s prior is used.buffer_pool (BufferPool, optional) – Deprecated. Pass
ctx=ComputeContext(buffer_pool=...)instead.use_sparse (bool, optional) – Use sparse matrix solver (automatic for few modes), by default False
prior (
pycsa.core.priors.Prior, optional) – Pluggable Tikhonov diagonal generator. WhenNone(default), the existing scalar-trace branch is used and numerics are bit-identical to historical behavior. When supplied, the prior is called asprior(fobj, E_tilda_lm, lmbda=lmbda)and the returned diagonal is added todiag(E_tilda_lm). Opt-in only; no production caller passes this kwarg.
- Returns:
a_m (ndarray) – Fourier amplitudes corresponding to the unknown vector in the linear problem. When
save_coeffs=Truethe regression is skipped and(None, None)is returned instead.data_recons (ndarray) – vector-like topography reconstructed from
a_m(Nonewhensave_coeffs=True).
- Raises:
ValueError – If the supplied
priorreturns a diagonal whose shape does not matchE_tilda_lm(checked in both the sparse and dense solver branches).