看板 Python 關於我們 聯絡資訊
給定兩個相同長度的list,分別代表x與y的座標,請問我該怎麼用python去計算他的線性回歸方程式y=mx+b 呢? ----- Sent from JPTT on my Samsung SM-G930F. -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.171.235.208 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1593085331.A.3F5.html
DavisX: 是有已知方程式要求參數是嗎? 如是可用lmfit套件 06/25 20:06
hsnuyi: 高中課本拿出來 直接套公式 06/25 20:19
Pieteacher: (X’X)^-1 X’y 06/25 21:00
aredfish: 是有一堆點想找趨近的方程式 06/25 21:55
aredfish: lmfit我研究看看 06/25 21:55
papple23g: sklearn.linear_model.LinearRegression 或 scipy.opti 06/25 22:32
papple23g: mize.curve_fit 後者可以自訂擬合函數 06/25 22:32
martin7887: mse 和 gradient decent 06/26 00:08
aredfish: 感謝樓上兩位建議 06/26 09:42
yuasa: statsmodels的OLS(或類似方式)。也可以直接得到你要的m跟b 06/26 15:37
aredfish: OLS看來很方便耶,感謝 06/26 17:07
kokolotl: 推三樓 06/27 14:26