hanaml.KMeans.Rdhanaml.KMeans is a R wrapper for SAP HANA PAL K-means and accelerated K-Means algorithm.
hanaml.KMeans( data = NULL, key = NULL, features = NULL, n.clusters = NULL, n.clusters.min = NULL, n.clusters.max = NULL, init = NULL, max.iter = NULL, tol = NULL, thread.ratio = NULL, distance.level = NULL, minkowski.power = NULL, category.weights = NULL, normalization = NULL, categorical.variable = NULL, memory.mode = NULL, accelerated = FALSE, use.fast.library = NULL, use.float = NULL )
| data |
|
|---|---|
| key |
|
| features |
|
| n.clusters |
|
| n.clusters.min |
|
| n.clusters.max |
|
| init |
|
| max.iter |
|
| tol |
|
| thread.ratio |
|
| distance.level |
Defaults to "euclidean". |
| minkowski.power |
|
| category.weights |
|
| normalization |
Defaults to "no". |
| categorical.variable |
VALID only for variables of "INTEGER" type, omitted otherwise. |
| memory.mode |
Only valid when accelerated is TRUE. Defaults to "auto". |
| accelerated |
|
| use.fast.library |
|
| use.float |
|
A "KMeans" object with the following attributes:
labels : DataFrame
Label assigned to each sample.
cluster.centers : DataFrame
Coordinates of cluster centers.
model : DataFrame
Model content.
statistics : DataFrame
Statistic value.
Input DataFrame data:
> data$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
6 5 0.5 B 15.5
7 6 1.5 B 15.5
8 7 1.5 B 16.5
9 8 0.5 B 16.5
10 9 1.2 C 16.1
11 10 15.5 C 15.5
12 11 16.5 C 15.5
13 12 16.5 C 16.5
14 13 15.5 C 16.5
15 14 15.6 D 16.2
16 15 15.5 D 0.5
17 16 16.5 D 0.5
18 17 16.5 D 1.5
19 18 15.5 D 1.5
20 19 15.7 A 1.6
Call the function:
> km <- hanaml.KMeans(data = data,
key = "ID",
features = NULL,
n.clusters = 4,
init = "first.k",
max.iter = 100,
tol = 1.0E-6,
thread.ratio = 0.2,
distance.level = "euclidean",
category.weights = 0.5)
Output:
> km$labels$Collect()
ID CLUSTER_ID DISTANCE SLIGHT_SILHOUETTE
1 0 0 0.891088 0.944370
2 1 0 0.863917 0.942478
3 2 0 0.806252 0.946288
4 3 0 0.835684 0.944942
5 4 0 0.744571 0.950234
6 5 3 0.891088 0.940733