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

Поделиться
HTML-код
  • Опубликовано: 21 авг 2024

Комментарии • 10

  • @teklenegash6201
    @teklenegash6201 3 года назад

    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  3 года назад

      Why are you doing np.round on preds? They already should be 0s and 1s, right?

  • @AT-om6dn
    @AT-om6dn 2 года назад

    Is FN value should be more than FP value?

  • @chiragsharma9430
    @chiragsharma9430 2 года назад

    Hi Rachit, where can I find the slides on the confusion matrix and other performance metrics?

    • @rachittoshniwal
      @rachittoshniwal  2 года назад +1

      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 года назад +1

      @@chiragsharma9430 oh it's all right!

    • @rachittoshniwal
      @rachittoshniwal  2 года назад +1

      @@chiragsharma9430 Yo, they're live now. github.com/rachittoshniwal/machineLearning/tree/master/ppts

    • @chiragsharma9430
      @chiragsharma9430 2 года назад +1

      @@rachittoshniwal yeah I see thanks for uploading them all. These will be helpful while revising things

  • @ajinkyaadhotre5336
    @ajinkyaadhotre5336 Год назад

    hi