Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do the lines in Seaborn.Regplot represent

Tags:

python

seaborn

I was curious as to what the highlighted lines represent in seaborn.regplot. I haven't been able to find the answer in the documentation.

Thanks

enter image description here

like image 406
bugsyb Avatar asked Aug 05 '17 19:08

bugsyb


1 Answers

The solid line is evidently the linear regression model fit.

The translucent band lines, however, describe a bootstrap confidence interval generated for the estimate. From the docs we can see this in the parameter info for ci:

(emphasis mine)

ci : int in [0, 100] or None, optional

Size of the confidence interval for the regression estimate. This will be drawn using translucent bands around the regression line. The confidence interval is estimated using a bootstrap; for large datasets, it may be advisable to avoid that computation by setting this parameter to None.

So if you don't want the overhead of performing a bootstrap to get these CI bands, just pass ci=None.


Example

import seaborn as sns
import matplotlib.pyplot as plt

sns.set_palette(sns.cubehelix_palette(8, light=.6))

tips = sns.load_dataset('tips')
x = 'total_bill'
y = 'tip'
cis = [None, 67, 99]
titles = ['No CI', '67% CI', '99% CI']

fig, axes = plt.subplots(nrows=3, sharey=True, sharex=True, figsize=(7, 10))

for ci, title, ax in zip(cis, titles, axes):
    sns.regplot(x    = x,
                y    = y,
                data = tips,
                ax   = ax,
                ci   = ci).set_title(title)

plt.tight_layout()
plt.show()

CI examples

like image 108
miradulo Avatar answered Oct 19 '22 10:10

miradulo