Lmplot - Seaborn

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ธ.ค. 2024

ความคิดเห็น • 10

  • @TheApoorvagni
    @TheApoorvagni 5 ปีที่แล้ว

    Thanks for the video! It is really amazing!

  • @funny_vid3513
    @funny_vid3513 4 ปีที่แล้ว

    Thank you this was very helpful

  • @arhataria
    @arhataria 4 ปีที่แล้ว

    Things I learned from this lecture:
    Regression(Linear model) Plots-1
    *sns.lmplot()

  • @HardLessonsOfLife
    @HardLessonsOfLife 4 ปีที่แล้ว

    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.

    • @DataTalks
      @DataTalks  4 ปีที่แล้ว

      That is a confidence interval of the regression using bootstrap sampling!

  • @rashmimahadevaiah8321
    @rashmimahadevaiah8321 3 ปีที่แล้ว

    "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

  • @markremark
    @markremark 7 ปีที่แล้ว +1

    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?

    • @DataTalks
      @DataTalks  7 ปีที่แล้ว

      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)

    • @markremark
      @markremark 7 ปีที่แล้ว

      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!

    • @DataTalks
      @DataTalks  7 ปีที่แล้ว +1

      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 :)