neuraxle.metrics

Neuraxle’s metrics classes

The neuraxle classes to track metrics results.

Classes

MetricsWrapper(wrapped, metrics, VT], name)

Add metrics calculation to a step.

class neuraxle.metrics.MetricsWrapper(wrapped: neuraxle.base.BaseStep, metrics: Dict[KT, VT], name: str = None, print_metrics=False, print_fun=<built-in function print>)[source]

Add metrics calculation to a step. Calculates metrics after each fit, fit_transform, or even transform if there is an expected outputs.

Example usage :

wrapped = MetricsWrapper(wrapped=wrapped, metrics=self.batch_metrics, name=BATCH_METRICS_STEP_NAME)
wrapped = MiniBatchSequentialPipeline(
    [wrapped],
    batch_size=self.batch_size,
    enabled=True
)

# toggle metrics on, and off
wrapped.apply('toggle_metrics')
_abc_impl = <_abc_data object>
_calculate_metrics_results(data_container: neuraxle.data_container.DataContainer)[source]

Calculate metrics results using the transformed data container, and the metrics function dict.

Parameters

data_container (DataContainer) – transformed data container

Returns

_did_fit_transform(data_container: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext) → neuraxle.data_container.DataContainer[source]

Apply side effects after fit transform.

Parameters
  • data_container – data container

  • context – execution context

Returns

(fitted self, data container)

_did_fit_transform_or_transform(data_container: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext)[source]

Calculate metrics results after fit, or transform if there is an expected outputs in the data container. Also, calculate validation metrics if there is a sub data container named validation in the data container. Please refer to DataContainer for more information about sub data containers.

Parameters

data_container (DataContainer) – data container to calculate metrics for

Returns

data container

Return type

DataContainer

_did_transform(data_container: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext) → neuraxle.data_container.DataContainer[source]

Apply side effects after transform.

Parameters
  • data_container – data container

  • context – execution context

Returns

data container

_initialize_metrics(metrics)[source]

Initialize metrics results dict for train, and validation using the metrics function dict.

Parameters

metrics (dict) – metrics function dict

Returns

disable_metrics()[source]

Disable metrics wrapper metrics if needed..

Returns

enable_metrics()[source]

Enable metrics wrapper metrics if needed..

Returns

get_metrics() → neuraxle.hyperparams.space.RecursiveDict[source]

Get all metrics results using the transformed data container, and the metrics function dict. To be used with neuraxle.base.BaseStep.apply() method.

Returns

dict with the step name as key, and all of the training, and validation metrics as values

toggle_metrics() → neuraxle.hyperparams.space.RecursiveDict[source]

Toggle metrics wrapper on and off to temporarily disable metrics if needed..

Returns