กราฟ Regression ใน Seaborn

การสร้างภาพข้อมูลระดับกลางด้วย Seaborn

Chris Moffitt

Instructor

แนะนำ regplot

  • ฟังก์ชัน regplot สร้าง scatter plot พร้อมเส้น regression
  • ใช้งานคล้ายกับ displot
  • ต้องกำหนด data, x และ y
sns.regplot(data=df, x="alcohol", y="pH" )

Scatter plot

การสร้างภาพข้อมูลระดับกลางด้วย Seaborn

lmplot() สร้างต่อยอดจาก regplot()

  • regplot - ระดับล่าง
sns.regplot(data=df,
            x="alcohol",
            y="quality")

กราฟคุณภาพไวน์

  • lmplot - ระดับสูง
sns.lmplot(data=df, 
           x="alcohol",
           y="quality")

กราฟคุณภาพไวน์

การสร้างภาพข้อมูลระดับกลางด้วย Seaborn

การแบ่ง facet ด้วย lmplot

  • จัดกลุ่มข้อมูลด้วยสี (hue)
sns.lmplot(data=df, 
           x="quality",
           y="alcohol",
           hue="type")

กราฟคุณภาพไวน์แยกตามสี

  • จัดกลุ่มข้อมูลด้วยคอลัมน์ (col)
sns.lmplot(data=df, 
           x="quality",
           y="alcohol",
           col="type")

กราฟคุณภาพไวน์แยกตามคอลัมน์

การสร้างภาพข้อมูลระดับกลางด้วย Seaborn

มาฝึกกันเถอะ!

การสร้างภาพข้อมูลระดับกลางด้วย Seaborn

Preparing Video For Download...