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)
Run the code above in your browser using DataLab