python 回归分析
来源:互联网 发布:sql 统计每小时记录 编辑:程序博客网 时间:2024/06/05 19:33
pwd
‘d:\\python\\exerise-df\\df-data-analysis’from scipy import statsimport pandas as pdimport numpy as npfrom statsmodels.formula.api import olsimport statsmodels.api as smfrom statsmodels.stats.anova import anova_lmfrom statsmodels.stats.multicomp import pairwise_tukeyhsdimport matplotlib.pyplot as plt
单变量分析分析
dat = pd.read_csv("simple-resgreesion.csv")
dat.head()
model = ols('weight ~ N',dat).fit()
print(model.summary())
OLS Regression Results ==============================================================================Dep. Variable: weight R-squared: 0.991Model: OLS Adj. R-squared: 0.990Method: Least Squares F-statistic: 1433.Date: Wed, 27 Sep 2017 Prob (F-statistic): 1.09e-14Time: 14:49:40 Log-Likelihood: -26.541No. Observations: 15 AIC: 57.08Df Residuals: 13 BIC: 58.50Df Model: 1 Covariance Type: nonrobust ============================================================================== coef std err t P>|t| [95.0% Conf. Int.]------------------------------------------------------------------------------Intercept -87.5167 5.937 -14.741 0.000 -100.343 -74.691N 3.4500 0.091 37.855 0.000 3.253 3.647==============================================================================Omnibus: 2.396 Durbin-Watson: 0.315Prob(Omnibus): 0.302 Jarque-Bera (JB): 1.660Skew: 0.789 Prob(JB): 0.436Kurtosis: 2.596 Cond. No. 982.==============================================================================Warnings:[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.
多项式回归分析
dat2 = pd.read_csv("duoxiangshi.csv")
dat2.head()
mod = ols('weight ~ N + I(N**2)',dat2).fit()
print(mod.summary())
OLS Regression Results ==============================================================================Dep. Variable: weight R-squared: 0.999Model: OLS Adj. R-squared: 0.999Method: Least Squares F-statistic: 1.139e+04Date: Wed, 27 Sep 2017 Prob (F-statistic): 2.13e-20Time: 14:59:57 Log-Likelihood: -5.2563No. Observations: 15 AIC: 16.51Df Residuals: 12 BIC: 18.64Df Model: 2 Covariance Type: nonrobust ============================================================================== coef std err t P>|t| [95.0% Conf. Int.]------------------------------------------------------------------------------Intercept 261.8782 25.197 10.393 0.000 206.979 316.777N -7.3483 0.778 -9.449 0.000 -9.043 -5.654I(N ** 2) 0.0831 0.006 13.891 0.000 0.070 0.096==============================================================================Omnibus: 2.449 Durbin-Watson: 1.144Prob(Omnibus): 0.294 Jarque-Bera (JB): 1.033Skew: 0.049 Prob(JB): 0.597Kurtosis: 1.718 Cond. No. 1.09e+06==============================================================================
多变量回归分析
dat = pd.read_csv("mul-regression.csv")
dat.head()
mod = ols('y ~ x1 + x2 + x3 + x4',dat).fit()
print(mod.summary())
OLS Regression Results ==============================================================================Dep. Variable: y R-squared: 0.894Model: OLS Adj. R-squared: 0.866Method: Least Squares F-statistic: 31.78Date: Wed, 27 Sep 2017 Prob (F-statistic): 3.66e-07Time: 14:52:33 Log-Likelihood: -97.454No. Observations: 20 AIC: 204.9Df Residuals: 15 BIC: 209.9Df Model: 4 Covariance Type: nonrobust ============================================================================== coef std err t P>|t| [95.0% Conf. Int.]------------------------------------------------------------------------------Intercept -625.3583 114.378 -5.467 0.000 -869.150 -381.566x1 15.1962 2.127 7.146 0.000 10.663 19.729x2 7.3785 1.889 3.907 0.001 3.353 11.404x3 9.5034 1.342 7.082 0.000 6.643 12.364x4 -0.8468 1.493 -0.567 0.579 -4.029 2.335==============================================================================Omnibus: 0.492 Durbin-Watson: 1.620Prob(Omnibus): 0.782 Jarque-Bera (JB): 0.578Skew: -0.294 Prob(JB): 0.749Kurtosis: 2.409 Cond. No. 1.38e+03==============================================================================
阅读全文
0 0
- python 回归分析
- Python数据挖掘-回归分析
- Python金融大数据分析-回归分析
- python回归分析相关代码-散点图,回归,预测
- 回归分析---线性回归原理和Python实现
- 回归分析
- 回归分析
- 回归分析
- 回归分析
- 回归分析
- 回归分析
- 回归分析
- 回归分析
- 回归分析
- 回归分析
- 回归分析
- 回归分析
- 回归分析
- Windows中使用CRT函数检查内存泄露和溢出
- pascals-triangle-ii
- Quartz任务调度框架和Spring的整合使用
- PL/SQL之手动修改Oracle表
- 山园小梅
- python 回归分析
- linux下执行多个shell脚本的方法
- 深度学习笔记之Andrew Ng(1)
- Android的几种SdkVersion(complie target min)
- onvif profiles概述
- Ubuntu安装Django
- AndroidStudio使用Material Theme UI
- 使用BeanUtils操作Javabean
- linux——创建