splisosm.kernel#
Spatial kernel abstractions.
Classes#
Graph-based spatial covariance kernel built from spot coordinates. |
Module Contents#
- class splisosm.kernel.SpatialCovKernel(coords, k_neighbors=4, model='icar', rho=0.99, standardize_cov=True, centering=False, approx_rank=None)#
Bases:
KernelGraph-based spatial covariance kernel built from spot coordinates.
- Parameters:
coords (ndarray | Tensor) – Spot coordinates of shape (n_spots, 2).
k_neighbors (int) – Number of nearest neighbors used to build the graph.
model (Literal['icar', 'car', 'isar', 'sar']) – Spatial process model for inverse covariance construction. Supported values are
'icar','car','isar', and'sar'.rho (float) – Spatial autocorrelation coefficient.
standardize_cov (bool) – If True, scales covariance to unit marginal variance.
centering (bool) – If True, applies centering so row/column sums are approximately zero.
approx_rank (int | None) – If provided, computes and stores a rank-
approx_rankfactorization.
- eigendecomposition()#
Compute and store eigendecomposition of the dense kernel.
- Raises:
ValueError – If only low-rank kernel factors are stored.
- Return type:
None
- eigenvalues(k=None)#
Return leading eigenvalues of the kernel matrix.
- Parameters:
k (int | None) – Number of leading eigenvalues to return. If None, all available eigenvalues are returned.
- Returns:
Eigenvalues sorted in descending order.
- Return type:
- rank()#
Return effective rank of the kernel representation.
- Returns:
Kernel rank.
- Return type:
int
- realization()#
Return the realized dense kernel matrix.
- Returns:
Dense matrix of shape (n_spots, n_spots).
- Return type:
- shape()#
Return kernel shape.
- Returns:
Pair (n_spots, n_spots).
- Return type:
tuple of int
- xtKx(x)#
Compute the kernel quadratic form for multivariate inputs.
- K_sp: Tensor | None#
Dense kernel matrix of shape (n_spots, n_spots) when full-rank storage is used.
Nonewhen low-rank storage is used.