spatial
Spatial basis columns for marginal-parameter formulas.
:class:SpatialDesign fits spatial bases for parameters with
:class:SpatialTerms, appends the K bases columns to the .obs as
sp_<parameter>_0, ..., sp_<parameter>_<K-1>, and adds them to the
parameter's formula. Basis columns are generated for the current chunk, so we
don't have to create it on the entire (potentially large, backed) dataset. For
penalization, we add
:class:~scdesigner.distributions.penalties.CoefficientPenalty to those columns
with d = basis.penalty_diag.
SpatialDesign
Extend .obs to include spatial basis columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_formula
|
mapping of str to str
|
Formula per marginal parameter, before spatial columns. |
required |
terms
|
mapping of str to SpatialTerm
|
Term per parameter. Parameters without one are unchanged. |
required |
spatial_cols
|
tuple of str
|
Coordinate columns of the observations. |
('spatial1', 'spatial2')
|
Attributes:
| Name | Type | Description |
|---|---|---|
formula |
dict of str to str
|
|
penalties |
tuple of CoefficientPenalty
|
One per penalized term. |
bases |
dict of str to SpatialBasis
|
Fitted basis per term. |
Source code in scdesigner/src/scdesigner/data/spatial.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
fit(obs, chunk_size=None)
Fit the spatial bases on coordinates in obs.
chunk_size control the number of considered per kernel evaluation.
See :meth:~scdesigner.data.basis.SpatialBasis.fit.
Source code in scdesigner/src/scdesigner/data/spatial.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
transform(obs)
Copy of obs with the fitted basis columns appended.
Source code in scdesigner/src/scdesigner/data/spatial.py
113 114 115 116 117 118 119 120 121 122 123 | |
SpatialTerm
dataclass
Unfitted spatial basis and optional penalty on its coefficients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
basis
|
SpatialBasis
|
Template |
required |
penalty
|
QuadraticPenalty
|
|
None
|
Source code in scdesigner/src/scdesigner/data/spatial.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |