use crate::matrix::FdMatrix;
pub mod bayesian;
pub mod boost_fofr;
pub mod boost_fosr;
pub mod gamlss;
pub mod stability;
#[derive(Debug, Clone, PartialEq)]
pub struct BoostingConfig {
pub mstop: usize,
pub nu: f64,
pub nbasis: usize,
pub order: usize,
pub lfd_order: usize,
pub lambda: f64,
pub ncomp_x: usize,
pub seed: u64,
}
impl Default for BoostingConfig {
fn default() -> Self {
Self {
mstop: 100,
nu: 0.1,
nbasis: 10,
order: 4,
lfd_order: 2,
lambda: 1.0,
ncomp_x: 3,
seed: 0,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct BayesianConfig {
pub ncomp: usize,
pub tau2: f64,
pub ig_a0: f64,
pub ig_b0: f64,
pub n_iter: usize,
pub burn_in: usize,
pub thin: usize,
pub seed: u64,
}
impl Default for BayesianConfig {
fn default() -> Self {
Self {
ncomp: 4,
tau2: 100.0,
ig_a0: 0.001,
ig_b0: 0.001,
n_iter: 400,
burn_in: 200,
thin: 1,
seed: 0,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct StabilityConfig {
pub n_resamples: usize,
pub pi_thr: f64,
pub seed: u64,
}
impl Default for StabilityConfig {
fn default() -> Self {
Self {
n_resamples: 100,
pi_thr: 0.9,
seed: 0,
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub struct BoostFosrResult {
pub intercept: Vec<f64>,
pub beta: FdMatrix,
pub fitted: FdMatrix,
pub residuals: FdMatrix,
pub r_squared_t: Vec<f64>,
pub r_squared: f64,
pub mstop: usize,
pub nu: f64,
pub selected_learners: Vec<usize>,
pub gcv_path: Vec<f64>,
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub struct BoostFofrResult {
pub intercept: Vec<f64>,
pub fitted: FdMatrix,
pub residuals: FdMatrix,
pub r_squared_t: Vec<f64>,
pub r_squared: f64,
pub fpca_x: Vec<crate::regression::FpcaResult>,
pub score_coefs: Vec<FdMatrix>,
pub beta_surfaces: Vec<FdMatrix>,
pub selected_learners: Vec<usize>,
pub gcv_path: Vec<f64>,
pub mstop: usize,
pub nu: f64,
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub struct GamlssResult {
pub mu_fitted: FdMatrix,
pub sigma_fitted: FdMatrix,
pub mu_intercept: Vec<f64>,
pub sigma_intercept: Vec<f64>,
pub mu_beta: FdMatrix,
pub sigma_beta: FdMatrix,
pub log_likelihood: f64,
pub ll_path: Vec<f64>,
pub mstop: usize,
pub nu: f64,
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub struct BayesianFosrResult {
pub beta_mean: FdMatrix,
pub beta_lower: FdMatrix,
pub beta_upper: FdMatrix,
pub fitted: FdMatrix,
pub residuals: FdMatrix,
pub sigma2_mean: Vec<f64>,
pub n_iter: usize,
pub burn_in: usize,
pub thin: usize,
pub ncomp: usize,
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub struct StabilityResult {
pub selection_freq: Vec<f64>,
pub stable_set: Vec<usize>,
pub pi_thr: f64,
pub pfer_bound: f64,
pub n_resamples: usize,
}
pub use self::bayesian::bayesian_fosr;
pub use self::boost_fofr::boost_fofr;
pub use self::boost_fosr::boost_fosr;
pub use self::gamlss::gamlss_fosr;
pub use self::stability::stability_selection;
#[cfg(test)]
mod tests {
use super::{BayesianConfig, BoostingConfig, StabilityConfig};
#[test]
fn config_defaults_match_documented_values() {
assert_eq!(
BoostingConfig::default(),
BoostingConfig {
mstop: 100,
nu: 0.1,
nbasis: 10,
order: 4,
lfd_order: 2,
lambda: 1.0,
ncomp_x: 3,
seed: 0,
}
);
assert_eq!(
BayesianConfig::default(),
BayesianConfig {
ncomp: 4,
tau2: 100.0,
ig_a0: 0.001,
ig_b0: 0.001,
n_iter: 400,
burn_in: 200,
thin: 1,
seed: 0,
}
);
assert_eq!(
StabilityConfig::default(),
StabilityConfig {
n_resamples: 100,
pi_thr: 0.9,
seed: 0,
}
);
}
}