Time series forecasting (eventually with python)

Question:

  • What algorithms exist for time series forecasting/regression ?
    • What about using neural networks ? (best docs about this topic ?)
    • Are there python libraries/code snippets that can help ?
Asked By: gpilotino

||

Answers:

I’ve no idea about python libraries, but there are good forecasting algorithms in R which are open source. See the forecast package for code and references for time series forecasting.

Answered By: Rob Hyndman

Speaking only about the algorithms behind them, I recently used the double exponential smoothing in a project and it did well by forecasting new values when there is a trend in the data.

The implementation is pretty trivial, but maybe the algorithm is not sufficiently elaborated for your case.

Answered By: GaretJax

Did you tried Autocorrelation for finding periodical patterns in time series ?
You can do that with numpy.correlate function.

Answered By: Agnius Vasiliauskas

The classical approaches to time series regression are:

  • auto-regressive models (there are whole literatures about them)

  • Gaussian Processes

  • Fourier decomposition or similar to extract the periodic components of the signal (i.e., hidden oscillations in the data)

Other less common approaches that I know about are

  • Slow Feature Analysis, an algorithm that extract the driving forces of a time series, e.g., the parameters behind a chaotic signal

  • Neural Network (NN) approaches, either using recurrent NNs (i.e., built to process time signals) or classical feed-forward NNs that receive as input part of the past data and try to predict a point in the future; the advantage of the latter is that recurrent NNs are known to have a problem with taking into account the distant past

In my opinion for financial data analysis it is important to obtain not only a best-guess extrapolation of the time series, but also a reliable confidence interval, as the resulting investment strategy could be very different depending on that. Probabilistic methods, like Gaussian Processes, give you that "for free", as they return a probability distribution over possible future values. With classical statistical methods you’ll have to rely on bootstrapping techniques.

There are many Python libraries that offer statistical and Machine Learning tools, here are the ones I’m most familiar with:

  • NumPy and SciPy are a must for scientific programming in Python
  • There is a Python interface to R, called RPy
  • statsmodel contains classical statistical model techniques, including autoregressive models; it works well with Pandas, a popular data analysis package
  • scikits.learn, MDP, MLPy, Orange are collections of machine learning algorithms
  • PyMC A python module that implements Bayesian statistical models and fitting algorithms, including Markov chain Monte Carlo.
  • PyBrain contains (among other things) implementations of feed-forward and recurrent neural networks
  • at the Gaussian Process site there is a list of GP software, including two Python implementations
  • mloss is a directory of open source machine learning software
Answered By: pberkes

Group method of data handling is widely used to forecast financial data.

Answered By: Gleb Koshulko

Two approaches

There are two ways on how to deal with temporal structured input for classification, regression, clustering, forecasting and related tasks:

  1. Dedicated Time Series Model: The machine learning algorithm incorporates such time series directly. Such a model is like a black box and it can be hard to explain the behavior of the model. Example are autoregressive models.
  2. Feature based approach: Here the time series are mapped to another, possibly lower dimensional, representation. This means that the feature extraction algorithm calculates characteristics such as the average or maximal value of the time series. The features are then passed as a feature matrix to a “normal” machine learning such as a neural network, random forest or support vector machine. This approach has the advantage of a better explainability of the results. Further it enables us to use a well developed theory of supervised machine learning.

tsfresh calculates a huge number of features

The python package tsfresh calculate a huge number of such features from a pandas.DataFrame containing the time series. You can find its documentation at http://tsfresh.readthedocs.io.

enter image description here

Disclaimer: I am one of the authors of tsfresh.

Answered By: MaxBenChrist

If you want to understand Time Series Forecasting using Python then below link is very helpful.

https://github.com/ManojKumarMaruthi/Time-Series-Forecasting

Answered By: Satya