Similar to other transform methods, this function transforms values from a fitted "Kmeans" object.

# S3 method for Discretize
transform(model, data, key, features = NULL)

Arguments

model

R6Class object
A "Discretize" Object.

data

DataFrame
DataFrame containting the data.

key

character
Name of the ID column.

features

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

Value

Transformed 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.

Examples

Perform the transformation on DataFrame data2 using "Discretize" object discretize:


> discretize.df.apply$Collect()
  ID ATT1 ATT2 ATT3 ATT4
1  1 20.0  120    1    A
2  2 30.0  101    1    A
3  3 10.7  143    1    B
4  4 15.8  256    1    C
5  5 88.9  100    1    A
6  6 76.5  402    4    A
7  7 55.3  905    4    B

Call the function:


> result <- transform(discretize, discretize.df.apply, key = "ID",
                     features = list("ATT1", "ATT2", "ATT3", "ATT4"))

Output:


> result[[1]]$Collect()
   ID ATT1  ATT2 ATT3 ATT4
1  1 10.2 100.8    1    A
2  2 10.2 100.8    1    A
3  3 10.2 100.8    1    B
4  4 10.2 100.8    1    C
5  5 90.2 900.8    1    A
6  6 90.2 900.8    4    A
7  7 40.2 400.8    4    B