GramSpace¶
The representation space induced by a PSD Gram matrix: geometry and spectral energy.
A PSD matrix G admits vectors phi_i with G_ij = <phi_i, phi_j>; everything here is
computed from G alone, never from the phi_i:
- geometry -- the pseudometric
d(i, j)^2 = G_ii + G_jj - 2 G_ij, neighbourhoods, level sets and representational equivalence; - spectrum --
G = V Lambda V^T, the retained subspaceV_r, the per-object mode energyE_ik = lambda_k V_ik^2and the orthogonal-energy ratioE_ratio; - comparison -- alignment with another Gram (CKA) and the decomposition
G_hat = a K_hat + Rinto the part another Gram explains and the residual.
GramSpace
¶
GramSpace(
G,
labels=None,
predictions=None,
components: dict | None = None,
name: str = "",
info: dict | None = None,
)
Representation space of n objects given by a symmetric PSD Gram matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
G
|
|
required | |
labels
|
Optional per-object integers, stored for the readings and plots. |
None
|
|
predictions
|
Optional per-object integers, stored for the readings and plots. |
None
|
|
components
|
dict | None
|
Optional |
None
|
Source code in src\fannar\space.py
predictions
instance-attribute
¶
distances
cached
property
¶
(n, n) pseudometric d(i, j) = sqrt(G_ii + G_jj - 2 G_ij). O(n^2).
eigenvalues_raw
cached
property
¶
Ascending eigenvalues without clipping (negative ones reveal a non-PSD input).
eigenvalues
property
¶
Descending eigenvalues, clipped at zero. O(n^3), computed once.
is_psd
¶
subset
¶
The sub-space of a subset of objects (the submatrix, not re-transformed).
Source code in src\fannar\space.py
distance
¶
distance_function
¶
neighbors
¶
The k objects closest to i0 (excluding itself), nearest first. O(n).
Source code in src\fannar\space.py
level_band
¶
level_set
¶
equivalence_classes
¶
Groups of objects at pseudodistance <= tol (indistinguishable for this space).
Source code in src\fannar\space.py
participation_rank
¶
round((sum lambda)^2 / sum lambda^2) from the trace and the Frobenius norm, O(n^2).
Source code in src\fannar\space.py
rank
¶
Number of retained modes: "participation", "tau" (cumulative energy >= tau)
or an explicit integer.
Source code in src\fannar\space.py
mode_energy
¶
energies
¶
Retained, orthogonal and total energy per object, and E_ratio = E_perp / G_ii.
Source code in src\fannar\space.py
embedding
¶
Coordinates sqrt(lambda_k) V_ik of the dim dominant modes (kernel PCA of G)
and the fraction of the trace they retain.
Source code in src\fannar\space.py
containment
¶
Fraction of the centred class-indicator directions inside V_r.
r defaults to K - 1 (number of classes minus one), which makes the value
comparable between spaces; the participation rank of each space is not.
Source code in src\fannar\space.py
cka
¶
Centred kernel alignment with another Gram (GramSpace or array).
decompose
¶
G_hat = a K_hat + R with a = CKA(G, K): the part the reference explains (seen)
and the residual, each projected on the PSD cone, plus the discarded spectral mass.