Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to predict time series in scikit-learn?
    primarykey
    data
    text
    <p>Scikit-learn utilizes a very convenient approach based on <code>fit</code> and <code>predict</code> methods. I have time-series data in the format suited for <code>fit</code> and <code>predict</code>.</p> <p>For example I have the following <code>Xs</code>:</p> <pre><code>[[1.0, 2.3, 4.5], [6.7, 2.7, 1.2], ..., [3.2, 4.7, 1.1]] </code></pre> <p>and the corresponding <code>ys</code>:</p> <pre><code>[[1.0], [2.3], ..., [7.7]] </code></pre> <p>These data have the following meaning. The values stored in <code>ys</code> form a time series. The values in <code>Xs</code> are corresponding time dependent "factors" that are known to have some influence on the values in <code>ys</code> (for example: temperature, humidity and atmospheric pressure).</p> <p>Now, of course, I can use <code>fit(Xs,ys)</code>. But then I get a model in which future values in <code>ys</code> depend only on factors and do not dependend on the previous <code>Y</code> values (at least directly) and this is a limitation of the model. I would like to have a model in which <code>Y_n</code> depends also on <code>Y_{n-1}</code> and <code>Y_{n-2}</code> and so on. For example I might want to use an exponential moving average as a model. What is the most elegant way to do it in scikit-learn</p> <p><strong>ADDED</strong></p> <p>As it has been mentioned in the comments, I can extend <code>Xs</code> by adding <code>ys</code>. But this way has some limitations. For example, if I add the last 5 values of <code>y</code> as 5 new columns to <code>X</code>, the information about time ordering of <code>ys</code> is lost. For example, there is no indication in <code>X</code> that values in the 5th column follows value in the 4th column and so on. As a model, I might want to have a linear fit of the last five <code>ys</code> and use the found linear function to make a prediction. But if I have 5 values in 5 columns it is not so trivial.</p> <p><strong>ADDED 2</strong></p> <p>To make my problem even more clear, I would like to give one concrete example. I would like to have a "linear" model in which <code>y_n = c + k1*x1 + k2*x2 + k3*x3 + k4*EMOV_n</code>, where EMOV_n is just an exponential moving average. How, can I implement this simple model in scikit-learn?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload