What is a Confusion Matrix | TP, TN, FP, FN | Type 1 & 2 Error | Easily explained | Machine Learning

  Рет қаралды 6,498

Rachit Toshniwal

Rachit Toshniwal

Күн бұрын

In this tutorial, we'll look at the confusion matrix.
First we'll look at why the need for such a matrix arises in the first place, and how we can dissect performance of a classifier by using a confusion matrix.
Then we'll look at the four basic terminologies, viz. True Positives, True Negatives, False Positives and False Negatives and what do they really mean.
Finally we'll look at Type 1 and Type 2 errors.
I've uploaded all the relevant code and datasets used here (and all other tutorials for that matter) on my github page which is accessible here:
Link:
github.com/rac...
If you like my content, please do not forget to upvote this video and subscribe to my channel.
If you have any qualms regarding any of the content here, please feel free to comment below and I'll be happy to assist you in whatever capacity possible.
Thank you!

Пікірлер: 10
@AT-om6dn
@AT-om6dn 2 жыл бұрын
Is FN value should be more than FP value?
@teklenegash6201
@teklenegash6201 4 жыл бұрын
thank you very much sir. i clearly understand those terms now. could you tell me the reason why testing accuracy, precision, recall become under 10% while the traning and validation accuracy are more than 90%. my confusion matrix value on the precison, recall and f1 score vlues is showing too less which is under 10. here is the final result sir. Epoch 10/10 164/164 [==============================] - 95s 577ms/step - loss: 0.1356 - accuracy: 0.9502 - val_loss: 0.2857 - val_accuracy: 0.9194 from sklearn.metrics import accuracy_score, confusion_matrix preds = model.predict(test_data) acc = accuracy_score(test_labels, np.round(preds))*100 cm = confusion_matrix(test_labels, np.round(preds)) tn, fp, fn, tp = cm.ravel() print('CONFUSION MATRIX ------------------') print(cm) print(' TEST METRICS ----------------------') precision = tp/(tp+fp)*100 recall = tp/(tp+fn)*100 print('Accuracy: {}%'.format(acc)) print('Precision: {}%'.format(precision)) print('Recall: {}%'.format(recall)) print('F1-score: {}'.format(2*precision*recall/(precision+recall))) print(' TRAIN METRIC ----------------------') print('Train acc: {}'.format(np.round((hist.history['accuracy'][-1])*100, 2))) CONFUSION MATRIX ------------------ [[ 37 197] [375 15]] TEST METRICS ---------------------- Accuracy: 8.333333333333332% Precision: 7.0754716981132075% Recall: 3.8461538461538463% F1-score: 4.983388704318937
@rachittoshniwal
@rachittoshniwal 4 жыл бұрын
Why are you doing np.round on preds? They already should be 0s and 1s, right?
@chiragsharma9430
@chiragsharma9430 2 жыл бұрын
Hi Rachit, where can I find the slides on the confusion matrix and other performance metrics?
@rachittoshniwal
@rachittoshniwal 2 жыл бұрын
Hi Chirag, you can find them on my laptop xD gimme some time, and you'll find them on GitHub too haha
@chiragsharma9430
@chiragsharma9430 2 жыл бұрын
@@rachittoshniwal hahaha take your time and thanks for uploading them. Really appreciate you taking the time to read my comment and your content you make.
@rachittoshniwal
@rachittoshniwal 2 жыл бұрын
@@chiragsharma9430 oh it's all right!
@rachittoshniwal
@rachittoshniwal 2 жыл бұрын
@@chiragsharma9430 Yo, they're live now. github.com/rachittoshniwal/machineLearning/tree/master/ppts
@chiragsharma9430
@chiragsharma9430 2 жыл бұрын
@@rachittoshniwal yeah I see thanks for uploading them all. These will be helpful while revising things
@ajinkyaadhotre5336
@ajinkyaadhotre5336 Жыл бұрын
hi
TPR,FPR,FNR,TNR, Confusion Matrix
25:12
Krish Naik
Рет қаралды 73 М.
Modus males sekolah
00:14
fitrop
Рет қаралды 25 МЛН
What La Niña Will do to Earth in 2025
19:03
Astrum
Рет қаралды 541 М.
Fraud Detection: Fighting Financial Crime with Machine Learning
12:01
Pixtral is REALLY Good - Open-Source Vision Model
11:15
Matthew Berman
Рет қаралды 44 М.
How To Identify Type I and Type II Errors In Statistics
11:24
The Organic Chemistry Tutor
Рет қаралды 422 М.