pytorch_forecasting.utils.groupby_apply(keys: Tensor, values: Tensor, bins: int = 95, reduction: str = 'mean', return_histogram: bool = False) Union[Tensor, Tuple[Tensor, Tensor]][source]#

Groupby apply for torch tensors

  • keys – tensor of groups (0 to bins)

  • values – values to aggregate - same size as keys

  • bins – total number of groups

  • reduction – either “mean” or “sum”

  • return_histogram – if to return histogram on top


tensor of size bins with aggregated values and optionally with counts of values