Learn R Programming

stream (version 1.5-1)

animate: Animates the plotting of a DSD and the clustering process

Description

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.

Usage

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 = 0.1,
  plot.args = NULL,
  ...
)

animate_data(dsd, horizon = 100, n = 1000, wait = 0.1, plot.args = NULL, ...)

Arguments

dsc

a DSC object

dsd

a DSD object

measure

the evaluation measure that should be graphed below the animation

horizon

the number of points displayed at once/used for evaluation.

n

the number of points to be plotted

type

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

assign new points to the closest "micro" or "macro"-cluster to calculate the evaluation measure.

assignmentMethod

how to assign data points to micro-clusters. Options are "model" and "nn" (nearest neighbor). "auto" uses model if available and nn otherwise.

noise

how to handle noise for calculating the evaluation measure (as a separate class or excluded).

wait

the time interval between each frame

plot.args

a list with plotting parameters for the clusters.

...

extra arguments are added to plot.args.

Author

Michael Hahsler

Details

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).

See Also

evaluate_cluster for stream evaluation without animation. See ani.replay for replaying and saving animations.

Examples

Run this code

if (FALSE) {
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