Open levalencia opened 1 year ago
Hello There,
I have used the Confusion Matrix from TorchMetrics as below
Create the Confusion Matrix Function
cm_fn = torchmetrics.ConfusionMatrix(task='multiclass', num_classes=3)
Pass the y_pred and y_true to the cm_fn to get the confusion matrix
confmat = cm_fn(y_pred, y_true)
Hope this helps.
Thanks.
Yeah I know I fixed it also on my notebook but I think it should be mentioned in a page before the video
Sent from Outlook for Androidhttps://aka.ms/AAb9ysg
From: Vineet Sharma @.> Sent: Friday, March 31, 2023 3:26:15 PM To: mrdbourke/pytorch-deep-learning @.> Cc: Luis Valencia @.>; Author @.> Subject: Re: [mrdbourke/pytorch-deep-learning] TypeError: new() missing 1 required positional argument: 'task' (Issue #377)
Hello There,
I have used the Confusion Matrix from TorchMetrics as below
Create the Confusion Matrix Function
cm_fn = torchmetrics.ConfusionMatrix(task='multiclass', num_classes=3)
Pass the y_pred and y_true to the cm_fn to get the confusion matrix
confmat = cm_fn(y_pred, y_true)
Hope this helps.
Thanks.
— Reply to this email directly, view it on GitHubhttps://github.com/mrdbourke/pytorch-deep-learning/issues/377#issuecomment-1491924147, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABVD5KPP4NMUHH3OIEGE4Z3W63LPNANCNFSM6AAAAAAWMDP3LY. You are receiving this because you authored the thread.Message ID: @.***>
Hello my friend : I have encountered a problem with the following code, please tell me how to fix this error
from torchmetrics import ConfusionMatrix from mlxtend.plotting import plot_confusion_matrix
confmat = ConfusionMatrix(num_classes=len(class_names)) confmat_tensor = confmat(preds=test_preds, target=test_truth)
fig, ax = plot_confusion_matrix( conf_mat=confmat_tensor.numpy(), # matplotlib likes working with NumPy class_names=class_names, figsize=(10, 7) )
Related error: TypeError: ConfusionMatrix.new() missing 1 required positional argument: 'task'
Check out https://torchmetrics.readthedocs.io/en/stable/classification/confusion_matrix.html. The task argument has been added since the course was recorded. I ran into the same issue.
On video: Evaluating Our Best Models Predictions with a Confusion Matrix
You show this line: confmat = ConfusionMatrix(num_classes=len(class_names))
But it throws above exception, task parameter is required (binary, multiclass, multilabel)
Maybe a note before the video is worth it