Search code examples
pythonseabornlinear-regression

How to Extract Linear Model Parameters from Seaborn lmplot()?


Is there a way to extract the parameters of the regression line(s) that seaborn.lmplot() fits for a given set of data? I have looked up the documentation and haven't been able to spot anything that would help me in this regard.

Just to be clear, I don't mean the lmplot()'s function parameters, but the m,
and b of y = mx + b.


Solution

  • seaborn uses scipy stats linregress, so you could get it directly from there.

    from scipy import stats
    slope, intercept, r_value, p_value, std_err = stats.linregress(df.x,df.y)