predict.Kmeans {hana.ml.r}R Documentation

Make Predictions from a "Kmeans" Object

Description

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

Usage

## S3 method for class 'Kmeans'
predict(model, data, key, features = NULL, ...)

Arguments

model

R6Class object
A 'Kmeans' object for prediction.

data

DataFrame
data for prediction.

key

character
Name of the ID column.

features

character or list of characters, optional
Names of the feature columns.
If not provided, it defaults to all non-ID columns.

Value

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

See Also

hanaml.Kmeans

Examples

## 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)

[Package hana.ml.r version 1.0.8 Index]