I have built a model to predict Upsell probability. When I use the function confusionMatirx from caret package, I get the following results:
> confusionMatrix(data = predict_svm_test_5, test_td$UpSell_Ind)
Confusion Matrix and Statistics
Reference
Prediction 0 1
0 7976 2886
1 217 644
Accuracy : 0.7353
95% CI : (0.7272, 0.7433)
No Information Rate : 0.6989
P-Value [Acc > NIR] : < 2.2e-16
Kappa : 0.1987
Mcnemar's Test P-Value : < 2.2e-16
Sensitivity : 0.9735
Specificity : 0.1824
Pos Pred Value : 0.7343
Neg Pred Value : 0.7480
Prevalence : 0.6989
Detection Rate : 0.6804
Detection Prevalence : 0.9266
Balanced Accuracy : 0.5780
'Positive' Class : 0
However, I expected to see the confusion matrix as follows:
Reference
Prediction 1 0
1 644 217
0 2886 7976
Specificity(TPR): 0.9735
Sensitivity(TNR): 0.1824
1 meaning there was an Upsell (Event) and 0 meaning no Upsell (No Event) based on the PDF of Caret Package. Link is here Page 24, 25
Now my question: How do I interpret the results of confusionMatrix? The values given by the function are different from values that I calculate.
Thanks in advance for the help.
Best Answer
Thanks @charles for pointing me to "positive". Though positive = 1 did not work as the argument positive takes only character value in the function. But I was able to get what I wanted using the following: