pmml (version 1.5.1)

pmml.kmeans: Generate PMML for kmeans objects

Description

Generate the PMML representation for a kmeans object (cluster) from package stats. The kmeans object (a cluster described by k centroids) is converted into a PMML representation.

Usage

"pmml"(model, model.name="KMeans_Model", app.name="Rattle/PMML", description="KMeans cluster model", copyright=NULL, transforms=NULL, unknownValue=NULL, algorithm.name="KMeans: Hartigan and Wong", ...)

Arguments

model
a kmeans object.
model.name
a name to be given to the model in the PMML code.
app.name
the name of the application that generated the PMML code.
description
a descriptive text for the Header element of the PMML code.
copyright
the copyright notice for the model.
transforms
data transformations represented in PMML via pmmlTransformations.
unknownValue
value to be used as the 'missingValueReplacement' attribute for all MiningFields.
algorithm.name
the variety of kmeans used.
...
further arguments passed to or from other methods.

Details

A kmeans object is obtained by applying the kmeans function from the stats package. This method typically requires the user to normalize all the variables, these operations can be done using the pmmlTransformations package so that the normalization information is included in the pmml model format.

References

R project: K-Means Clustering

Examples

Run this code
ds <- rbind(matrix(rnorm(100, sd = 0.3), ncol = 2),
                matrix(rnorm(100, mean = 1, sd = 0.3), ncol = 2))
colnames(ds) <- c("Dimension1", "Dimension2")
cl <- kmeans(ds, 2)
pmml(cl)

Run the code above in your browser using DataCamp Workspace