train.adabag: train.adabag

View source: R/train.R

train.adabagR Documentation

train.adabag

Description

Provides a wrapping function for the boosting.

Usage

train.adabag(
  formula,
  data,
  boos = TRUE,
  mfinal = 100,
  coeflearn = "Breiman",
  minsplit = 20,
  maxdepth = 30,
  ...
)

Arguments

formula

a symbolic description of the model to be fit.

data

an optional data frame containing the variables in the model.

boos

if TRUE (by default), a bootstrap sample of the training set is drawn using the weights for each observation on that iteration. If FALSE, every observation is used with its weights.

mfinal

an integer, the number of iterations for which boosting is run or the number of trees to use. Defaults to mfinal=100 iterations.

coeflearn

if 'Breiman'(by default), alpha=1/2ln((1-err)/err) is used. If 'Freund' alpha=ln((1-err)/err) is used. In both cases the AdaBoost.M1 algorithm is used and alpha is the weight updating coefficient. On the other hand, if coeflearn is 'Zhu' the SAMME algorithm is implemented with alpha=ln((1-err)/err)+ ln(nclasses-1).

minsplit

the minimum number of observations that must exist in a node in order for a split to be attempted.

maxdepth

Set the maximum depth of any node of the final tree, with the root node counted as depth 0. Values greater than 30 rpart will give nonsense results on 32-bit machines.

...

arguments passed to rpart.control or adabag::boosting. For stumps, use rpart.control(maxdepth=1,cp=-1,minsplit=0,xval=0). maxdepth controls the depth of trees, and cp controls the complexity of trees.

Value

A object adabag.prmdt with additional information to the model that allows to homogenize the results.

Note

The parameter information was taken from the original function boosting and rpart.control.

See Also

The internal function is from package boosting.

Examples


data <- iris
n <- nrow(data)

sam <- sample(1:n,n*0.75)
training <- data[sam,]
testing <- data[-sam,]

model <- train.adabag(formula = Species~.,data = training,minsplit = 2,
                      maxdepth = 30, mfinal = 10)
model
predict <- predict(object = model,testing,type = "class")
predict


traineR documentation built on Nov. 10, 2023, 1:15 a.m.