簡體   English   中英

如何訓練多重回歸 Model 並在 Python 中獲取估計結果?

[英]How to Train Multiple Regression Model and Take Estimation Results in Python?

我有一個 dataframe。 該數據集包含我公司的數據和我的競爭對手的知識。 它看起來像:

Date         a_mine   b_mine  a_comp  b_comp  c_mine  c_comp   
1.01.2020    17.328   6.736   10.592  66.836  3.15    3.15
1.02.2020    16.680   6.522   10.158  64.097  3.46    3.45
1.03.2020    13.616   5.334   8.282   58.554  3.76    3.75
1.04.2020    8.351    3.075   5.276   37.301  3.76    3.75
1.05.2020    13.610   5.837   7.773   54.955  3.76    3.76
1.06.2020    14.361   5.875   8.486   59.996  3.79    3.80


a_mine: Net sales of my company
a_comp: Net sales of competitors
b_mine: bonus sales of my company
b_comp: bonus sales of competitors
c_mine: unit price of my product
c_comp: unit price of competitors product

我想找到獎金對凈銷售額的影響,最后,我想創建一個這樣的結果表(示例結果):

Component  Parameter  Estimate  Standart_error  t_value  Approx Pr>|t|
a_mine     constant   485052.1  22517.1         21.58    < 0001
b_mine     scale      1.15365   0.12745         9.07     < 0001

我試圖用多元線性回歸訓練我的 model。 但我不能為此成功。

如何訓練我的 model 並在 python 中獲得此結果?

您始終可以使用statsmodelsOLS回歸,它有一個.summary()方法可以返回您需要的表:

Y = df.a_mine
X = df[["b_mine", "c_mine"]]

model = sm.OLS(Y, X)
results = model.fit()

results.summary()

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM