Computes the (weighted) sum of the given values

metric_sum(..., name = NULL, dtype = NULL)

Arguments

...

Passed on to the underlying metric. Used for forwards and backwards compatibility.

name

(Optional) string name of the metric instance.

dtype

(Optional) data type of the metric result.

Value

A (subclassed) Metric instance that can be passed directly to compile(metrics = ), or used as a standalone object. See ?Metric for example usage.

Details

For example, if values is c(1, 3, 5, 7) then the sum is 16. If the weights were specified as c(1, 1, 0, 0) then the sum would be 4.

This metric creates one variable, total, that is used to compute the sum of values. This is ultimately returned as sum.

If sample_weight is NULL, weights default to 1. Use sample_weight of 0 to mask values.

See also