mindspore.nn.F1
- class mindspore.nn.F1[source]
Calculates the F1 score. F1 is a special case of Fbeta when beta is 1. Refer to class
mindspore.nn.Fbeta
for more details.\[F_1=\frac{2\cdot true\_positive}{2\cdot true\_positive + false\_negative + false\_positive}\]Examples
>>> x = Tensor(np.array([[0.2, 0.5], [0.3, 0.1], [0.9, 0.6]])) >>> y = Tensor(np.array([1, 0, 1])) >>> metric = nn.F1() >>> metric.update(x, y) >>> result = metric.eval() >>> print(result) [0.66666667 0.66666667]