predict.Kmeans {hana.ml.r} | R Documentation |
Similar to other predict methods, this function predicts fitted values from a fitted "Kmeans" object.
## S3 method for class 'Kmeans' predict(model, data, key, features = NULL, ...)
model |
|
data |
|
key |
|
features |
|
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 cluster center.
## Not run: Perform the predict on DataFrame data2 using "Kmeans" object km: > data2$Collect() ID V000 V001 V002 1 0 0.5 A 0.5 2 1 1.5 A 0.5 3 2 1.5 A 1.5 4 3 0.5 A 1.5 5 4 1.1 B 1.2 ... 19 18 15.5 D 1.5 20 19 15.7 A 1.6 > fitted <- predict(model = km, data = data2, key = 'ID') > fitted$Collect() ID CLUSTER_ID DISTANCE 1 0 0 0.9496364 2 1 0 0.9224655 3 2 0 0.8648006 4 3 0 0.8942320 5 4 0 0.9787646 ...... 19 18 3 0.7813475 20 19 3 1.3365355 ## End(Not run)