Table Of Contents
Table Of Contents

Accuracy

class mxnet.metric.Accuracy(axis=1, name='accuracy', output_names=None, label_names=None)[source]

Computes accuracy classification score.

The accuracy score is defined as

\[\text{accuracy}(y, \hat{y}) = \frac{1}{n} \sum_{i=0}^{n-1} \text{1}(\hat{y_i} == y_i)\]
Parameters:
  • axis (int, default=1) – The axis that represents classes
  • name (str) – Name of this metric instance for display.
  • output_names (list of str, or None) – Name of predictions that should be used when updating with update_dict. By default include all predictions.
  • label_names (list of str, or None) – Name of labels that should be used when updating with update_dict. By default include all labels.

Examples

>>> predicts = [mx.nd.array([[0.3, 0.7], [0, 1.], [0.4, 0.6]])]
>>> labels   = [mx.nd.array([0, 1, 1])]
>>> acc = mx.metric.Accuracy()
>>> acc.update(preds = predicts, labels = labels)
>>> print acc.get()
('accuracy', 0.6666666666666666)
__init__(axis=1, name='accuracy', output_names=None, label_names=None)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__([axis, name, output_names, label_names]) Initialize self.
get() Gets the current evaluation result.
get_config() Save configurations of metric.
get_name_value() Returns zipped name and value pairs.
reset() Resets the internal evaluation result to initial state.
update(labels, preds) Updates the internal evaluation result.
update_dict(label, pred) Update the internal evaluation with named label and pred