最近使用到了ols做线性回归,记录一下使用方法
首先是statsmodels,根据官网介绍,这是python里一个用于estimate statistical models 和 explore statistical data 的模块,经常做数据分析的小伙伴应该都不陌生
statsmodels is a Python module that provides classes and functions for the estimation of many different statistical models, as well as for conducting statistical tests, and statistical data exploration. An extensive list of result statistics are available for each estimator. The results are tested against existing statistical packages to ensure that they are correct.
然后是ols的方法,悉大的tutor给到了api 和 formula.api 两种建模方法,感觉直接用formula更省事些,毕竟自己做老容易忘记加intercept >-<