pmml.hclust {pmml} | R Documentation |
Generate the PMML representation for a hierarchical cluster object. The hclust object will be approximated by k centroids and is converted into a PMML representation for kmeans clusters.
## S3 method for class 'hclust' pmml(model, model.name="HClust_Model", app.name="Rattle/PMML", description="Hierarchical cluster model", copyright=NULL, transforms=NULL, unknownValue=NULL, centers, ...)
model |
a hclust 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 package pmmlTransformations. |
unknownValue |
value to be used as the 'missingValueReplacement' attribute for all MiningFields. |
centers |
a list of means to represent the clusters. |
... |
further arguments passed to or from other methods. |
This function converts a hclust object created by the 'hclusterpar' function from the 'amap' package. A hclust object is a cluster model created hierarchically. The data is divided recursively until a criteria is met. This function then takes the final model and represents it as a standard k-means cluster model. This is possible since while the method of constructing the model is different, the final model can be represented in the same way.
To use this pmml function, therefore, one must pick the number of clusters desired and the coordinate values at those cluster centers. This can be done using the 'hclusterpar' and 'centers.hclust' functions from the 'amap' and 'rattle' packages repectively.
R project: Hierarchical Clustering
http://stat.ethz.ch/R-manual/R-devel/library/stats/html/hclust.html
#\dontrun{ # cluster the 4 numeric variables of the iris dataset library(amap) model <- hclusterpar(iris[,-5]) # get the information about the cluster centers # the last parameter of the function used is the number of clusters desired library(rattle) centerInfo <- centers.hclust(iris[,-5],model,3) # convert to pmml library(pmml) pmml(model,centers=centerInfo) #}