Classification with MXNet in R

   MXNet is a deep learning framework to train and deploy deep learning models. In deep learning, the outcome values come from the input data passing through the multiple successive neural network layers in between. Each layer learns a specific feature of input data and contributes to the final decision.
   In this post, I'll show a classification method by using 'mxnet' library in R. You may find more info about the library in this link.
   We use an 'iris' dataset for this tutorial. First, we separate a dataset into train and test parts, then fit a model with a train data, predict a test data, and finally, check the results. To split a dataset and calculate the statistics of observed and predicted data, we use 'caret' library.
   Here is a source code in R.
The results:

Start training with 1 devices
[1] Train-accuracy=0.230769230769231
[2] Train-accuracy=0.507142857142857
[3] Train-accuracy=0.407142857142857
[4] Train-accuracy=0.514285714285714
[5] Train-accuracy=0.678571428571429
[6] Train-accuracy=0.678571428571429
...... 
[93] Train-accuracy=0.95
[94] Train-accuracy=0.957142857142857
[95] Train-accuracy=0.971428571428572
[96] Train-accuracy=0.978571428571429
[97] Train-accuracy=0.964285714285714
[98] Train-accuracy=0.95
[99] Train-accuracy=0.95
[100] Train-accuracy=0.95
Confusion Matrix and Statistics

          Reference
Prediction 0 1 2
         0 5 0 0
         1 0 5 0
         2 0 0 5

Overall Statistics
                                    
               Accuracy : 1         
                 95% CI : (0.782, 1)
    No Information Rate : 0.3333    
    P-Value [Acc > NIR] : 6.969e-08 
                                    
                  Kappa : 1         
 Mcnemar's Test P-Value : NA        

Statistics by Class:

                     Class: 0 Class: 1 Class: 2
Sensitivity            1.0000   1.0000   1.0000
Specificity            1.0000   1.0000   1.0000
Pos Pred Value         1.0000   1.0000   1.0000
Neg Pred Value         1.0000   1.0000   1.0000
Prevalence             0.3333   0.3333   0.3333
Detection Rate         0.3333   0.3333   0.3333
Detection Prevalence   0.3333   0.3333   0.3333
Balanced Accuracy      1.0000   1.0000   1.0000


   The model training accuracy has reached 100%, and test data has predicted with 100% accuracy. I hope you have found the post useful. Thank you for reading!

No comments:

Post a Comment