DSRegressor_SlidingWindow: DSRegressor_SlidingWindow - Data Stream Regressor Using a...

View source: R/DSRegressor_SlidingWindow.R

DSRegressor_SlidingWindowR Documentation

DSRegressor_SlidingWindow – Data Stream Regressor Using a Sliding Window

Description

The Regressor keeps a sliding window for the stream and rebuilds a regression model at regular intervals. By default is builds a decision tree using lm().

Usage

DSRegressor_SlidingWindow(formula, model = stats::lm, window, rebuild, ...)

Arguments

formula

a formula for the classification problem.

model

regression model (that has a formula interface).

window

size of the sliding window.

rebuild

interval (number of points) for rebuilding the regression. Set rebuild to Inf to prevent automatic rebuilding. Rebuilding can be initiated manually when calling update().

...

additional parameters are passed on to the regressor (default is lm()).

Details

This constructor creates a regressor based on DST_SlidingWindow. The regressor has a update() and predict() method.

Value

An object of class DST_SlidingWindow.

Author(s)

Michael Hahsler

See Also

Other DSRegressor: DSRegressor()

Examples

library(stream)

# create a data stream for the iris dataset
data <- iris[sample(nrow(iris)), ]
stream <- DSD_Memory(data)

# define the stream Regressor.
cl <- DSRegressor_SlidingWindow(
  Sepal.Length ~ Petal.Length + Petal.Length,
  window = 50,
  rebuild = 10
  )
cl

# update the regressor 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)
pr

plot(pr, newdata$Sepal.Length)
abline(0, 1, col = "red")

# get the tree model
get_model(cl)

stream documentation built on May 29, 2024, 9:43 a.m.