Python-线性回归

时间:2019-01-30 13:04:03

标签: python matplotlib linear-regression

我正在尝试对以下数据集的GDP和Count列之间进行线性回归:

enter image description here

这是我的代码:

CT = slav_df.iloc[:, 4]
GDP = slav_df.iloc[:,3]
t_slope, t_int, t_r, t_p, t_std_err = 
stats.linregress(GDP, CT)
talent_fit = t_slope * CT + t_int

#plotting 
fig, (ax1) = plt.subplots(1, sharex=True)
fig.suptitle(" ", fontsize=16, fontweight="bold")
ax1.set_xlim(min(CT), max(CT))
ax1.plot(GDP, CT, linewidth=1, marker="o")
ax1.plot(GDP, talent_fit, "b--", linewidth=1)
ax1.set_ylabel(" ")

运行此命令时,会得到如下图:

enter image description here

这似乎不正确,我想知道我在这里做错了什么吗?

0 个答案:

没有答案