Refactor KMeans module to use inbuilt random

This commit is contained in:
Palash Tyagi 2025-07-28 20:23:59 +01:00
parent 5a5baf9716
commit 252c8a3d29

View File

@ -1,7 +1,6 @@
use crate::compute::stats::mean_vertical;
use crate::matrix::Matrix;
use rand::rng;
use rand::seq::SliceRandom;
use crate::random::prelude::*;
pub struct KMeans {
pub centroids: Matrix<f64>, // (k, n_features)
@ -193,7 +192,11 @@ mod tests {
break;
}
}
assert!(matches_data_point, "Centroid {} (empty cluster) does not match any data point", c);
assert!(
matches_data_point,
"Centroid {} (empty cluster) does not match any data point",
c
);
}
}
break;
@ -360,5 +363,4 @@ mod tests {
assert_eq!(predicted_label.len(), 1);
assert!(predicted_label[0] < k);
}
}