deephyper.ensemble.aggregator.utils.average

Contents

deephyper.ensemble.aggregator.utils.average#

deephyper.ensemble.aggregator.utils.average(x: ndarray | MaskedArray, axis: int | None = None, weights: Sequence[float] | None = None) ndarray | MaskedArray[source]#

Compute the weighted average of an array, supporting both NumPy arrays and masked arrays.

Parameters:
  • x (np.ndarray | np.ma.MaskedArray) – Input array or masked array.

  • axis (int, optional) – Axis along which to compute the average. Defaults to None.

  • weights (Sequence[float], optional) – Weights to apply. Defaults to None.

Returns:

Weighted average of the input array.

Return type:

np.ndarray | np.ma.MaskedArray

Raises:

TypeError – If x is not a NumPy array or masked array.