aeon icon indicating copy to clipboard operation
aeon copied to clipboard

[ENH] Add `weights` parameter to `elastic_barycenter_average`

Open hadifawaz1999 opened this issue 11 months ago • 1 comments

Describe the feature or idea you want to propose

Basically until now, we compute the barycenter average supposing a uniform weight distribution for all series in the batch. I would like to assume this by default, and give control over the weights in the parameters of the elastic_barycenter_average function.

Describe your proposed solution

Basically, weights should be an array-like object containing a weight, between 0 and 1, with the same shape as len(X) (the number of input series). If weights is set to None (default), then the function will generate a default uniformly distributed weights between 0 and 1, on all series (i.e. weights[i] = 1/len(X)). This should then replace this part of the code inside _ba_update:

            alignment[:, k] += curr_ts[:, j]
            sum[k] += 1
            cost += squared_distance(curr_ts[:, j], center[:, k])

    return alignment / sum, cost / X_timepoints

with a weighted average

Describe alternatives you've considered, if relevant

No response

Additional context

This issue is assigned to Maxime Devanne

hadifawaz1999 avatar Feb 26 '24 08:02 hadifawaz1999

great idea

TonyBagnall avatar Feb 27 '24 13:02 TonyBagnall