python-3.xnumpyseaborn

What estimators does seaborn support


Seaborn allows the user to input "estimator" variable in its various plots, for example: https://seaborn.pydata.org/generated/seaborn.catplot.html

I understand that the estimator should be a function of "vector" to "scalar" i.e. "mean" takes vector to and outputs a scalar (it's average value).

So far, I found "mean" and "sum" to be valid estimators, while "median" is not. Are there any other?


Solution

  • Many numpy functions can be used directly, for example np.median. mean is supported as np.mean. len, sum, max and min are built-in python functions and work without being imported from a library.

    You can also provide your own function. For example estimator=lambda x: sum(xi*xi for xi in x). Or lambda x: np.percentile(x, 95).

    Further note that many seaborn functions draw a confidence interval, calculated via "bootstrapping", which doesn't play well with all functions. You can set errorbar=None (in versions before 0.13: ci=None) to suppress the confidence interval.