View source: R/DSAggregate_Window.R
DSAggregate_Window | R Documentation |
Implements a sliding window data stream operator which keeps a fixed amount (window length) of the most recent data points of the stream.
DSAggregate_Window(horizon = 100, lambda = 0)
horizon |
the window length. |
lambda |
decay factor damped window model. |
If lambda
is greater than 0 then the weight uses a damped window
model (Zhu and Shasha, 2002). The weight for points in the window follows
2^(-lambda*t)
where t
is the age of the point.
An object of class DSAggregate_Window
(subclass of DSAggregate).
Michael Hahsler
Zhu, Y. and Shasha, D. (2002). StatStream: Statistical Monitoring of Thousands of Data Streams in Real Time, Intl. Conference of Very Large Data Bases (VLDB'02).
Other DSAggregate:
DSAggregate()
,
DSAggregate_Sample()
set.seed(1500)
## Example 1: Basic use
stream <- DSD_Gaussians(k = 3, d = 2, noise = 0.05)
window <- DSAggregate_Window(horizon = 10)
window
# update with only two points. The window is mostly empty (NA)
update(window, stream, 2)
get_points(window)
# get weights and window as a single data.frame
get_model(window)
# update window
update(window, stream, 100)
get_points(window)
## Example 2: Implement a classifier over a sliding window
window <- DSAggregate_Window(horizon = 100)
update(window, stream, 1000)
# train the classifier on the window
library(rpart)
tree <- rpart(`.class` ~ ., data = get_points(window))
tree
# predict the class for new points from the stream
new_points <- get_points(stream, n = 100, info = FALSE)
pred <- predict(tree, new_points)
plot(new_points, col = pred)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.