What values are being passed in for the estimator parameter when creating a barplot?

Question

In the context of this exercise, what values are we passing in for the estimator parameter when we create a barplot?

Answer

When we use the estimator parameter, we pass in objects that are callable.

Basically, callable objects are like functions, which we can call.

The functions we pass for the estimator parameter must only be functions that can apply to list values.

As a result, we can pass in values like, np.median, and len which are functions that apply to lists. However, we cannot use functions like str or int since these do not apply to lists.

3 Likes

When we use the estimator “len”, what word is it counting the frequency of appearance for?

2 Likes

As I understood it is as follows.

The estimator uses the list in y (from sns.barplot(…)) and groups it
by x:
In this grouping process it counts how many of rows this group has.
So it’s not counting specific words, but the number of rows in each group.

6 Likes

estimator = sum

Plots the Sum of all Observations for a given item

estimator = len

Specifies to use Length (count of observations) as the aggregate statistic.

So can we use a USER DEFINED FUNCTION or a USER DEFINED METHOD in a user defined class with the ESTIMATOR parameter of sns.barplot() ???

Yes.

def my_max(x):
return max(x)

sns.barplot(data=df, x = “Gender”, y=“Response”, estimator=my_max)

image