Member-only story
Interview question: What is a confusion matrix in machine learning?
Any individual entering the field of data science and machine learning will need to have a clear understanding of what a confusion matrix is because they are used in supervised classification problems.
In the field of machine learning and specifically the problem of statistical classification, a confusion matrix, also known as error matrix, is a specific table layout that allows visualisation of the performance of an algorithm, typically a supervised learning classification problem.
Each row of the matrix represents the instances in an actual class while each column represents the instances in a predicted class, or vice versa.
The confusion matrix is a special kind of contingency table, with two dimensions (“actual” and “predicted”), and identical sets of “classes” in both dimensions (each combination of dimension and class is a variable in the contingency table).
The diagram below is a depiction of a confusion matrix for a binary classification problem:-
- True positive is when the actual and predicted values are positive.
- True negative are when the actual and predicted values are negative.
- False positive is when the actual value is negative but the predicted value is positive