#[non_exhaustive]pub struct AgglomerativeClustering { /* private fields */ }Expand description
Agglomerative (hierarchical) clustering.
Starts with each sample as its own cluster and iteratively merges the
closest pair until n_clusters remain. Supports four linkage criteria.
§Example
use scry_learn::cluster::AgglomerativeClustering;
use scry_learn::dataset::Dataset;
let data = Dataset::new(
vec![vec![0.0, 0.0, 10.0, 10.0], vec![0.0, 0.0, 10.0, 10.0]],
vec![0.0; 4],
vec!["x".into(), "y".into()],
"label",
);
let mut model = AgglomerativeClustering::new(2);
model.fit(&data).unwrap();
assert_eq!(model.labels().len(), 4);Implementations§
Source§impl AgglomerativeClustering
impl AgglomerativeClustering
Sourcepub fn fit(&mut self, data: &Dataset) -> Result<()>
pub fn fit(&mut self, data: &Dataset) -> Result<()>
Fit the model on a dataset.
Uses the features and ignores the target column. Computes the full O(n²) pairwise distance matrix, then greedily merges the closest cluster pair using a priority queue.
Sourcepub fn n_clusters(&self) -> usize
pub fn n_clusters(&self) -> usize
Number of clusters.
Trait Implementations§
Source§impl Clone for AgglomerativeClustering
impl Clone for AgglomerativeClustering
Source§fn clone(&self) -> AgglomerativeClustering
fn clone(&self) -> AgglomerativeClustering
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AgglomerativeClustering
impl RefUnwindSafe for AgglomerativeClustering
impl Send for AgglomerativeClustering
impl Sync for AgglomerativeClustering
impl Unpin for AgglomerativeClustering
impl UnsafeUnpin for AgglomerativeClustering
impl UnwindSafe for AgglomerativeClustering
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 more