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);

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§

source§

impl<A, M> Dbscan<A, M>

source

pub fn new(eps: A, min_samples: usize, metric: M) -> Self

Trait Implementations§

source§

impl<A: Debug, M: Debug> Debug for Dbscan<A, M>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<A> Default for Dbscan<A, Euclidean>
where A: FloatCore,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

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>,

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>>, Vec<usize>)> for Dbscan<A, M>
where A: AddAssign + DivAssign + FloatCore + FromPrimitive + Sync, S: Data<Elem = A>, M: Metric<A> + Clone + Sync,

source§

fn fit( &mut self, input: &ArrayBase<S, Ix2> ) -> (HashMap<usize, Vec<usize>>, Vec<usize>)

source§

impl<A, M> Serialize for Dbscan<A, M>
where A: Serialize, M: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<A, M> RefUnwindSafe for Dbscan<A, M>

§

impl<A, M> Send for Dbscan<A, M>
where A: Send, M: Send,

§

impl<A, M> Sync for Dbscan<A, M>
where A: Sync, M: Sync,

§

impl<A, M> Unpin for Dbscan<A, M>
where A: Unpin, M: Unpin,

§

impl<A, M> UnwindSafe for Dbscan<A, M>
where A: UnwindSafe, M: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,