LinearRegression: Create a streamer for updating a linear regression model

Description Format Methods Examples

Description

LinearRegressions creates a streaming algorithm that can calculate and update linear regression coefficients.

Format

An R6Class generator object

Methods

Public methods


Method new()

Creates a new LinearRegression streamer object.

Usage
LinearRegression$new(X, y, fit_intercept = TRUE, method = "woodbury")
Arguments
X

initial design matrix

y

initial labels

fit_intercept

if 'TRUE', add an intercept to the model

method

the method used to update regression coefficients

Returns

The new LinearRegression (invisibly)


Method update()

Updates the regression coefficient based on new data

Usage
LinearRegression$update(X, y)
Arguments
X

new design matrix

y

new labels

#' @return The updated LinearRegression (invisibly)


Method clone()

The objects of this class are cloneable with this method.

Usage
LinearRegression$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

1
2
3
4
5
6
X <- matrix(c(3, 1, 4, 1, 5, 9, 2, 6), ncol = 2)
y <- c(2, 7, 1, 8)
reg <- LinearRegression$new(X, y)
X_new <- matrix(c(5, 3, 5, 8), ncol = 2)
y_new <- c(2, 8)
reg$update(X_new, y_new)

THargreaves/onlineoceanarium documentation built on Jan. 13, 2022, 10:41 p.m.