Similar to other predict methods, this function predicts fitted values from a fitted "DBSCAN" object.

# S3 method for DBSCAN
predict(model, data, key, features = NULL, ...)

Format

S3 methods

Arguments

model

R6Class object
A "DBSCAN" object for prediction.

data

DataFrame
DataFrame containting the data.

key

character
Name of the ID column.

features

character of list of characters, optional
Name of feature columns for prediction.
If not provided, it defaults to all non-key columns of data.

...

Reserved parameter.

Value

Predicted values are returned as a DataFrame, structured as follows.

  • ID column, with same name and type as data's ID column.

  • Cluster_ID, type INTEGER, the assigned cluster ID.

  • DISTANCE, type DOUBLE, Distance between a given point and the nearest core object .

Examples

Perform the predict on DataFrame data2 using "DBSCAN" object dbscan:


> data2$Collect()
   ID  V000  V001  V002
1   1  0.10  0.10     B
2   2  0.11  0.10     A
3   3  0.10  0.11     C
4   4  0.11  0.11     B
5   5  0.12  0.11     A
......
28 28 16.11 16.11     A
29 29 20.11 20.12     C
30 30 15.12 15.11     A
> fitted <- predict(model = dbscan, data = data2)

Output:


> fitted$Collect()
    ID   CLUSTER_ID  DISTANCE
1   1             0     0.000
2   2             0     0.000
3   3             0     0.000
4   4             0     0.000
5   5             0     0.000
......
28 28            -1    11.950
29 29            -1    21.374
30 30            -1     9.960

See also