BAG_Model | R Documentation |
Bagging Model
BAG_Model(Data, xvar, yvar)
Data |
The name of the Dataset. |
xvar |
X variables. |
yvar |
Y variable. |
Decision trees suffer from high variance (If we split the training data-set randomly into two parts and set a decision tree to both parts, the results might be quite different). Bagging is an ensemble procedure which reduces the variance and increases the prediction accuracy of a statistical learning method by considering many training sets (\hat{f}^{1}(x),\hat{f}^{2}(x),…,\hat{f}^{B}(x)) from the population. Since we can not have multiple training-sets, from a single training data-set, we can generate B different bootstrapped training data-sets (\hat{f}^{*1}(x), \hat{f}^{*2}(x), …,\hat{f}^{*B}(x)) by each B trees and take a majority vote. Therefore, bagging for classification problem defined as
\hat{f}(x)=arg\max_{k}\hat{f}^{*b}(x)
The output from BAG_Model
.
yvar <- c("Loan.Type") sample_data <- sample_data[c(1:750),] xvar <- c("sex", "married", "age", "havejob", "educ", "political.afl", "rural", "region", "fin.intermdiaries", "fin.knowldge", "income") BchMk.BAG <- BAG_Model(sample_data, c(xvar, "networth"), yvar ) BchMk.BAG$Roc$auc
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.