Beispiel #1
0
    def compute(self) -> Union[Tuple[Tensor, Tensor, Tensor], Tuple[List[Tensor], List[Tensor], List[Tensor]]]:
        """Compute the receiver operating characteristic.

        Returns:
            3-element tuple containing

            fpr:
                tensor with false positive rates.
                If multiclass, this is a list of such tensors, one for each class.
            tpr:
                tensor with true positive rates.
                If multiclass, this is a list of such tensors, one for each class.
            thresholds:
                thresholds used for computing false- and true postive rates
        """
        preds = torch.cat(self.preds, dim=0)
        target = torch.cat(self.target, dim=0)
        if not self.num_classes:
            raise ValueError(f"`num_classes` bas to be positive number, but got {self.num_classes}")
        return _roc_compute(preds, target, self.num_classes, self.pos_label)
Beispiel #2
0
    def compute(
        self
    ) -> Union[Tuple[torch.Tensor, torch.Tensor, torch.Tensor], Tuple[
            List[torch.Tensor], List[torch.Tensor], List[torch.Tensor]]]:
        """
        Compute the receiver operating characteristic

        Returns: 3-element tuple containing

            fpr:
                tensor with false positive rates.
                If multiclass, this is a list of such tensors, one for each class.
            tpr:
                tensor with true positive rates.
                If multiclass, this is a list of such tensors, one for each class.
            thresholds:
                thresholds used for computing false- and true postive rates

        """
        preds = torch.cat(self.preds, dim=0)
        target = torch.cat(self.target, dim=0)
        return _roc_compute(preds, target, self.num_classes, self.pos_label)