TypeError: ConfusionMatrix.__new__() missing 1 required positional argument: 'task' #483
Unanswered
KaisarJamil
asked this question in
Q&A
Replies: 1 comment 1 reply
-
on the second step when you initialize the confusion matrix, you need to specify the task. The correct code would be -
Go through the confusion matrix doc, for more info |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I tried to plot the confusion matrix in "03_pytorch_computer_vision" session following below:
`from torchmetrics import ConfusionMatrix
from mlxtend.plotting import plot_confusion_matrix
Setup confusion instance and compare predictions to targets
confmat = ConfusionMatrix(num_classes=len(class_names))
confmat_tensor = confmat(preds=y_pred_tensor,
target=test_data.targets)
Plot the confusion matrix
fig, ax = plot_confusion_matrix(
conf_mat=confmat_tensor.numpy(), # matplotlib likes working with numpy
class_names=class_names,
figsize=(10, 7)
)`
But it occurred an error :
`---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in <cell line: 5>()
3
4 # 2. Setup confusion instance and compare predictions to targets
----> 5 confmat = ConfusionMatrix(num_classes=len(class_names))
6 confmat_tensor = confmat(preds=y_pred_tensor,
7 target=test_data.targets)
TypeError: ConfusionMatrix.new() missing 1 required positional argument: 'task'`
Beta Was this translation helpful? Give feedback.
All reactions