use scirs2_core::ndarray::{Array1, Array2};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use sklears_core::{error::Result, types::Float};
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct LARSConfig {
pub max_iter: usize,
pub alpha: Float,
}
impl Default for LARSConfig {
fn default() -> Self {
Self {
max_iter: 500,
alpha: 1.0,
}
}
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct LARSResult {
pub coefficients: Array2<Float>,
pub active_set: Vec<usize>,
pub n_iter: usize,
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct LARSDirection {
pub direction: Array1<Float>,
pub correlation: Float,
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct LARSStepSize {
pub step_size: Float,
pub next_variable: Option<usize>,
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct LARSEncoder {
config: LARSConfig,
}
impl LARSEncoder {
pub fn new(config: LARSConfig) -> Self {
Self { config }
}
pub fn encode(
&self,
dictionary: &Array2<Float>,
_signal: &Array1<Float>,
) -> Result<LARSResult> {
let n_atoms = dictionary.nrows();
let coefficients = Array2::zeros((1, n_atoms));
let active_set = Vec::new();
Ok(LARSResult {
coefficients,
active_set,
n_iter: 0,
})
}
}