Module rusty_machine::learning::dbscan
source · [−]Expand description
DBSCAN Clustering
Note: This module is likely to change dramatically in the future and should be treated as experimental.
Provides an implementaton of DBSCAN clustering. The model
also implements a predict
function which uses nearest neighbours
to classify the points. To utilize this function you must use
self.set_predictive(true)
before training the model.
The algorithm works by specifying eps
and min_points
parameters.
The eps
parameter controls how close together points must be to be
placed in the same cluster. The min_points
parameter controls how many
points must be within distance eps
of eachother to be considered a cluster.
If a point is not within distance eps
of a cluster it will be classified
as noise. This means that it will be set to None
in the clusters Vector
.
Examples
use rusty_machine::learning::dbscan::DBSCAN;
use rusty_machine::learning::UnSupModel;
use rusty_machine::linalg::Matrix;
let inputs = Matrix::new(6, 2, vec![1.0, 2.0,
1.1, 2.2,
0.9, 1.9,
1.0, 2.1,
-2.0, 3.0,
-2.2, 3.1]);
let mut model = DBSCAN::new(0.5, 2);
model.train(&inputs).unwrap();
let clustering = model.clusters().unwrap();