Brief Explanation on Confusion Matrix

Introduction:

In Machine Learning, no algorithm would predict the values as exactly as expected outcomes. Every algorithm has its own drawbacks. Hence, we need to measure the percentage of positive classes by comparing the predicted results with expected outcomes. Here comes the concept of Confusion Matrix which is used to evaluate the classifier.

What is Confusion Matrix?

Confusion Matrix is a method to measure the performance accuracy of Classification Algorithms. The following solution can be driven out from a confusion matrix,

  • It signifies the number of correct and incorrect predictions made by the Classifier.
  • It determines the different number of ways a Classification model got confused in predictions.
  • It also showcases types of error made by the Classifier.

Steps to be followed:

  • Classification algorithm are trained to fit with the training set.
  • Need to predict the values with the help of trained classifier.
  • Compare the predicted values with the available expected test set.

Sample Code (Python):

from sklearn.metrics import confusion_matrix
expected_outcome = [1, 1, 0, 1, 0, 1, 1, 0, 1, 0]
predicted_result = [1, 0, 1, 1, 0, 1, 0, 1, 1, 0]
cm_results = confusion_matrix(expected_outcome, predicted_result)
print(cm_results)
output:
 [[4 2]
  [1 3]]

Related Terms:

Precision: The precision is the percentage of results which are relevant. It refers to the measure of how much the prediction of positive class is correct.

F1 Score: F1 score is a weighted average of the Recall and precision. F1 is more useful than accuracy, if data does not have even number of classes.

Sensitivity: Sensitivity is the ratio of actual positive which are correctly determined. It measures how good the classifier recognizes the positive classes.

Machine learning will automate jobs that most people thought could only be done by people.

Dave Waters

Leave a Reply

Your email address will not be published. Required fields are marked *