[英]How to train a Regression model for single input and multiple output?
[英]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 中获得此结果?
您始终可以使用statsmodels
的OLS
回归,它有一个.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.