deepmd.utils.weight_avg#

Functions#

merge_weighted_errors(→ dict[str, tuple[float, float]])

Combine prediction errors, keeping the weight they were combined over.

weighted_average(→ dict)

Compute weighted average of prediction errors (MAE or RMSE) for model.

Module Contents#

deepmd.utils.weight_avg.merge_weighted_errors(errors: list[dict[str, tuple[float, float]]]) → dict[str, tuple[float, float]][source]#

Combine prediction errors, keeping the weight they were combined over.

An MAE is the mean of the absolute errors and an RMSE the root of the mean of their squares, so both are recovered exactly from the partial results by weighting the mean, respectively the squared mean, by the number of elements each was taken over. Combining partial results is therefore equivalent to evaluating the whole set at once, which lets a caller evaluate in chunks.

Parameters:
errorslist[dict[str, tuple[float, float]]]

One {quantity: (error, weight)} mapping per partial result. A quantity name starts with mae or rmse.

Returns:
dict[str, tuple[float, float]]

The combined (error, weight) of every quantity, itself suitable as one partial result of a further combination.

Raises:
RuntimeError

If a quantity name identifies neither an MAE nor an RMSE.

deepmd.utils.weight_avg.weighted_average(errors: list[dict[str, tuple[float, float]]]) → dict[source]#

Compute weighted average of prediction errors (MAE or RMSE) for model.

Parameters:
errorslist[dict[str, tuple[float, float]]]

List: the error of systems Dict: the error of quantities, name given by the key str: the name of the quantity, must starts with ‘mae’ or ‘rmse’ Tuple: (error, weight)

Returns:
Dict

weighted averages