Skip to main content

linear_dictionary_transform

Function linear_dictionary_transform 

Source
pub fn linear_dictionary_transform(
    x: ArrayView2<'_, f64>,
    atoms: ArrayView2<'_, f64>,
    top_k: usize,
    code_ridge: f64,
) -> Result<Array2<f64>, String>
Expand description

Encode held-out rows x (M x P) against a frozen dictionary atoms (K x P) using the same top-top_k ridge least-squares routing the fit uses against its final atoms. Returns the (M, K) sparse code matrix.

This is the out-of-sample transform/encode step for a fitted linear dictionary; the math (top-k selection + active-set ridge solve) lives in the Rust core so the Python facade stays a thin wrapper.