日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python线性回归x可以数量不一样吗_R和Python中的线性回归 - 在同一问题上的结果不同...

發布時間:2023/12/2 python 51 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python线性回归x可以数量不一样吗_R和Python中的线性回归 - 在同一问题上的结果不同... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

只是指出這一點: statsmodel 's least squares fit does by default not include a constant. If we remove the constant from R'適合,我們得到與Python實現非常相似的結果,或者相反,如果我們向 statsmodel -fit添加一個常量,我們得到類似于 R 的結果:

刪除 R 的 lm -call中的常量:

summary(lm(Temp ~ . - 1, data = train[,3:NCOL(train)]))

Call:

lm(formula = Temp ~ . - 1, data = train[, 3:NCOL(train)])

Residuals:

Min 1Q Median 3Q Max

-0.221940 -0.032347 0.002071 0.037048 0.167294

Coefficients:

Estimate Std. Error t value Pr(>|t|)

MEI 0.036076 0.027983 1.289 0.2079

CO2 0.004640 0.008945 0.519 0.6080

CH4 -0.002328 0.002132 -1.092 0.2843

N2O -0.014115 0.079452 -0.178 0.8603

`CFC-11` -0.031232 0.096693 -0.323 0.7491

`CFC-12` 0.035760 0.103574 0.345 0.7325

TSI -0.003283 0.036861 -0.089 0.9297

Aerosols 69.968040 33.093275 2.114 0.0435 *

---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.07457 on 28 degrees of freedom

Multiple R-squared: 0.9724, Adjusted R-squared: 0.9645

F-statistic: 123.1 on 8 and 28 DF, p-value: < 2.2e-16

讓我們為 statsmodel 的調用添加一個常量:

X_with_constant = sm.add_constant(X)

model = sm.OLS(y, X_with_constant).fit()

model.summary()

給我們相同的結果:

OLS Regression Results

Dep. Variable: Temp R-squared: 0.535

Model: OLS Adj. R-squared: 0.397

Method: Least Squares F-statistic: 3.877

Date: Tue, 02 Oct 2018 Prob (F-statistic): 0.00372

Time: 10:14:03 Log-Likelihood: 46.899

No. Observations: 36 AIC: -75.80

Df Residuals: 27 BIC: -61.55

Df Model: 8

Covariance Type: nonrobust

coef std err t P>|t| [0.025 0.975]

const -17.8663 563.008 -0.032 0.975 -1173.064 1137.332

MEI 0.0361 0.029 1.265 0.217 -0.022 0.095

CO2 0.0048 0.011 0.451 0.656 -0.017 0.027

CH4 -0.0024 0.002 -0.950 0.351 -0.007 0.003

N2O -0.0130 0.088 -0.148 0.884 -0.194 0.168

CFC-11 -0.0332 0.116 -0.285 0.777 -0.272 0.205

CFC-12 0.0378 0.123 0.307 0.761 -0.215 0.290

TSI 0.0091 0.392 0.023 0.982 -0.795 0.813

Aerosols 70.4633 37.139 1.897 0.069 -5.739 146.666

Omnibus: 8.316 Durbin-Watson: 1.488

Prob(Omnibus): 0.016 Jarque-Bera (JB): 10.432

Skew: -0.535 Prob(JB): 0.00543

Kurtosis: 5.410 Cond. No. 1.06e+08

總結

以上是生活随笔為你收集整理的python线性回归x可以数量不一样吗_R和Python中的线性回归 - 在同一问题上的结果不同...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。