feat: + builders for algorithm parameters
This commit is contained in:
+20
-2
@@ -53,14 +53,32 @@ pub struct DBSCAN<T: RealNumber, D: Distance<Vec<T>, T>> {
|
||||
#[derive(Debug, Clone)]
|
||||
/// DBSCAN clustering algorithm parameters
|
||||
pub struct DBSCANParameters<T: RealNumber> {
|
||||
/// Maximum number of iterations of the k-means algorithm for a single run.
|
||||
/// The number of samples (or total weight) in a neighborhood for a point to be considered as a core point.
|
||||
pub min_samples: usize,
|
||||
/// The number of samples in a neighborhood for a point to be considered as a core point.
|
||||
/// The maximum distance between two samples for one to be considered as in the neighborhood of the other.
|
||||
pub eps: T,
|
||||
/// KNN algorithm to use.
|
||||
pub algorithm: KNNAlgorithmName,
|
||||
}
|
||||
|
||||
impl<T: RealNumber> DBSCANParameters<T> {
|
||||
/// The number of samples (or total weight) in a neighborhood for a point to be considered as a core point.
|
||||
pub fn with_min_samples(mut self, min_samples: usize) -> Self {
|
||||
self.min_samples = min_samples;
|
||||
self
|
||||
}
|
||||
/// The maximum distance between two samples for one to be considered as in the neighborhood of the other.
|
||||
pub fn with_eps(mut self, eps: T) -> Self {
|
||||
self.eps = eps;
|
||||
self
|
||||
}
|
||||
/// KNN algorithm to use.
|
||||
pub fn with_algorithm(mut self, algorithm: KNNAlgorithmName) -> Self {
|
||||
self.algorithm = algorithm;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: RealNumber, D: Distance<Vec<T>, T>> PartialEq for DBSCAN<T, D> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.cluster_labels.len() == other.cluster_labels.len()
|
||||
|
||||
Reference in New Issue
Block a user