A margin is a measure of the certainty of classification. This method calculates the difference between the support of a correct class and the maximum support of an incorrect class. In this recipe, we will demonstrate how to calculate the margins of the generated classifiers.
You need to have completed the previous recipe by storing a fitted bagging model in the variables, churn.bagging
and churn.predbagging
. Also, put the fitted boosting
classifier in both churn.boost
and churn.boost.pred
.
Perform the following steps to calculate the margin of each ensemble learner:
- First, use the
margins
function to calculate the margins of theboosting
classifiers:
> boost.margins = margins(churn.boost, trainset) > boost.pred.margins = margins(churn.boost.pred, testset)
- You can then use the
plot
function to plot a marginal cumulative distribution graph of theboosting
classifiers:
> plot(sort(boost.margins[...