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.
Example
scan := DbscanDetector->New(1.0, 5);
noise := scan->FitPredict(X);Operations
- New
- DecisionFunction
- Fit
- FitPredict
- GetCoreMask
- GetError
- GetSensitivity
- GetSensitivityName
- GetThreshold
- GetTrainingScores
- IsFitted
- Predict
- Score
- SetSensitivity
DecisionFunction #
Score minus eps; positive means outlier.
method : public : DecisionFunction(X:Float[,]) ~ Float[]Parameters
| Name | Type | Description |
|---|---|---|
| X | Float | rows x features |
Return
| Type | Description |
|---|---|
| Float | values, or Nil when unfitted or the input is refused |
Fit #
Finds the core rows and scores the training rows.
method : public : Fit(X:Float[,]) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| X | Float | rows x features |
Return
| Type | Description |
|---|---|
| Bool | true on success |
FitPredict #
Fits, then labels the training rows: true for DBSCAN noise.
method : public : FitPredict(X:Float[,]) ~ Bool[]Parameters
| Name | Type | Description |
|---|---|---|
| X | Float | rows x features |
Return
| Type | Description |
|---|---|
| Bool | labels (true = outlier), or Nil when the fit failed |
GetCoreMask #
Which training rows are core rows.
method : public : GetCoreMask() ~ Bool[]Return
| Type | Description |
|---|---|
| Bool | mask, or Nil when unfitted |
GetError #
Why the last call failed.
method : public : GetError() ~ StringReturn
| Type | Description |
|---|---|
| String | the reason, or an empty string |
GetSensitivityName #
The setting's name.
method : public : GetSensitivityName() ~ StringReturn
| Type | Description |
|---|---|
| String | "eps" |
GetThreshold #
The threshold, which is eps.
method : public : GetThreshold() ~ FloatReturn
| Type | Description |
|---|---|
| Float | eps |
GetTrainingScores #
The training rows' distances to the nearest core row.
method : public : GetTrainingScores() ~ Float[]Return
| Type | Description |
|---|---|
| Float | scores, or Nil when unfitted |
IsFitted #
Whether the detector is fitted.
method : public : IsFitted() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true when fitted |
New # constructor
Constructor.
New(eps:Float, min_points:Int)Parameters
| Name | Type | Description |
|---|---|---|
| eps | Float | neighbourhood radius (Euclidean), > 0 |
| min_points | Int | rows 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
| Name | Type | Description |
|---|---|---|
| X | Float | rows x features |
Return
| Type | Description |
|---|---|
| Bool | labels, or Nil when unfitted or the input is refused |