TASK 5
CONFUSION MATRIX
Have you ever thought why your machine learning model to perform really well but it have errors in prediction or have poor accuracy ? Instead of performing programming with taking all right measures why these errors come into existance ? This an be easily understand eith the help of a Confusion Matrix.
WHAT IS A CONFUSION MATRIX ?
In the field of Machine Learning and specially the problem of statistical classification, a Confusion Matrix, also known as an Error Matrix, is a specific table layout that allows visualization of the performance of an algorithm, typically a supervised learning one.
PROPERTY OF CONFUSION MATRIX
>> It is a SQUARE MATRIX of order N.
>> Order of a Confusion Matrix is equals to the number of target classes.
>> Every row of the matrix represents the instances in ACTUAL CLASS while each column represents the instances in PREDICED CLASS, or vise-versa.
WHAT IS THE NEED OF CONFUSION MATRIX ?
A Confusion Matrix of order N is used for evaluating the performance of a classification model, where N is the number of target classes. The matrix compares the actual target values with those predicted by the machine learning model. This gives us a holistic view of how well our classification model is performing and what kinds of errors it is making.
BASIC STRUCTURE OF CONFUSION MATRIX
>> The target variable has two values:-
1. Positive 2. Negative
>> The columns represent the actual values of the target variable
>> The rows represent the predicted values of the target variable
ANALYSIS OF CONFUSION MATRIX
A binary classifier can make two types of errors:
1. It can incorrectly assign an individual who defaults to the no default category.
2. It can incorrectly assign an individual who does not default to the default category.
It is often of interest to determine which of these two types of errors are being made. A confusion matrix is a convenient way to display this information.
For a binary classification problem, we would have a 2 x 2 matrix with 4 values as shown below:
True Positive (TP)
> The predicted value matches the actual value
> The actual value was positive and the model predicted a positive value
True Negative (TN)
> The predicted value matches the actual value
> The actual value was negative and the model predicted a negative value
False Positive (FP) — Type 1 error
> The predicted value was falsely predicted
> The actual value was negative but the model predicted a positive value
> Also known as the Type 1 error
False Negative (FN) — Type 2 error
> The predicted value was falsely predicted
> The actual value was positive but the model predicted a negative value
> Also known as the Type 2 error
TYPE I
> A error means rejecting the null hypothesis when it’s actually true.
> You predicted positive and it’s false.
Type II
> A error means failing to reject the null hypothesis when it’s actually false.
> You predicted negative and it’s false.
FINDING DIFFERENT VALUES USING CONFUSION MATRIX
1. Accuracy -
The accuracy of a machine learning classification algorithm is one way to measure how often the algorithm classifies a data point correctly.
Accuracy = Number of correct predictions Total number of predictions.
2. Precision -
Precision is the ratio of correctly predicted positive observations to the total predicted positive observations.
3. Recall -
Recall tells us how many of the actual positive cases we were able to predict correctly with our model.
CONCLUSION
As the name suggest the Confusion Matrix is not so confusing now. It is a basically a square matrix which is used to calculate various parameters in Machine Learning. It also helps to understand the programing algorithms performed by the machines in Machine Learning and Deep Learning.