prediction: Function that does prediction based on the fitted models for...

Description Usage Arguments Value Examples

View source: R/EnsembleFuns.R

Description

Function that does prediction based on the fitted models for the new coming data

Usage

1
prediction(x, model_train, parallel)

Arguments

x

- the new coming data that we want to do prediction on

model_train

- the list of models trained on the training data

parallel

- logical value, true if its results will be combined in parallel

Value

The multiple estimation based on the multiple weak models if in parallel, otherwise the final estimation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
x = matrix(rnorm(1000), 200, 5)
y <- x %*% rnorm(5) + rnorm(200, 0, 3)
parallel <- TRUE
coef <- lm(y ~ -1 + x)$coefficients
model_train <- list()
model_train[[1]] <- function(x){
  x <- matrix(x, ncol = length(coef))
  x %*% coef
}
x_new <- matrix(rnorm(5), 1, 5)
prediction(x_new, model_train, parallel)

StevenBoys/Ensemblelearn documentation built on Dec. 11, 2019, 2:06 a.m.