# NOT RUN {
set.seed(0)
stream <- DSD_Gaussians(k = 3, noise = 0.05)
# create clusterer with r = 0.05
dbstream <- DSC_DBSTREAM(r = .05)
update(dbstream, stream, 1000)
dbstream
# check micro-clusters
nclusters(dbstream)
head(get_centers(dbstream))
plot(dbstream, stream)
# plot macro-clusters
plot(dbstream, stream, type = "both")
# plot micro-clusters with assignment area
plot(dbstream, stream, type = "both", assignment = TRUE)
# DBSTREAM with shared density
dbstream <- DSC_DBSTREAM(r = .05, shared_density = TRUE, Cm=5)
update(dbstream, stream, 1000)
dbstream
plot(dbstream, stream, type = "both")
# plot the shared density graph (several options)
plot(dbstream, stream, type = "both", shared_density = TRUE)
plot(dbstream, stream, type = "micro", shared_density = TRUE)
plot(dbstream, stream, type = "micro", shared_density = TRUE, assignment = TRUE)
plot(dbstream, stream, type = "none", shared_density = TRUE, assignment = TRUE)
# see how micro and macro-clusters relate
# each microcluster has an entry with the macro-cluster id
# Note: unassigned micro-clusters (noise) have an NA
microToMacro(dbstream)
# do some evaluation
evaluate(dbstream, stream, measure="purity")
evaluate(dbstream, stream, measure="cRand", type="macro")
# use DBSTREAM for conventional clustering (with assignments = TRUE so we can
# later retrieve the cluster assignments for each point)
data("iris")
dbstream <- DSC_DBSTREAM(r = 1)
update(dbstream, iris[,-5], assignments = TRUE)
dbstream
cl <- get_cluster_assignments(dbstream)
cl
# micro-clusters
plot(iris[,-5], col = cl, pch = cl)
# macro-clusters
plot(iris[,-5], col = microToMacro(dbstream, cl))
# }
Run the code above in your browser using DataLab