accuracy#
- mvpy.math.accuracy(x: ndarray | Tensor, y: ndarray | Tensor) ndarray | Tensor[source]#
Compute accuracy between x and y. Note that accuracy is always computed over the final dimension.
- Parameters:
- xUnion[np.ndarray, torch.Tensor]
Vector/Matrix/Tensor
- yUnion[np.ndarray, torch.Tensor]
Vector/Matrix/Tensor
- Returns:
- Union[np.ndarray, torch.Tensor]
Accuracy
Notes
Accuracy is defined as:
\[\text{accuracy}(x, y) = \frac{1}{N}\sum_i^N{1(x_i = y_i)}\]Examples
>>> import torch >>> from mvpy.math import accuracy >>> x = torch.tensor([1, 0]) >>> y = torch.tensor([-1, 0]) >>> accuracy(x, y) tensor([0.5])