groupby_apply#
- pytorch_forecasting.utils._utils.groupby_apply(keys: Tensor, values: Tensor, bins: int = 95, reduction: str = 'mean', return_histogram: bool = False) Tensor | Tuple[Tensor, Tensor] [source]#
Groupby apply for torch tensors
- Parameters:
keys – tensor of groups (
0
tobins
)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
- Returns:
tensor of size
bins
with aggregated values and optionally with counts of values