


From the expected outcomes and predictions count:.Make a prediction for each row in your test dataset.

You need a test dataset or a validation dataset with expected outcome values.
CARET CONFUSION MATRIX HOW TO
How to Calculate a Confusion Matrixīelow is the process for calculating a confusion Matrix. It is this breakdown that overcomes the limitation of using classification accuracy alone. It gives you insight not only into the errors being made by your classifier but more importantly the types of errors that are being made. The confusion matrix shows the ways in which your classification model The number of correct and incorrect predictions are summarized with count values and broken down by each class. What is a Confusion Matrix?Ī confusion matrix is a summary of prediction results on a classification problem. But thankfully we can tease apart this detail by using a confusion matrix. You may achieve accuracy of 90% or more, but this is not a good score if 90 records for every 100 belong to one class and you can achieve this score by always predicting the most common class value.Ĭlassification accuracy can hide the detail you need to diagnose the performance of your model.
CARET CONFUSION MATRIX UPDATE
Update Dec/2017: Fixed a small bug in accuracy calculation (thanks Robson Pastor Alexandre)Įrror rate = (1 - (correct predictions / total predictions)) * 100Ĭlassification accuracy is a great place to start, but often encounters problems in practice.Update Oct/2017: Fixed a small bug in the worked example (thanks Raktim).
CARET CONFUSION MATRIX CODE
Kick-start your project with my new book Machine Learning Algorithms From Scratch, including step-by-step tutorials and the Python source code files for all examples.

How to calculate a confusion matrix for a 2-class classification problem from scratch.What the confusion matrix is and why you need to use it.In this post, you will discover the confusion matrix for use in machine learning. Last Updated on AugMake the Confusion Matrix Less Confusing.Ī confusion matrix is a technique for summarizing the performance of a classification algorithm.Ĭlassification accuracy alone can be misleading if you have an unequal number of observations in each class or if you have more than two classes in your dataset.Ĭalculating a confusion matrix can give you a better idea of what your classification model is getting right and what types of errors it is making.
