classifier

The classification metrics.

Classes

ClassifierLoss A handy way to measure the classification loss.
ClassifierMetric Wrap a metric using argmax to extract predictions out of a classifier’s output.
class ashpy.metrics.classifier.ClassifierLoss(name='loss', model_selection_operator=None, logdir=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/master/docs/source/log'))[source]

Bases: ashpy.metrics.metric.Metric

A handy way to measure the classification loss.

__init__(name='loss', model_selection_operator=None, logdir=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/master/docs/source/log'))[source]

Initialize the Metric.

Parameters:
  • name (str) – Name of the metric.
  • model_selection_operator (typing.Callable) –

    The operation that will be used when model_selection is triggered to compare the metrics, used by the update_state. Any typing.Callable behaving like an operator is accepted.

    Note

    Model selection is done ONLY if an operator is specified here.

  • logdir (str) – Path to the log dir, defaults to a log folder in the current directory.
Return type:

None

update_state(context)[source]

Update the internal state of the metric, using the information from the context object.

Parameters:context (ashpy.contexts.ClassifierContext) – An AshPy Context holding all the information the Metric needs.
Return type:None
class ashpy.metrics.classifier.ClassifierMetric(metric, model_selection_operator=None, logdir=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/master/docs/source/log'), processing_predictions=None)[source]

Bases: ashpy.metrics.metric.Metric

Wrap a metric using argmax to extract predictions out of a classifier’s output.

__init__(metric, model_selection_operator=None, logdir=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/ashpy/checkouts/master/docs/source/log'), processing_predictions=None)[source]

Initialize the Metric.

Parameters:
  • metric (tf.keras.metrics.Metric) – The Keras Metric to use with the classifier (e.g.: Accuracy()).
  • model_selection_operator (typing.Callable) –

    The operation that will be used when model_selection is triggered to compare the metrics, used by the update_state. Any typing.Callable behaving like an operator is accepted.

    Note

    Model selection is done ONLY if an model_selection_operator is specified here.

  • logdir (str) – Path to the log dir, defaults to a log folder in the current directory.
  • processing_predictions (typing.Dict) – A dict in the form of {“fn”: tf.argmax, “kwargs”: {“axis”: -1}} with a function “fn” to be used for predictions processing purposes and its “kwargs” as its keyword-arguments. Defaults to {“fn”: tf.argmax, “kwargs”: {“axis”: -1}}.
Return type:

None

update_state(context)[source]

Update the internal state of the metric, using the information from the context object.

Parameters:context (ashpy.contexts.ClassifierContext) – An AshPy Context holding all the information the Metric needs.
Return type:None