2017-04-18 5 views
1

전 ols 모델을 실행 중이며 모든 계수를 알아야 분석에 사용할 수 있습니다. 계수를 과학 표기법과 다른 형식으로 표시하거나 저장하는 방법은 무엇입니까?python sm.ols 과학 표기법을 피하기 위해 요약 형식을 변경합니다.

model = sm.ols(formula="sales ~ product_category + quantity_bought + quantity_ordered + quantity_returned + season", data=final_email).fit() 
print model.summary() 

OLS Regression Results        
============================================================================== 
Dep. Variable:    sales R-squared:      0.974 
Model:       OLS Adj. R-squared:     0.938 
Method:     Least Squares F-statistic:      27.26 
Date:    Tue, 18 Apr 2017 Prob (F-statistic):   5.39e-13 
Time:      11:43:36 Log-Likelihood:    -806.04 
No. Observations:     60 AIC:        1682. 
Df Residuals:      25 BIC:        1755. 
Df Model:       34           
Covariance Type:   nonrobust           
====================================================================================== 
         coef std err   t  P>|t|  [95.0% Conf. Int.] 
-------------------------------------------------------------------------------------- 
Intercept   -2.79e+05 2.883e+05  -0.987  0.333  -8.92e+05 3.14e+05 
Product_category[A] 4.343e+04 2.456e+05  0.186  0.854  -4.95e+05 5.93e+05 
Product_category[B] 2.784e+05 1.23e+05  1.128  0.270  -1.68e+05 5.75e+05 
quantity_bought  -74678  1.754e+05  -0.048  0.962  -3.4e+05 3.24e+05 
quantity_ordered  3.543e+05 1.363e+05  1.827  0.080  -4.21e+04 7.05e+05 
quantity_returned  1.285e+05 2.154e+05  0.512  0.613  -4.61e+05 7.66e+05 
season    -1.983e+04 1.76e+05  -0.133  0.895  -2.69e+05 

Warnings: 
[1] Standard Errors assume that the covariance matrix of the errors is correctly specified. 
[2] The smallest eigenvalue is 1.19e-29. This might indicate that there are 
strong multicollinearity problems or that the design matrix is singular. 

이 도움이되지 않았다 RegressionResultsWrapper.summary() 방법은이 기능에 대한 좋은 지원을 가지고하지 않았기 때문에

pd.set_option('display.float_format', lambda x: '%3.f' % x) 

답변

4

그래서 이것은 통계 소스에 하드 코드 된 것입니다. 그러나 계수를 빼내는 가장 좋은 방법은 model.params입니다. RegressionResults의 소스를 살펴보고 특히 모든 속성과 모델 적합성에 대한 모든 관련 정보에 액세스하는 방법을 보여줍니다.

+0

model.params는 과학적 공지없이 작동합니다. 고맙습니다 – jeangelj

3

당신은의 statsmodels version 0.8.0로 지금 그것을 할 수 없습니다. xname, yname, alpha, title 만 사용할 수 있습니다.

따라서 float_format이라는 매개 변수가있는 RegressionResultsWrapper.summary()이라는 실험적 기능이 있습니다.이 기능을 통해 수행해야 할 작업을 알 수 있습니다.

그러나 이것은 실험적인 기능이기 때문에. 버그를 사용할 때 발생할 수 있습니다. float_format을 지정하면 예상대로 일부 결과가 작동하지 않을 수 있습니다.

일부 결과 형식이 hard-coded 인 것을 발견했습니다. 따라서 float_format이 작동하지 않는 경우. 원본 파일을 편집하면 마지막 옵션 일 수 있습니다. 걱정 마세요, 생각했던 것처럼 어렵지 않을 수도 있습니다. 더 많은 것을 물어보십시오.

+0

고마워요 - 그걸보고 있는데 – jeangelj