deephyper.ensemble.aggregator.ModeAggregator

deephyper.ensemble.aggregator.ModeAggregator#

class deephyper.ensemble.aggregator.ModeAggregator(with_uncertainty: bool = False)[source]#

Bases: Aggregator

Aggregate predictions using the mode of categorical distributions from predictors.

Array (Fixed Set)

MaskedArray

This aggregator is useful when the ensemble is composed of predictors that output categorical distributions. The mode of the ensemble is the mode of the modes of the predictors, minimizing the 0-1 loss.

Parameters:
  • with_uncertainty (bool, optional) – a boolean that sets if the uncertainty should be

  • False. (returned when calling the aggregator. Defaults to)

Methods

aggregate

Aggregate predictions using the mode of categorical distributions.

aggregate(y: List[ndarray | MaskedArray], weights: List[float] | None = None) ndarray | MaskedArray | Dict[str, ndarray | MaskedArray][source]#

Aggregate predictions using the mode of categorical distributions.

Parameters:
  • y (List[Union[np.ndarray, np.ma.MaskedArray]]) – List of categorical probability arrays of shape (n_predictors, n_samples, ..., n_classes).

  • weights (Optional[List[float]]) – Weights for the predictors. Default is None.

Returns:

Union[Union[np.ndarray, np.ma.MaskedArray], Dict[str, Union[np.ndarray, np.ma.MaskedArray]]]: Aggregated results, as an array corresponding to the mode when with_uncertainty=False and as a dict otherwise including:

  • "loc": Aggregated mode of shape (n_samples, ...).

  • "uncertainty": Uncertainty values of shape (n_samples, ...) `.

Raises:

ValueError – If y dimensions are invalid or if weights length does not match y.