#[non_exhaustive]pub struct KernelKmeansResult {
pub cluster: Vec<usize>,
pub inertia: f64,
pub iter: usize,
pub converged: bool,
pub n_init_best: usize,
/* private fields */
}Expand description
Result of kernel_kmeans_fd.
Carries the cluster assignments and fit diagnostics plus the internal state
KernelKmeansResult::predict needs (the fitted GakGramTrain, the per-cluster
within-cluster kernel sums, and the cluster sizes). There is no centroid /
centers field: kernel k-means has no explicit centroid curve.
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.cluster: Vec<usize>Cluster assignment for each training curve (values in 0..n_clusters).
inertia: f64Total feature-space inertia Σ_i d²(i, cluster[i]) of the returned run.
iter: usizeNumber of Lloyd iterations the winning restart ran.
converged: boolWhether the winning restart converged before hitting max_iter.
n_init_best: usizeIndex of the restart (0-based) that produced this result.
Implementations§
Source§impl KernelKmeansResult
impl KernelKmeansResult
Sourcepub fn n_clusters(&self) -> usize
pub fn n_clusters(&self) -> usize
The number of clusters (k).
Sourcepub fn predict(&self, new_data: &FdMatrix) -> Result<Vec<usize>, FdarError>
pub fn predict(&self, new_data: &FdMatrix) -> Result<Vec<usize>, FdarError>
Assign new (out-of-sample) curves to the fitted clusters.
Builds the normalized cross-Gram Kcross = gak_gram_predict(train, new_data)
(n_test × n_train) and assigns each new curve t to the cluster minimizing
d²(t, k) = 1 − (2/|C_k|)·Σ_{j∈C_k} Kcross[t,j] + within_kwhere 1 = k(test,test) (normalized GAK), and within_k, |C_k| are the
fitted training quantities. The same σ and normalization as the fit are
reused (via gak_gram_predict) — nothing is re-estimated on the test set.
§Errors
Propagates gak_gram_predict errors: FdarError::InvalidDimension if
new_data is empty or its evaluation-grid width differs from the training
set’s, or FdarError::InvalidParameter if the stored σ is invalid.
Trait Implementations§
Source§impl Clone for KernelKmeansResult
impl Clone for KernelKmeansResult
Source§fn clone(&self) -> KernelKmeansResult
fn clone(&self) -> KernelKmeansResult
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 KernelKmeansResult
impl Debug for KernelKmeansResult
Source§impl PartialEq for KernelKmeansResult
impl PartialEq for KernelKmeansResult
impl StructuralPartialEq for KernelKmeansResult
Auto Trait Implementations§
impl Freeze for KernelKmeansResult
impl RefUnwindSafe for KernelKmeansResult
impl Send for KernelKmeansResult
impl Sync for KernelKmeansResult
impl Unpin for KernelKmeansResult
impl UnsafeUnpin for KernelKmeansResult
impl UnwindSafe for KernelKmeansResult
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.