confusion-matrix

How to plot a confusion matrix

How to plot a confusion matrix Question: I am trying to evaluate my renet50 model with a confusion matrix, but the confusion matrix looks like this: matrix = confusion_matrix(y_test, y_pred, normalize="pred") print(matrix) # output array([[1, 0], [1, 2]], dtype=int64) I am using scikit-learn for generating the confusion matrix and tf keras for making the model …

Total answers: 2

Confused about creating a result matrix for NxN matrix transposition in Python

Confused about creating a result matrix for NxN matrix transposition in Python Question: NxN Matrix transposing gives wrong answers upon making "result" matrix = input matrix Novice programmer here. I am trying to transpose a NxN matrix. Putting the code here to make the problem clear: def flippingMatrix(matrix): result=[[0 for i in range(len(matrix))] for j …

Total answers: 2

How to extract performance metrics from confusion matrix for multiclass classification model with 5 classes in Python?

How to extract performance metrics from confusion matrix for multiclass classification model with 5 classes in Python? Question: I built multiclass classification model (with 5 classes in target) in Python and I have confusion matrix like below: confusion_matrix(y_test, model.predict(X_test)) [[2006 114 80 312 257] [567 197 87 102 155] [256 84 316 39 380] [565 …

Total answers: 1

Confusion matrix plot one decimal but exact zeros

Confusion matrix plot one decimal but exact zeros Question: I’m trying to plot a confusion matrix that has one decimal for all values but if the value is exact zero, I would like to keep it as an exact zero rather than 0.0. How can I achieve this? In this minimal example for example I …

Total answers: 1

Analyzing keras model w.r.t a specific feature

Analyzing keras model w.r.t a specific feature Question: I have a dataset that consists of different features, like "gender". The task of the model is to determine if the annual income is above or below 50k. It is the "Adult income dataset" from: https://www.kaggle.com/datasets/wenruliu/adult-income-dataset Let say I have a trained network that does the classification. …

Total answers: 1

Keras evaluate Accuracy w.r.t. a feature

Keras evaluate Accuracy w.r.t. a feature Question: I have a dataset that consists of different features, like "gender". The task of the model is to determine if the annual income is above or below 50k. Let say I have a trained network that does the classification. Now I want to see how often the classifier …

Total answers: 1

Find confusion matrix of image classification in Tensorflow

Find confusion matrix of image classification in Tensorflow Question: I am training a model to classify images into 2 classes following this tutorial: https://www.tensorflow.org/tutorials/images/classification After model.fit(), I want to evaluate the accuracy of the model’s prediction using a test set which contains images that weren’t included in the training or validation sets. The test set …

Total answers: 2

Adjust size of ConfusionMatrixDisplay (ScikitLearn)

Adjust size of ConfusionMatrixDisplay (ScikitLearn) Question: How to set the size of the figure ploted by ScikitLearn’s Confusion Matrix? import numpy as np from sklearn.metrics import ConfusionMatrixDisplay, confusion_matrix cm = confusion_matrix(np.arange(25), np.arange(25)) cmp = ConfusionMatrixDisplay(cm, display_labels=np.arange(25)) cmp.plot() The code above shows this figure, which is too tight: Asked By: Raphael || Source Answers: You can …

Total answers: 2

Mean of non-diagonal elements of each row numpy

Mean of non-diagonal elements of each row numpy Question: I essentially have a confusion matrix of size n x n with all my diagonal elements being 1. For every row, I wish to calculate its mean, excluding the 1, i.e. excluding the diagonal value. Is there a simple way to do it in numpy? This …

Total answers: 3