pub struct Dbscan<A, M> {
pub eps: A,
pub min_samples: usize,
pub metric: M,
}
Expand description
DBSCAN (density-based spatial clustering of applications with noise) clustering algorithm.
§Examples
use ndarray::array;
use petal_neighbors::distance::Euclidean;
use petal_clustering::{Dbscan, Fit};
let points = array![[1., 2.], [2., 2.], [2., 2.3], [8., 7.], [8., 8.], [25., 80.]];
let clustering = Dbscan::new(3., 2, Euclidean::default()).fit(&points, None);
assert_eq!(clustering.0.len(), 2); // two clusters found
assert_eq!(clustering.0[&0], [0, 1, 2]); // the first three points in Cluster 0
assert_eq!(clustering.0[&1], [3, 4]); // [8., 7.] and [8., 8.] in Cluster 1
assert_eq!(clustering.1, [5]); // [25., 80.] doesn't belong to any cluster
Fields§
§eps: A
The radius of a neighborhood.
min_samples: usize
The minimum number of points required to form a dense region.
metric: M
Implementations§
Trait Implementations§
Source§impl<'de, A, M> Deserialize<'de> for Dbscan<A, M>where
A: Deserialize<'de>,
M: Deserialize<'de>,
impl<'de, A, M> Deserialize<'de> for Dbscan<A, M>where
A: Deserialize<'de>,
M: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<S, A, M> Fit<ArrayBase<S, Dim<[usize; 2]>>, HashMap<usize, Vec<usize>>, (HashMap<usize, Vec<usize>>, Vec<usize>)> for Dbscan<A, M>
Fits the DBSCAN clustering algorithm to the given input data.
impl<S, A, M> Fit<ArrayBase<S, Dim<[usize; 2]>>, HashMap<usize, Vec<usize>>, (HashMap<usize, Vec<usize>>, Vec<usize>)> for Dbscan<A, M>
Fits the DBSCAN clustering algorithm to the given input data.
§Parameters
input
: A 2D array representing the dataset to cluster. Each row corresponds to a data point._params
: An optional parameter for prelabelled data. Not used in this implementation, but required for consistency.
§Returns
A tuple containing:
HashMap<usize, Vec<usize>>
: A mapping of cluster IDs to the indices of points in each cluster.Vec<usize>
: A vector of indices representing the noise points that do not belong to any cluster.
Auto Trait Implementations§
impl<A, M> Freeze for Dbscan<A, M>
impl<A, M> RefUnwindSafe for Dbscan<A, M>where
A: RefUnwindSafe,
M: RefUnwindSafe,
impl<A, M> Send for Dbscan<A, M>
impl<A, M> Sync for Dbscan<A, M>
impl<A, M> Unpin for Dbscan<A, M>
impl<A, M> UnwindSafe for Dbscan<A, M>where
A: UnwindSafe,
M: UnwindSafe,
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> 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