How to do it...

Perform the following steps to calculate the margin of each ensemble learner:

  1. First, use the margins function to calculate the margins of the boosting classifiers:
        > boost.margins = margins(churn.boost, trainset)
        > boost.pred.margins = margins(churn.boost.pred, testset)
  1. You can then use the plot function to plot a marginal cumulative distribution graph of the boosting classifiers:
        > plot(sort(boost.margins[[1]]),        (1:length(boost.margins[[1]]))/length(boost.margins[[1]]),        type="l",xlim=c(-1,1),main="Boosting: Margin cumulative        distribution graph", xlab="margin", ylab="% observations",         col = "blue")
        > lines(sort(boost.pred.margins[[1]])        (1:length(boost.pred.margins[[1]]))/length(boost.pred.margins[[1]]) , type="l", col ...

Get Machine Learning with R Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.