Kernel Normalization#
normalization
#
| CLASS | DESCRIPTION |
|---|---|
KernelNormalizer |
Unified kernel normalization for spectral methods and graph Laplacians. |
Classes#
KernelNormalizer(norm_type: NormalizationType = 'markov_symmetric', alpha: float = 0.5, eps: float = torch.finfo(torch.float32).eps)
#
Unified kernel normalization for spectral methods and graph Laplacians.
Provides a comprehensive interface for normalizing kernel matrices using various schemes suitable for diffusion maps, spectral clustering, and graph-based methods.
The normalizer is stateful and stores the density vector after each call, which can be accessed for analysis or use in other methods.
| PARAMETER | DESCRIPTION |
|---|---|
norm_type
|
Type of normalization to apply.
TYPE:
|
alpha
|
Anisotropy parameter for density correction. Controls the strength of
density-based reweighting. Must be in [0, 1]. When
TYPE:
|
eps
|
Small epsilon added to density for numerical stability.
TYPE:
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
q |
Density vector computed during the last normalization call. Shape (n_samples,).
TYPE:
|
Examples:
>>> import torch
>>> from spectre.kernel import GaussianKernel, KernelNormalizer
>>>
>>> # Create data and kernel
>>> X = torch.randn(50, 3)
>>> kernel = GaussianKernel(normalize=False)
>>> K = kernel(X)
>>>
>>> # Apply Markov normalization (diffusion maps style)
>>> normalizer = KernelNormalizer("markov_symmetric")
>>> T_sym = normalizer(K)
>>>
>>> # Compute Laplacian
>>> normalizer = KernelNormalizer("laplacian_symmetric")
>>> L_sym = normalizer(K) # Returns I - T_sym