mirror of
https://github.com/Magnus167/rustframe.git
synced 2025-08-20 04:00:01 +00:00
Refactor KMeans module to use inbuilt random
This commit is contained in:
parent
5a5baf9716
commit
252c8a3d29
@ -1,7 +1,6 @@
|
|||||||
use crate::compute::stats::mean_vertical;
|
use crate::compute::stats::mean_vertical;
|
||||||
use crate::matrix::Matrix;
|
use crate::matrix::Matrix;
|
||||||
use rand::rng;
|
use crate::random::prelude::*;
|
||||||
use rand::seq::SliceRandom;
|
|
||||||
|
|
||||||
pub struct KMeans {
|
pub struct KMeans {
|
||||||
pub centroids: Matrix<f64>, // (k, n_features)
|
pub centroids: Matrix<f64>, // (k, n_features)
|
||||||
@ -193,7 +192,11 @@ mod tests {
|
|||||||
break;
|
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;
|
break;
|
||||||
@ -360,5 +363,4 @@ mod tests {
|
|||||||
assert_eq!(predicted_label.len(), 1);
|
assert_eq!(predicted_label.len(), 1);
|
||||||
assert!(predicted_label[0] < k);
|
assert!(predicted_label[0] < k);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user