how do you create a linear regression forecast on time series data in python

前端 未结 4 780
时光说笑
时光说笑 2021-01-31 03:37

I need to be able to create a python function for forecasting based on linear regression model with confidence bands on time-series data:

The function needs to take an a

4条回答
  •  遇见更好的自我
    2021-01-31 04:01

    Note: this is not a detailed canonical answer, but references to available libraries that apply to your domain (statistical models).

    For python, you could use:

    • scipy : scipy.stats.linregress
      • e.g. http://glowingpython.blogspot.com/2012/03/linear-regression-with-numpy.html (uses scipy.stats.linregress)
    • statsmodels: here are some examples.
    • sklearn: here is the documentation.

    There are some good articles:

    • http://davidcoallier.com/blog/linear-regression-from-r-to-python/, in particular it has a section about forecasting.
    • http://connor-johnson.com/2014/02/18/linear-regression-with-python/, another article, shows both using statsmodels and sklearn.

提交回复
热议问题