#[non_exhaustive]pub struct AlignClusterConfig {
pub k: usize,
pub max_iter: usize,
pub seed: u64,
pub use_amplitude_only: bool,
pub elastic_lambda: f64,
pub karcher_max_iter: usize,
pub karcher_tol: f64,
}Expand description
Configuration for joint align-and-cluster (elastic k-means).
Alternates between updating per-cluster template curves (via Karcher mean in the elastic metric) and reassigning each curve to the nearest template by elastic distance. This is the only clusterer in this module that is shape-invariant — it finds clusters based on amplitude shape, not phase.
Reference: Inspired by Sangalli et al. (2010) joint clustering and alignment
and the fdasrvf elastic k-means variant (Srivastava et al.).
§Example
use fdars_core::clustering_advanced::{align_cluster_fd, AlignClusterConfig};
use fdars_core::matrix::FdMatrix;
use std::f64::consts::PI;
let m = 25;
let n = 10;
let t: Vec<f64> = (0..m).map(|i| i as f64 / (m - 1) as f64).collect();
let mut col_major = vec![0.0_f64; n * m];
for i in 0..5 {
for (j, &tj) in t.iter().enumerate() {
col_major[i + j * n] = (2.0 * PI * tj).sin();
}
}
for i in 5..10 {
for (j, &tj) in t.iter().enumerate() {
col_major[i + j * n] = (2.0 * PI * tj).sin() + 5.0;
}
}
let data = FdMatrix::from_column_major(col_major, n, m).unwrap();
let mut cfg = AlignClusterConfig::default();
cfg.k = 2;
cfg.max_iter = 10;
cfg.karcher_max_iter = 8;
let result = align_cluster_fd(&data, &t, &cfg).unwrap();
assert_eq!(result.cluster.len(), n);
assert_eq!(result.templates.len(), 2);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.k: usizeNumber of clusters (default: 2). Must be ≥ 1 and ≤ n.
max_iter: usizeMaximum number of outer iterations (default: 20).
seed: u64Random seed for initial template selection (default: 42).
use_amplitude_only: boolIf true, use amplitude_distance (shape-invariant); otherwise use
elastic_distance (full Fisher-Rao distance including phase). Default: true.
elastic_lambda: f64Penalty weight for elastic_distance when use_amplitude_only = false (default: 0.0).
karcher_max_iter: usizeMaximum inner iterations for Karcher mean (default: 15).
karcher_tol: f64Convergence tolerance for Karcher mean (default: 1e-4).
Trait Implementations§
Source§impl Clone for AlignClusterConfig
impl Clone for AlignClusterConfig
Source§fn clone(&self) -> AlignClusterConfig
fn clone(&self) -> AlignClusterConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AlignClusterConfig
impl Debug for AlignClusterConfig
Source§impl Default for AlignClusterConfig
impl Default for AlignClusterConfig
Source§impl PartialEq for AlignClusterConfig
impl PartialEq for AlignClusterConfig
impl StructuralPartialEq for AlignClusterConfig
Auto Trait Implementations§
impl Freeze for AlignClusterConfig
impl RefUnwindSafe for AlignClusterConfig
impl Send for AlignClusterConfig
impl Sync for AlignClusterConfig
impl Unpin for AlignClusterConfig
impl UnsafeUnpin for AlignClusterConfig
impl UnwindSafe for AlignClusterConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.