Bundle Core machine learning types: the seedable Random generator, Matrix2D linear algebra and activations, matrix reference holders, the NeuralNetwork and CSV-backed MatrixReader. Compile with -lib ml.
DBSCAN
Density-based spatial clustering (DBSCAN). Groups points that are densely packed (at least min_points neighbors within eps, Euclidean) and labels sparse points as noise (-1). Unlike KMeans the cluster count is discovered, clusters may be any shape, and the result is deterministic for a given input order.
Example
scanner := DBSCAN->New(1.0, 3);
scanner->Fit(X);
labels := scanner->GetLabels(); # cluster id per row; -1 = noiseOperations
Fit #
Clusters the data. Region growing visits rows in order, so results are deterministic for a given input.
method : public : Fit(X:Float[,]) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| X | Float | data matrix (rows=samples, cols=features) |
Return
| Type | Description |
|---|---|
| Bool | true if clustering succeeded |
GetLabels #
Gets the per-row cluster labels (-1 = noise).
method : public : GetLabels() ~ Int[]Return
| Type | Description |
|---|---|
| Int | label array, or Nil if not fitted |
GetNumClusters #
Gets the number of clusters discovered.
method : public : GetNumClusters() ~ IntReturn
| Type | Description |
|---|---|
| Int | cluster count |