Generates an animation of a data stream or a data steam clustering.
Note: You need to install package animation
, and, if necessary, the
libraries required for package magick
.
animate_data(dsd, horizon = 100, n = 1000, wait = .1, plot.args = NULL, ...)
animate_cluster(dsc, dsd, measure = NULL, horizon = 100, n = 1000,
type=c("auto", "micro", "macro"), assign="micro",
assignmentMethod=c("auto","model", "nn"),
noise = c("class", "exclude"),
wait=.1, plot.args = NULL, ...)
a DSD object
a DSC object
the number of points displayed at once/used for evaluation.
the number of points to be plotted
the evaluation measure that should be graphed below the animation
evaluate "micro"
or "macro"
-clusters? "auto"
chooses micro if dsc
is of class DSC_micro
and no macro
is given. Otherwise macro is used.
assign new points to the closest "micro"
or
"macro"
-cluster to calculate the evaluation measure.
how to assign data points to micro-clusters. Options are
"model"
and "nn"
(nearest neighbor). "auto"
uses model if
available and nn otherwise.
how to handle noise for calculating the evaluation measure (as a separate class or excluded).
the time interval between each frame
a list with plotting parameters for the clusters.
extra arguments are added to plot.args
.
Animations are recorded using the library animation and can be replayed (which gives a smoother experience since the is no more computation done) and saved in various formats (see Examples section below).
evaluate_cluster
for stream evaluation without animation.
See ani.replay
for replaying and saving animations.
# NOT RUN {
stream <- DSD_Benchmark(1)
animate_data(stream, horizon=100, n=5000, xlim=c(0,1), ylim=c(0,1))
### animations can be replayed with the animation package
library(animation)
animation::ani.options(interval=.1) ## change speed
ani.replay()
### animations can also be saved as HTML, animated gifs, etc.
saveHTML(ani.replay())
### animate the clustering process with evaluation
### Note: we choose to exclude noise points from the evaluation
### measure calculation, even if the algorithm would assign
### them to a cluster.
reset_stream(stream)
dbstream <- DSC_DBSTREAM(r=.04, lambda=.1, gaptime=100, Cm=3,
shared_density=TRUE, alpha=.2)
animate_cluster(dbstream, stream, horizon=100, n=5000,
measure="crand", type="macro", assign="micro", noise = "exclude",
plot.args = list(xlim=c(0,1), ylim=c(0,1), shared = TRUE))
# }
Run the code above in your browser using DataLab