Learn R Programming

stream (version 0.1-1)

microToMacro: Translate Micro-cluster IDs to Macro-cluster IDs

Description

Translates micro-cluster ids into macro-cluster ids for a DSC_Macro object.

Usage

microToMacro(x, micro=NULL)

Arguments

x
a DSC_Macro object that also contains information about micro-clusters.
micro
A vector with micro-cluster ids. If NULL then the assignments for all micro-clusters in x are returned.

Value

  • A vector of the same length as micro with the macro-cluster ids.

See Also

DSC_Macro

Examples

Run this code
# 3 clusters with 5% noise
dsd <- DSD_GaussianStatic(k=3, noise=0.05)

# recluster a micro-clusters
micro <- DSC_CluStream()
cluster(micro, dsd, 500)

macro <- DSC_Kmeans(k=3)
recluster(macro, micro)

# translate all micro-cluster ids
ids <- 1:nclusters(macro, type="micro")
microToMacro(macro, ids)

# plot some data points in grey
plot(dsd, col="grey", cex=.5)
# add micro-clusters and use the macro-cluster ids as color
points(get_centers(macro, type="micro"), col=microToMacro(macro, ids))
# add macro-cluster centers
points(get_centers(macro, type="macro"), pch=3, cex=4, ,lwd=2, col=1:3)

Run the code above in your browser using DataLab