Add support for weights in objects.Est #3580
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR enhances
seaborn.objects.Est
to support a weighted mean, with confidence intervals:(I don't know that this plot makes any particular sense, but it demonstrates how you'd use it...)
It is using
np.average
under the hood.Currently support is limited to
func="mean", errorbar=("ci", ...)
. There may be other estimators / error bar methods were it makes sense to compute a weighted version (e.g. weighted median/percentiles) although we would need to implement those in seaborn as I don't believe there's an implementation in our dependencies. I think this is fine and probably satisfies the majority of use cases; we can expand support later if there's enough interest.(As a side note, we should probably error when
func != "mean"
anderrorbar=("se", ...)
since we don't generically compute the parameteric standard error of whatever estimator is passed).See previous discussion in #3563, which is about the function interface. I actually think that it will be relatively straightforward to add first-class support in the function interface too on top of these changes. I might follow up here or maybe do that in another PR...