#[non_exhaustive]pub struct KShapeResult {
pub centroids: FdMatrix,
pub cluster: Vec<usize>,
pub inertia: f64,
pub iter: usize,
pub converged: bool,
pub n_init_best: usize,
}Expand description
Result of kshape_fd.
Carries the fitted centroids (k × m, already z-normalized) plus cluster
assignments and fit diagnostics. KShapeResult::predict reuses the stored
centroids directly — nothing is re-estimated on new data.
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.centroids: FdMatrixCluster centroids as a k × m FdMatrix (each row a z-normalized shape prototype).
cluster: Vec<usize>Cluster assignment for each training series (values in 0..n_clusters).
inertia: f64Total SBD inertia Σ_i SBD(series_i, centroid[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 KShapeResult
impl KShapeResult
Sourcepub fn centroids(&self) -> &FdMatrix
pub fn centroids(&self) -> &FdMatrix
The fitted centroids (k × m, each row a z-normalized shape prototype).
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) series to the fitted clusters.
Each new series is z-normalized and compared by sbd against every
stored (already-z-normalized) centroid; the argmin cluster is returned.
The centroids are used as-is, so predict(train_data) reproduces the
training labels.
§Errors
Returns FdarError::InvalidDimension if new_data is empty or its
evaluation-grid width differs from the fitted centroids’ length m.
Trait Implementations§
Source§impl Clone for KShapeResult
impl Clone for KShapeResult
Source§fn clone(&self) -> KShapeResult
fn clone(&self) -> KShapeResult
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 KShapeResult
impl Debug for KShapeResult
Source§impl PartialEq for KShapeResult
impl PartialEq for KShapeResult
impl StructuralPartialEq for KShapeResult
Auto Trait Implementations§
impl Freeze for KShapeResult
impl RefUnwindSafe for KShapeResult
impl Send for KShapeResult
impl Sync for KShapeResult
impl Unpin for KShapeResult
impl UnsafeUnpin for KShapeResult
impl UnwindSafe for KShapeResult
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.