v2026.11.2
All Bundles
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.

DbscanDetector

DBSCAN as an outlier detector, so its eps can be swept like any other detector's setting. The outliers are exactly DBSCAN's noise: rows that are not core (fewer than min_points rows, itself included, within eps) and have no core row within eps. The existing DBSCAN class gives the same noise; this adds a score and the OutlierDetector interface.

The score is the distance to the nearest core training row (0 for a core row), the threshold is eps, and Predict applies the same rule to new rows. With no core rows at all every score is +Inf. Distances are computed by brute force, O(n^2). Changing eps changes the model, so SetSensitivity unfits it.

Implements: OutlierDetector

Example

scan := DbscanDetector->New(1.0, 5);
noise := scan->FitPredict(X);

Operations

DecisionFunction #

Score minus eps; positive means outlier.

method : public : DecisionFunction(X:Float[,]) ~ Float[]

Parameters

NameTypeDescription
XFloatrows x features

Return

TypeDescription
Floatvalues, or Nil when unfitted or the input is refused

Fit #

Finds the core rows and scores the training rows.

method : public : Fit(X:Float[,]) ~ Bool

Parameters

NameTypeDescription
XFloatrows x features

Return

TypeDescription
Booltrue on success

FitPredict #

Fits, then labels the training rows: true for DBSCAN noise.

method : public : FitPredict(X:Float[,]) ~ Bool[]

Parameters

NameTypeDescription
XFloatrows x features

Return

TypeDescription
Boollabels (true = outlier), or Nil when the fit failed

GetCoreMask #

Which training rows are core rows.

method : public : GetCoreMask() ~ Bool[]

Return

TypeDescription
Boolmask, or Nil when unfitted

GetError #

Why the last call failed.

method : public : GetError() ~ String

Return

TypeDescription
Stringthe reason, or an empty string

GetSensitivity #

eps.

method : public : GetSensitivity() ~ Float

Return

TypeDescription
Floateps

GetSensitivityName #

The setting's name.

method : public : GetSensitivityName() ~ String

Return

TypeDescription
String"eps"

GetThreshold #

The threshold, which is eps.

method : public : GetThreshold() ~ Float

Return

TypeDescription
Floateps

GetTrainingScores #

The training rows' distances to the nearest core row.

method : public : GetTrainingScores() ~ Float[]

Return

TypeDescription
Floatscores, or Nil when unfitted

IsFitted #

Whether the detector is fitted.

method : public : IsFitted() ~ Bool

Return

TypeDescription
Booltrue when fitted

New # constructor

Constructor with scikit-learn's defaults: eps 0.5, min_points 5.

New()

New # constructor

Constructor.

New(eps:Float, min_points:Int)

Parameters

NameTypeDescription
epsFloatneighbourhood radius (Euclidean), > 0
min_pointsIntrows within eps, itself included, for a core row (sklearn's min_samples)

Predict #

Labels new rows: true where no core training row lies within eps.

method : public : Predict(X:Float[,]) ~ Bool[]

Parameters

NameTypeDescription
XFloatrows x features

Return

TypeDescription
Boollabels, or Nil when unfitted or the input is refused

Score #

Distance from each row to the nearest core training row.

method : public : Score(X:Float[,]) ~ Float[]

Parameters

NameTypeDescription
XFloatrows x features

Return

TypeDescription
Floatdistances, or Nil when unfitted or the input is refused

SetSensitivity #

Sets eps; the detector becomes unfitted, since the core rows change.

method : public : SetSensitivity(value:Float) ~ Bool

Parameters

NameTypeDescription
valueFloateps (> 0)

Return

TypeDescription
Boolfalse when value <= 0