# A Confusion Matrix Helps

## Confusion Matrix in Machine Learning with EXAMPLE

A confusion matrix is a technique for evaluating the performance of Machine Learning classification algorithms. An example of this would be a table that allows you to determine the performance of a classification model on a set of test data for which the real values have been determined. Although the word “conflict matrix” is a straightforward concept, the verbiage that surrounds it can be a little befuddling. This approach is explained in this section in a straightforward manner.

You will learn the following things in this tutorial:

## Four outcomes of the confusion matrix

TP stands for True Positive, which means that the anticipated numbers were successfully forecasted as actual positive.

FP: The predicted values were inaccurate in their prediction of an actual positive outcome. Specifically, negative values are projected to be positive.

FN: False Noun Positive values are projected to be negative when they are positive.

TN: True Negative: Forecasted values that were successfully predicted as being negative in reality.

From the confusion matrix, you can compute the accuracy test as follows:

An example of a Confusion Matrix is as follows:

Confusion Matrix is a valuable machine learning tool that allows you to measure Recall, Precision, Accuracy, and the area under the curve (AUC-ROC curve). The following example will help you understand the meanings of the terms True Positive, True Negative, False Negative, and True Negative.

## Example of Confusion Matrix:

You made a positive projection, and it turned out to be correct. For instance, you predicted that France would win the World Cup, and France did indeed win.

‘True Negative’ refers to the absence of a true negative.

When you predicted a negative outcome, you were correct. You had predicted that England would not win, and it did not win the World Cup.

False positives are when something is not as it appears.

The outcome of your prediction is both positive and incorrect.

Even though you anticipated that England would win, the team came up short.

False Negative (False Negative):

Your guess was incorrect, and the outcome was also incorrect.

You had projected that France would lose, but it ended up winning.

Please keep in mind that anticipated values are either True or False, as well as Positive and Negative, depending on the situation.

### Calculating a Confusion Matrix is a simple process.

In this section, you will find a step-by-step procedure for calculating a confusion matrix in data mining.

Step 1) To begin, you must test the dataset using the predicted outcome values that it contains.

Step 2) Predict all of the rows in the test dataset using statistical methods.

The following are the expected forecasts and outcomes for Step 3:

The total number of right predictions made by each class is shown below.

The total number of inaccurate predictions made by each class is calculated.

Following that, these numbers are sorted according to the techniques listed below:

### In the matrix, each row corresponds to a predicted class, and so on.

Every column of the matrix belongs to a specific class….

It is necessary to enter the total number of correct and wrong classifications into the table.

Accurate predictions for a class are placed in the predicted column and expected row for that class value, and the sum of correct predictions for that class is placed in the expected column and expected row for that class value.

For a given class, the aggregate of inaccurate predictions is entered into the expected row for that class value and into the predicted column for that specific class value.

Using a Confusion matrix, you can find out about other important terms.

Precision is really close to being achieved by having a positive predictive value (PVV). Among the key differences between the terms is that PVV takes into account prevalence. When the classes are exactly balanced, the positive predictive value is the same as the precision in the case.

If you are able to anticipate the majority class, you can calculate your null error rate, which is the number of times your prediction would be incorrect. You can think of it as a baseline statistic against which your classifier can be compared.

A true positive (recall) and precision score are combined to get the F1 score, which is a weighted average value.

An example of a ROC curve is one that plots the true positive rates versus the false positive rates at different cut points. Moreover, it illustrates a trade-off between sensitivity and robustness (recall and specificity or the true negative rate).

Precision: The precision measure indicates the degree to which the affirmative class is accurate. It determines how likely it is that the forecast of the positive class is accurate.

When the classifier correctly classifies all of the positive values, the highest possible score is one. Precision on its own is not very useful because it does not take into account the negative class. The measure is frequently used in conjunction with the Recall metric. The term “recall” can also refer to the term “sensitivity” or the term “true positive rate.”

Sensitivity is the ratio of positive classes accurately detected to the total number of positive classes. This statistic indicates how well the model performs when it comes to recognising a positive class.

### What is the purpose of Confusion matrix?

The following are some of the advantages and disadvantages of employing a confusion matrix.

It demonstrates how any classification model might become perplexed when making predictions.

The confusion matrix not only provides insight into the errors that your classifier is making, but it also provides insight into the types of errors that are being made.

This breakdown will assist you in overcoming the constraint of using classification accuracy alone in your analysis.

For each column of the confusion matrix, the instances of that anticipated class are represented by a row.

Similarly, each row of the confusion matrix represents an instance of the actual class in question.

It provides insight into not only the errors made by a classifier, but also the errors that are being made by the classifier.