| Title: | Multi-Class Area Under the Minimum in Torch |
|---|---|
| Description: | Torch code for computing multi-class Area Under The Minimum, <https://www.jmlr.org/papers/v24/21-0751.html>, Generalization. Useful for optimizing Area under the curve. |
| Authors: | Omar Guenoun [aut, cre] |
| Maintainer: | Omar Guenoun <[email protected]> |
| License: | LGPL-3 |
| Version: | 30.07.2025 |
| Built: | 2026-05-11 07:54:39 UTC |
| Source: | https://github.com/oguenoun/torchmaum |
This function draws K ROC curves using OvR approach, each time considering one class as the positive class. It assumes that all the inputs are torch tensors and labels are in [1,K] with K being the number of classes.
Draw_ROC_curve_macro(pred_tensor, label_tensor)Draw_ROC_curve_macro(pred_tensor, label_tensor)
pred_tensor |
output of the model assuming it is of dimension NxK (or Nx1 for binary classification) |
label_tensor |
true labels , tensor of length N |
K ROC curves
## Not run: # Small example with 3 classes and 10 samples labels = torch::torch_randint(1, 4, size = 10, dtype = torch::torch_long()) Draw_ROC_curve_micro(torch::torch_randn(c(10, 3)), labels) ## End(Not run)## Not run: # Small example with 3 classes and 10 samples labels = torch::torch_randint(1, 4, size = 10, dtype = torch::torch_long()) Draw_ROC_curve_micro(torch::torch_randn(c(10, 3)), labels) ## End(Not run)
This function draws one ROC curve using OvR approach and micro average. It assumes that all the inputs are torch tensors and labels are in [1,K] with K being the number of classes.
Draw_ROC_curve_micro(pred_tensor, label_tensor)Draw_ROC_curve_micro(pred_tensor, label_tensor)
pred_tensor |
output of the model assuming it is of dimension NxK (or Nx1 for binary classification) |
label_tensor |
true labels , tensor of length N |
plot of the ROC curve
## Not run: # Small example with 3 classes and 10 samples labels = torch::torch_randint(1, 4, size = 10, dtype = torch::torch_long()) Draw_ROC_curve_micro(torch::torch_randn(c(10, 3)), labels) ## End(Not run)## Not run: # Small example with 3 classes and 10 samples labels = torch::torch_randint(1, 4, size = 10, dtype = torch::torch_long()) Draw_ROC_curve_micro(torch::torch_randn(c(10, 3)), labels) ## End(Not run)
This function computes the multi class ROC AUC using OvR approach and macro averaging. It assumes that all the inputs are torch tensors and labels are in [1,K] with K being the number of classes.
ROC_AUC_macro(pred_tensor, label_tensor)ROC_AUC_macro(pred_tensor, label_tensor)
pred_tensor |
output of the model assuming it is of dimension NxK (or Nx1 for binary classification) |
label_tensor |
true labels , tensor of length N |
ROC AUC macro averaged
## Not run: # Small example with 3 classes and 10 samples labels = torch::torch_randint(1, 4, size = 10, dtype = torch::torch_long()) Draw_ROC_curve_micro(torch::torch_randn(c(10, 3)), labels) ## End(Not run)## Not run: # Small example with 3 classes and 10 samples labels = torch::torch_randint(1, 4, size = 10, dtype = torch::torch_long()) Draw_ROC_curve_micro(torch::torch_randn(c(10, 3)), labels) ## End(Not run)
This function computes the multi class ROC AUC using OvR approach and micro averaging. It assumes that all the inputs are torch tensors and labels are in [1,K] with K being the number of classes.
ROC_AUC_micro(pred_tensor, label_tensor)ROC_AUC_micro(pred_tensor, label_tensor)
pred_tensor |
output of the model assuming it is of dimension NxK (or Nx1 for binary classification) |
label_tensor |
true labels , tensor of length N |
ROC AUC macro averaged
## Not run: # Small example with 3 classes and 10 samples labels = torch::torch_randint(1, 4, size = 10, dtype = torch::torch_long()) Draw_ROC_curve_micro(torch::torch_randn(c(10, 3)), labels) ## End(Not run)## Not run: # Small example with 3 classes and 10 samples labels = torch::torch_randint(1, 4, size = 10, dtype = torch::torch_long()) Draw_ROC_curve_micro(torch::torch_randn(c(10, 3)), labels) ## End(Not run)
This function computes the multi class ROC AUM using OvR approach and macro averaging. It assumes that all the inputs are torch tensors and labels are in [1,K] with K being the number of classes.
ROC_AUM_macro(pred_tensor, label_tensor)ROC_AUM_macro(pred_tensor, label_tensor)
pred_tensor |
output of the model assuming it is of dimension NxK (or Nx1 for binary classification) |
label_tensor |
true labels , tensor of length N |
ROC AUM macro averaged
## Not run: # Small example with 3 classes and 10 samples labels = torch::torch_randint(1, 4, size = 10, dtype = torch::torch_long()) Draw_ROC_curve_micro(torch::torch_randn(c(10, 3)), labels) ## End(Not run)## Not run: # Small example with 3 classes and 10 samples labels = torch::torch_randint(1, 4, size = 10, dtype = torch::torch_long()) Draw_ROC_curve_micro(torch::torch_randn(c(10, 3)), labels) ## End(Not run)
This function computes the multi class ROC AUM using OvR approach and micro averaging. It assumes that all the inputs are torch tensors and labels are in [1,K] with K being the number of classes.
ROC_AUM_micro(pred_tensor, label_tensor, counts = NULL)ROC_AUM_micro(pred_tensor, label_tensor, counts = NULL)
pred_tensor |
output of the model assuming it is of dimension NxK (or Nx1 for binary classification) |
label_tensor |
true labels , tensor of length N |
counts |
(optional) the counts of each class , tensor of length K, used to compute weighted ROC AUM micro. |
ROC AUM micro averaged
## Not run: # Small example with 3 classes and 10 samples labels = torch::torch_randint(1, 4, size = 10, dtype = torch::torch_long()) Draw_ROC_curve_micro(torch::torch_randn(c(10, 3)), labels) ## End(Not run)## Not run: # Small example with 3 classes and 10 samples labels = torch::torch_randint(1, 4, size = 10, dtype = torch::torch_long()) Draw_ROC_curve_micro(torch::torch_randn(c(10, 3)), labels) ## End(Not run)