1
我用熊猫和statsmodels做线性回归。但是,我找不到任何可能的方式来阅读结果。结果显示,但我需要做一些使用coef值的进一步计算。有什么可能的方法将coef值存储到一个新变量中吗?从OLS回归结果中读取coef值
import statsmodels.api as sm
import numpy
ones = numpy.ones(len(x[0]))
t = sm.add_constant(numpy.column_stack((x[0], ones)))
for m in x[1:]:
t = sm.add_constant(numpy.column_stack((m, t)))
results = sm.OLS(y, t).fit()
'''它没有help'''几乎是无用的。也许你想解释什么是问题。 – sascha
由于我忘记将所有(np's)转换为numpy,所以出现了numpy问题。抱歉。你的回答是正确的,它解决了问题。 – HussainBiedouh
results.params是答案,这里是更多的例子http://www.statsmodels.org/dev/examples/notebooks/generated/ols.html – HussainBiedouh