Questions tagged [confusion-matrix]

A confusion matrix is a contingency table of correct and incorrect classifications used to evaluate the performance of a classification algorithm in machine learning.

1111 questions
16
votes
4 answers

calculate accuracy and precision of confusion matrix

Is there any tool / R package available to calculate accuracy and precision of a confusion matrix? The formula and data structure are here.
Ajay Singh
  • 289
  • 1
  • 3
  • 10
15
votes
2 answers

Plot Confusion Matrix for multilabel Classifcation Python

I'm looking for someone who can help me to plot my Confusion Matrix. I need this for a term paper at the university. However I have very little experience in programming. In the pictures you can see the classification report and the structure of my…
15
votes
1 answer

How to make sklearn.metrics.confusion_matrix() to always return TP, TN, FP, FN?

I am using sklearn.metrics.confusion_matrix(y_actual, y_predict) to extract tn, fp, fn, tp and most of the time it works perfectly. from sklearn.metrics import confusion_matrix y_actual, y_predict = [1,1,1,1], [0,0,0,0] tn, fp, fn, tp =…
Scoodood
  • 583
  • 1
  • 5
  • 13
14
votes
3 answers

Multi-class multi-label confusion matrix with Sklearn

I am working with a multi-class multi-label output from my classifier. The total number of classes is 14 and instances can have multiple classes associated. For example: y_true = np.array([[0,0,1], [1,1,0],[0,1,0]) y_pred = np.array([[0,0,1],…
14
votes
5 answers

Confusion matrix and test accuracy for PyTorch Transfer Learning tutorial

Following the Pytorch Transfer learning tutorial, I am interested in reporting only train and test accuracy as well as confusion matrix (say using sklearn confusionmatrix). How can I do that? The current tutorial only reports train/val accuracy and…
Mona Jalal
  • 34,860
  • 64
  • 239
  • 408
14
votes
3 answers

How to get confusion matrix when using model.fit_generator

I am using model.fit_generator to train and get results for my binary (two class) model because I am giving input images directly from my folder. How to get confusion matrix in this case (TP, TN, FP, FN) as well because generally I use…
Hitesh
  • 1,285
  • 6
  • 20
  • 36
14
votes
1 answer

How to retrieve overall accuracy value from confusionMatrix in R?

In R caret library, if I got a confusion matrix like this below, if there a way to retrieve the overall accuracy 0.992? I can't get this single value out, since I need to store this value and use it for later processing. Is this possible at all? …
user697911
  • 10,043
  • 25
  • 95
  • 169
12
votes
3 answers

How to change plot_confusion_matrix default figure size in sklearn.metrics package

I tried to plot confusion matrix with Jupyter notebook using sklearn.metrics.plot_confusion_matrix package, but the default figure size is a little bit small. I have added plt.figure(figsize=(20, 20)) before plotting, but the figure size did not…
11
votes
3 answers

Why scikit learn confusion matrix is reversed?

I have 3 questions: 1) The confusion matrix for sklearn is as follows: TN | FP FN | TP While when I'm looking at online resources, I find it like this: TP | FP FN | TN Which one should I consider? 2) Since the above confusion matrix for scikit…
11
votes
1 answer

What's the correct way to compute a confusion matrix for object detection?

I am trying to compute a confusion matrix for my object detection model. However, I seem to stumble across some pitfalls. My current approach is to compare each predicted box with each ground truth box. If they have an IoU > some threshold, I insert…
ITiger
  • 1,056
  • 3
  • 11
  • 24
11
votes
2 answers

how to create confusion matrix for classification in tensorflow

I have CNN model which has 4 output nodes, and I am trying to compute the confusion matrix so that i can know the individual class accuracy. I am able to compute the overall accuracy. In the link here, Igor Valantic gave a function which can compute…
Raady
  • 1,686
  • 5
  • 22
  • 46
11
votes
1 answer

Scikit - changing the threshold to create multiple confusion matrixes

I'm building a classifier that goes through lending club data, and selects the best X loans. I've trained a Random Forest, and created the usual ROC curves, Confusion Matrices, etc. The confusion matrix takes as an argument the predictions of the…
11
votes
3 answers

R package caret confusionMatrix with missing categories

I am using the function confusionMatrix in the R package caret to calculate some statistics for some data I have. I have been putting my predictions as well as my actual values into the table function to get the table to be used in the…
Barker
  • 2,074
  • 2
  • 17
  • 31
10
votes
2 answers

ImportError: cannot import name 'plot_confusion_matrix' from 'sklearn.metrics'

I am attempting to run below code. from sklearn.metrics import plot_confusion_matrix And I am receiving below error. --------------------------------------------------------------------------- ImportError Traceback…
excelman
  • 189
  • 1
  • 2
  • 10
10
votes
3 answers

Plotly: How to make an annotated confusion matrix using a heatmap?

I like to use Plotly to visualize everything, I'm trying to visualize a confusion matrix by Plotly, this is my code: def plot_confusion_matrix(y_true, y_pred, class_names): confusion_matrix = metrics.confusion_matrix(y_true, y_pred) …
1
2
3
74 75