add_observation-methods: Add an observation

Description Usage Arguments Value Examples

Description

Generic function for adding observations.

The function takes as first argument an initialized model (or a collection of models), and subsequently updates the parameters given an observation that is split into y (a 0 or 1 scalar) and a vector X containing the features. Note that the lenght of X needs to match the dimensions of the parameters of the current model.

The function takes as first argument an initialized model comparison, and subsequently update the parameters of each model give an observation that is split into y (a 0 or 1 scalar) and a vector X containing the features. Note that the lenght of X needs to match the dimensions of the parameters of the current model.

Usage

1
2
3
4
5
6
7
add_observation(object, y, X, ...)

## S4 method for signature 'online_log_mixture'
add_observation(object, y, X, lambda = 0.1)

## S4 method for signature 'multi_online_log_mixture'
add_observation(object, y, X, ...)

Arguments

object

An object of type online_log_mixture

y

A scalar with value 0 or 1; the dependent variable

X

The feature vector of the current observation

lambda

The current learn rate. If <=0 than lambda <- n+1000^(-.5) where n is the number of observations

object

An object of type online_log_mixture

y

A scalar with value 0 or 1; the dependent variable

X

The feature vector of the current observation

lambda

The current learn rate. If <=0 than lambda <- n+1000^(-.5) where n is the number of observations

Value

An updated object of type online_log_mixture

An updated object of type multi_online_log_mixture

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
M1 <- online_log_mixture(2,4, trace=1)
M1 <- add_observation(M1, 1, c(2,-3))
M1

M2 <- online_log_mixture(2,1, trace=1)
for(i in 1:500){
		X <- runif(2,-2,2)
		y <- rbinom(1, 1, inv_logit(c(2,-2)%*%X))
		M2 <- add_observation(M2, y, X, .1)
}
M2

M1 <- online_log_mixture(2,1)
models <- multi_online_log_mixture(M1)
models <- add_model(models, online_log_mixture(2,2))
models <- add_observation(models, 1, c(2,-3))

MKaptein/ofmlr documentation built on Sept. 25, 2020, 11:46 a.m.