Python - 線性迴歸



線上性迴歸中,這兩個變數透過一個方程相關聯,其中這兩個變數的指數(冪)均為 1。從數學上來說,當繪製成圖表時,線性關係表示一條直線。指數不等於 1 的非線性關係會形成一條曲線。

Seaborn 中用於查詢線性迴歸關係的函式是 regplot。以下示例顯示了它的用法。

import seaborn as sb from matplotlib import pyplot as plt df = sb.load_dataset('tips') sb.regplot(x = "total_bill", y = "tip", data = df) plt.show()

輸出 如下 -

lregression.png
廣告
© . All rights reserved.