正确性Scikit学习的MLR?

问题描述 投票:1回答:1

您好我有scikit学习包MLR(linear_model.LinearRegression)正确性的问题。在所有情况下,相同的数据被使用和不拦截建

Python代码:

data = np.loadtxt(fname=file, delimiter='\t')
X = data[:, 1:]
Y = data[:, 1]
mlr = LinearRegression(fit_intercept=False)
mlr.fit(X,Y)
print(mlr.coef_)

1.00000000e+00  6.20460347e-17 -1.82373860e-17  3.35782591e-19
7.92128777e-17 -1.04990677e-17 -1.15961796e-16  1.33629653e-15

R:

Y = data[,1]
X = data[,-1]
X = as.matrix(X)
m1 = lm(Y~X-1)
m1$coefficients

 0.0546782907  0.0159731763  0.1312037785 -0.0507591565  0.1036469860 

 0.0050217163 -0.1006476385  0.0248998498  0.0081473528 -0.0111405854 

C#(使用accord.net,只有相当复杂的程序发布的结果):

 0.0546782906719276*x0 + 0.0159731763215885*x1 + 0.13120377853918*x2 + -0.0507591564748648*x3 + 0.103646986044143*x4 + 0.00502171630071436*x5 

有什么理由?

tldr;二手scikit-learnRC# accord.net比较MLR系数,从sklearn获得学士学位的结果,同时accord.net&R给出了类似的结果

python-3.x machine-learning scikit-learn regression linear-regression
1个回答
0
投票

我已经想通了,为什么(我自己的虚拟错误)

Y = data[:, 1]错了!

改成:

Y = data[:, 0]

现在,我得到这个(这是正确的):

5.46782907e-02  1.59731763e-02  1.31203779e-01 -5.07591565e-02
  1.03646986e-01  5.02171630e-03 -1.00647639e-01  2.48998498e-02
© www.soinside.com 2019 - 2024. All rights reserved.