作者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/m.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