Great Video!! I have a question. In your lmplots, what does the blue area around the regression line represent? In lmplot I get for the data I have doesn't fit in between two straight lines, instead, it is an area enclosed between two curvy lines.
"confidence is done by bootstrap sample with replacement compute the linreg draw it on the graph do it 100 times 95% band of confidence based on that" robust de-weights points that are far away
Hey Nathaniel great videos! I'm pretty new to Python so I'm still figuring a bunch of stuff out....but is there a way to display the R-square and equation of the regression line?
Great question, the answer is totally yes, it just depends how much customization you want to do (as in it does not fit perfectly within the seaborn toolkit). If you head over here: seaborn.pydata.org/generated/seaborn.JointGrid.html#seaborn.JointGrid And you search "Use a custom function and formatting for the annotation", you should find an example of almost what you are looking for. I then made a few tweaks and came up with this code: g = sns.JointGrid(x="total_bill", y="tip", data=tips) g = g.plot_joint(sns.regplot) g.ax_marg_x.set_axis_off() g.ax_marg_y.set_axis_off() rsquare = lambda a, b: stats.pearsonr(a, b)[0] ** 2 g.annotate(rsquare, template="{stat}: {val:.2f}", stat="$R^2$", fontsize=12) Unfortunately I don't think there is an easier way to do it :( For the equation of the line you can use this: coefs = lambda x, y: stats.linregress(x,y)[:2] g.annotate(coefs, template="{stat} = {val:.2f}x + {p:.2g}", stat="y", fontsize=12)
No ways, that actually worked! Where can I get the documentation for the last part regarding the equation so that I can try to make sense of how you got to that? Thanks again for the help!
Glad it helped! You can check out the documentation here: github.com/mwaskom/seaborn/blob/master/seaborn/axisgrid.py#L1771 As always please do subscribe to my channel and twitter (twitter.com/knatetucker) if you are interested in workshops in the Bay Area (sorry about the plug :)
Thanks for the video! It is really amazing!
Thank you this was very helpful
Things I learned from this lecture:
Regression(Linear model) Plots-1
*sns.lmplot()
Great Video!! I have a question. In your lmplots, what does the blue area around the regression line represent? In lmplot I get for the data I have doesn't fit in between two straight lines, instead, it is an area enclosed between two curvy lines.
That is a confidence interval of the regression using bootstrap sampling!
"confidence is done by bootstrap
sample with replacement
compute the linreg
draw it on the graph
do it 100 times
95% band of confidence based on that"
robust de-weights points that are far away
Hey Nathaniel great videos! I'm pretty new to Python so I'm still figuring a bunch of stuff out....but is there a way to display the R-square and equation of the regression line?
Great question, the answer is totally yes, it just depends how much customization you want to do (as in it does not fit perfectly within the seaborn toolkit).
If you head over here:
seaborn.pydata.org/generated/seaborn.JointGrid.html#seaborn.JointGrid
And you search "Use a custom function and formatting for the annotation", you should find an example of almost what you are looking for. I then made a few tweaks and came up with this code:
g = sns.JointGrid(x="total_bill", y="tip", data=tips)
g = g.plot_joint(sns.regplot)
g.ax_marg_x.set_axis_off()
g.ax_marg_y.set_axis_off()
rsquare = lambda a, b: stats.pearsonr(a, b)[0] ** 2
g.annotate(rsquare, template="{stat}: {val:.2f}",
stat="$R^2$", fontsize=12)
Unfortunately I don't think there is an easier way to do it :(
For the equation of the line you can use this:
coefs = lambda x, y: stats.linregress(x,y)[:2]
g.annotate(coefs, template="{stat} = {val:.2f}x + {p:.2g}",
stat="y", fontsize=12)
No ways, that actually worked! Where can I get the documentation for the last part regarding the equation so that I can try to make sense of how you got to that? Thanks again for the help!
Glad it helped!
You can check out the documentation here:
github.com/mwaskom/seaborn/blob/master/seaborn/axisgrid.py#L1771
As always please do subscribe to my channel and twitter (twitter.com/knatetucker) if you are interested in workshops in the Bay Area (sorry about the plug :)