作者aredfish (一切都是假的)
看板Python
标题请问如何计算回归方程式
时间Thu Jun 25 19:42:09 2020
给定两个相同长度的list,分别代表x与y的座标,请问我该怎麽用python去计算他的线性回归方程式y=mx+b 呢?
-----
Sent from JPTT on my Samsung SM-G930F.
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 118.171.235.208 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1593085331.A.3F5.html
1F:→ DavisX: 是有已知方程式要求参数是吗? 如是可用lmfit套件 06/25 20:06
2F:→ hsnuyi: 高中课本拿出来 直接套公式 06/25 20:19
3F:→ Pieteacher: (X’X)^-1 X’y 06/25 21:00
4F:→ aredfish: 是有一堆点想找趋近的方程式 06/25 21:55
5F:→ aredfish: lmfit我研究看看 06/25 21:55
6F:→ papple23g: sklearn.linear_model.LinearRegression 或 scipy.opti 06/25 22:32
7F:→ papple23g: mize.curve_fit 後者可以自订拟合函数 06/25 22:32
8F:推 martin7887: mse 和 gradient decent 06/26 00:08
9F:→ aredfish: 感谢楼上两位建议 06/26 09:42
10F:推 yuasa: statsmodels的OLS(或类似方式)。也可以直接得到你要的m跟b 06/26 15:37
12F:→ aredfish: OLS看来很方便耶,感谢 06/26 17:07
13F:推 kokolotl: 推三楼 06/27 14:26