Python Data Science 简明教程
Python - Linear Regression
在线性回归中,这两个变量通过一个方程相关联,其中这两个变量的指数(幂)为 1。在数学上,当作为图形绘制时,线性关系表示一条直线。任何变量的指数不等于 1 的非线性关系会形成一条曲线。
In Linear Regression these two variables are related through an equation, where exponent (power) of both these variables is 1. Mathematically a linear relationship represents a straight line when plotted as a graph. A non-linear relationship where the exponent of any variable is not equal to 1 creates a curve.
Seaborn 中用于查找线性回归关系的函数是 regplot。以下示例显示了它的用法。
The functions in Seaborn to find the linear regression relationship is regplot. The below example shows its use.
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()
它的 output 如下所示 −
Its output is as follows −