Table Of Contents
Table Of Contents

CompositeEvalMetric

class mxnet.metric.CompositeEvalMetric(metrics=None, name='composite', output_names=None, label_names=None)[source]

Manages multiple evaluation metrics.

Parameters:
  • metrics (list of EvalMetric) – List of child metrics.
  • 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])]
>>> eval_metrics_1 = mx.metric.Accuracy()
>>> eval_metrics_2 = mx.metric.F1()
>>> eval_metrics = mx.metric.CompositeEvalMetric()
>>> for child_metric in [eval_metrics_1, eval_metrics_2]:
>>>     eval_metrics.add(child_metric)
>>> eval_metrics.update(labels = labels, preds = predicts)
>>> print eval_metrics.get()
(['accuracy', 'f1'], [0.6666666666666666, 0.8])
__init__(metrics=None, name='composite', output_names=None, label_names=None)[source]

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

Methods

__init__([metrics, name, output_names, …]) Initialize self.
add(metric) Adds a child metric.
get() Returns the current evaluation result.
get_config() Save configurations of metric.
get_metric(index) Returns a child 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(labels, preds) Update the internal evaluation with named label and pred