把统计的结果放到word中后,怎么提取想要的数据,存入CSV
我做了线性回归得到的结果是OLS Regression Results
==============================================================================
Dep. Variable: x R-squared: 0.004
Model: OLS Adj. R-squared: -0.006
Method: Least Squares F-statistic: 0.3809
Date: Fri, 04 Jun 2021 Prob (F-statistic): 0.539
Time: 22:45:51 Log-Likelihood: -493.47
No. Observations: 104 AIC: 990.9
Df Residuals: 102 BIC: 996.2
Df Model: 1
Covariance Type: nonrobust
==============================================================================
coef std err t P>|t|
------------------------------------------------------------------------------
Intercept 46.9506 3.145 14.930 0.000 40.713 53.188
y -0.3424 0.555 -0.617 0.539 -1.443 0.758
==============================================================================
Omnibus: 28.683 Durbin-Watson: 2.046
Prob(Omnibus): 0.000 Jarque-Bera (JB): 52.685
Skew: 1.138 Prob(JB): 3.63e-12
Kurtosis: 5.642 Cond. No. 6.52
==============================================================================
请教各位大神
我想把y 这行后面的 -1.443 0.758给提出来,存入CSV的两个单元格里。
我用正则,但没做出来。
这结果是咋来的,为啥要放在word中 这个结果是用OLS 做线性回归。#y=a+bx 统计后可以得到a,b 和p 的值,可以通过summary()得到所有的参数,但没法直接得到b值的95%可信区间,所以我只好把他放到word里,看能不能提取出来。
x = df2.values.reshape(-1, 1)# 必须是.value 然后再reshape(-1.1)转成1行。
y = df2['IL1b'].values.reshape(-1, 1)
# print(x)
lm_s = ols('x~y', data=df2).fit()
#y=a+bx
print(lm_s.summary())
b=lm_s.params
p=lm_s.pvalues # p值
a=lm_s.params #
print(a,b,p) # 分别打印出a ,b 和p的值。
writer.writerow(['IL1b',b, p]) chenjl1972 发表于 2021-6-5 10:34
这个结果是用OLS 做线性回归。#y=a+bx 统计后可以得到a,b 和p 的值,可以通过summary()得到所有的参数,但 ...
不可以直接提取吗,比如你要的数据在a里b里p里??
页:
[1]