Typically `y_pred` and `y` are stored in the cumulative buffers at each iteration, This function reads the buffers and computes the Average Precision. Args: average: {``"macro"``, ``"weighted"``, ``"micro"``, ``"none"``} Type of averaging perform
(self, average: Average | str | None = None)
| 66 | return y_pred, y |
| 67 | |
| 68 | def aggregate(self, average: Average | str | None = None) -> np.ndarray | float | npt.ArrayLike: |
| 69 | """ |
| 70 | Typically `y_pred` and `y` are stored in the cumulative buffers at each iteration, |
| 71 | This function reads the buffers and computes the Average Precision. |
| 72 | |
| 73 | Args: |
| 74 | average: {``"macro"``, ``"weighted"``, ``"micro"``, ``"none"``} |
| 75 | Type of averaging performed if not binary classification. Defaults to `self.average`. |
| 76 | |
| 77 | """ |
| 78 | y_pred, y = self.get_buffer() |
| 79 | # compute final value and do metric reduction |
| 80 | if not isinstance(y_pred, torch.Tensor) or not isinstance(y, torch.Tensor): |
| 81 | raise ValueError("y_pred and y must be PyTorch Tensor.") |
| 82 | |
| 83 | return compute_average_precision(y_pred=y_pred, y=y, average=average or self.average) |
| 84 | |
| 85 | |
| 86 | def _calculate(y_pred: torch.Tensor, y: torch.Tensor) -> float: |