简体   繁体   English

输出Scikit Learn OLS报告

[英]Outputting a Scikit Learn OLS report

I'm running OLS multivariate regression on a bunch of data subsets. 我正在对一堆数据子集运行OLS多元回归。

I'm currently using this to print out the results inside my Jupiter Python Notebook: 我目前正在使用它在Jupiter Python Notebook中打印出结果:

est = sm.OLS(y.astype(float), df_new.astype(float),hasconst=True).fit()
print (est.summary())

I would like to save each summary to a .csvor .xcl in some sort of orderly format. 我想以某种有序格式将每个摘要保存到.csvor .xcl。 Right now, copy-paste does not work-there is no standard delimiter. 目前,复制粘贴不起作用-没有标准定界符。 Any tips on programmatic ways to output each summary? 关于以编程方式输出每个摘要的任何技巧?

I believe you meant to say statsmodel in this case and not sklearn. 我相信您在这种情况下是要说statsmodel而不是sklearn。 Nonetheless, each statistic is actually stored as an attribute of the fitted estimator. 但是,每个统计信息实际上都存储为拟合估计量的属性。 It'd probably be nicer to have the information flattened out, but that functionality doesn't exist (that I am aware of). 整理信息可能会更好,但是该功能不存在(据我所知)。 For now, you can programmatically pull this information and write them to a csv using your favorite python 'to_csv' library. 现在,您可以使用您喜欢的python'to_csv'库以编程方式提取此信息并将其写入csv。

Here's some example values that show up in the summary: 以下是摘要中显示的一些示例值:

# Some first table values
est.nobs, est.df_resid, est.rsquared, est.rsquared_adj, est.fvalue, est.f_pvalue, est.aic, est.bic 
est.k_constant, 

# Some second table values
est.tvalues, est.pvalues

# All third table values
est.diagn

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM