Classification with 'maboost' in R

   Maboost (Mirror Ascent Boosting) is a boosting algorithm to fit a binary and multiclass type data. To learn more about the algorithms, please refers to 'A Boosting Framework on Grounds of Online Learning' by T. Naghibi and B. Pfister (2014).  In this post, I will show how to use a 'maboost' package in R for classification problems.
   First we generate sample data, then train the model, predict test data, and finally, check the accuracy. We use 'maboost' and 'caret' packages in this tutorial.

To install the package, run install.package("maboost") command.
The source code is listed below.



Checking predicted test data results.

print(data.frame(test, predMAB))
     a  b   flag predMAB
16   9 18    red     red
19   4 13  green   green
21   9 19    red     red
35   1 13 yellow  yellow
39   4 17  green   green
47   3 20  green   green
64   3 13  green   green
90   2 12 yellow  yellow
92   7 13    red     red
116  2 12 yellow  yellow
138  8 15    red     red
139 10 11    red     red
152  5 13  green   green
154  3 10  green   green
158  3 18  green   green
175  7 17    red     red
197  5 12  green   green
199  2 17 yellow  yellow
208  3 15  green   green
210  2 13 yellow  yellow
226  4 17  green   green
227  5 19  green   green
231  7 20    red     red
238  9 19    red     red
243  2 19 yellow  yellow
259  5 15  green   green
261 10 10  green     red
271  9 16    red     red
275  8 20    red     red
280  7 15    red     red



Checking model accuracy

confMatMb <- confusionMatrix(test[,3], predMAB) 
print(confMatMb)
Confusion Matrix and Statistics

          Reference
Prediction green red yellow
    green     12   1      0
    red        0  11      0
    yellow     0   0      6

Overall Statistics
                                          
               Accuracy : 0.9667          
                 95% CI : (0.8278, 0.9992)
    No Information Rate : 0.4             
    P-Value [Acc > NIR] : 5.303e-11       
                                          
                  Kappa : 0.9479          
 Mcnemar's Test P-Value : NA              

Statistics by Class:

                     Class: green Class: red Class: yellow
Sensitivity                1.0000     0.9167           1.0
Specificity                0.9444     1.0000           1.0
Pos Pred Value             0.9231     1.0000           1.0
Neg Pred Value             1.0000     0.9474           1.0
Prevalence                 0.4000     0.4000           0.2
Detection Rate             0.4000     0.3667           0.2
Detection Prevalence       0.4333     0.3667           0.2
Balanced Accuracy          0.9722     0.9583           1.0



Reference:

A Boosting Framework on Grounds of Online Learning by T. Naghibi and B. Pfister


No comments:

Post a Comment