groupby_apply¶
- pytorch_forecasting.utils.groupby_apply(keys: torch.Tensor, values: torch.Tensor, bins: int = 95, reduction: str = 'mean', return_histogram: bool = False) Union[torch.Tensor, Tuple[torch.Tensor, torch.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