DSClassifier_SlidingWindow {stream} | R Documentation |
DSClassifier_SlidingWindow – Data Stream Classifier Using a Sliding Window
Description
The classifier keeps a sliding window for the stream and rebuilds a classification model at regular
intervals. By default is builds a decision tree using rpart()
.
Usage
DSClassifier_SlidingWindow(formula, model = rpart::rpart, window, rebuild, ...)
Arguments
formula |
a formula for the classification problem. |
model |
classifier model (that has a formula interface). |
window |
size of the sliding window. |
rebuild |
interval (number of points) for rebuilding the classifier. Set rebuild to
|
... |
additional parameters are passed on to the classifier (default is |
Details
This constructor creates classifier based on DST_SlidingWindow
. The classifier has
a update()
and predict()
method.
Value
An object of class DST_SlidingWindow
.
Author(s)
Michael Hahsler
See Also
Other DSClassifier:
DSClassifier()
Examples
library(stream)
# create a data stream for the iris dataset
data <- iris[sample(nrow(iris)), ]
stream <- DSD_Memory(data)
# define the stream classifier.
cl <- DSClassifier_SlidingWindow(
Species ~ Sepal.Length + Sepal.Width + Petal.Length,
window = 50,
rebuild = 10
)
cl
# update the classifier with 100 points from the stream
update(cl, stream, 100)
# predict the class for the next 50 points
newdata <- get_points(stream, n = 50)
pr <- predict(cl, newdata, type = "class")
pr
table(pr, newdata$Species)
# get the tree model
get_model(cl)
[Package stream version 2.0-2 Index]