Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Add weights parameter to elastic_barycenter_average #1251

Closed
hadifawaz1999 opened this issue Feb 26, 2024 · 1 comment
Closed

[ENH] Add weights parameter to elastic_barycenter_average #1251

hadifawaz1999 opened this issue Feb 26, 2024 · 1 comment
Labels
distances Distances package enhancement New feature, improvement request or other non-bug code enhancement

Comments

@hadifawaz1999
Copy link
Contributor

hadifawaz1999 commented Feb 26, 2024

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 hadifawaz1999 added enhancement New feature, improvement request or other non-bug code enhancement distances Distances package averaging labels Feb 26, 2024
@TonyBagnall
Copy link
Contributor

great idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
distances Distances package enhancement New feature, improvement request or other non-bug code enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants