Adaboost: Function that implement the algorithm of Ensemble learning in...

Description Usage Arguments Value Examples

View source: R/adaboost.R

Description

Function that implement the algorithm of Ensemble learning in AdaBoost

Usage

1
Adaboost(fweak, data, model_num)

Arguments

fweak

- function that generates estimate from weak model based on input

data

- list of data that fweak need including x, y and last_est

model_num

- the number of weak models you want to train and combine

Value

A list of

fitted_value

- fitted value on the training dataset based on the trained model

model_train

- a list of trained weak models

Examples

1
2
3
4
5
6
7
8
fweak <- function(x, y, last_est){
  lm(y ~ -1 + x, weights = last_est)$coefficients
}
data <- list(x = matrix(rnorm(1000), 200, 5))
data$y <- data$x %*% rnorm(5) + rnorm(200, 0, 3)
data$last_est <- rep(1/length(data$y), length(data$y))
model_num <- 100
Adaboost(fweak, data, model_num)

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