Skip to content

statistics.mae

Import path: earth2studio.statistics.mae

View source on GitHub

Documentation

Bases: rmse

Statistic for calculating the mean absolute error of two tensors over a set of given dimensions.

Parameters:

  • reduction_dimensions (list[str]) –

    A list of names corresponding to dimensions to perform the statistical reduction over. Example: ['lat', 'lon']

  • weights (Tensor | None, default: None ) –

    A tensor containing weights to assign to the reduction dimensions. Note that these weights must have the same number of dimensions as passed in reduction_dimensions. Example: if reduction_dimensions = ['lat', 'lon'] then assert weights.ndim == 2.

  • batch_update (bool, default: False ) –

    Whether to apply batch updates to the rmse with each invocation of call. This is particularly useful when data is received in a stream of batches. Each invocation of call will return the running rmse. In particular, it will apply the square root operation after calculating the running mean squared error.

  • ensemble_dimension (str | None, default: None ) –

    Compute ensemble mean over this dimension before computing MAE. If None (default), no reduction is performed.

__call__

__call__(
    x: Tensor,
    x_coords: CoordSystem,
    y: Tensor,
    y_coords: CoordSystem,
) -> tuple[Tensor, CoordSystem]

Apply metric to data x and y, checking that their coordinates are broadcastable. While reducing over reduction_dims.

If batch_update was passed True upon metric initialization then this method returns the running sample MAE over all seen batches.

Parameters:

  • x (Tensor) –

    Input tensor, typically the forecast or prediction tensor, but MAE is symmetric with respect to x and y.

  • x_coords (CoordSystem) –

    Ordered dict representing coordinate system that describes the x tensor. reduction_dimensions must be in coords.

  • y (Tensor) –

    Input tensor #2 intended to be used as validation data, but MAE is symmetric with respect to x and y.

  • y_coords (CoordSystem) –

    Ordered dict representing coordinate system that describes the y tensor. reduction_dimensions must be in coords.

Returns:

  • tuple[Tensor, CoordSystem] –

    Returns root mean squared error tensor with appropriate reduced coordinates.