Answers.Body: <p>In general, multi output models is not that different.
  I.e.</p>
  <ol>
  <li>As Raghu mentioned in commentary, you could train separate model for each output. There is even helper module in sklearn for that (MultiOutputRegressor)</li>
  <li>DecisionTreeRegressor from sklearn allows multiple outputs out-of-the box</li>
  <li>Any neural network framework allows any number of outputs</li>
  </ol>
  <p>In your particular case there are two much bigger factors.</p>
  <ol>
  <li>It's timeseries. Timeseries requires whole another set of models then other data, i.e ANOVA, RNN or transformers.</li>
  <li>You data is not well scaled. The reason is that the change between points is insignificant in comparison with their absolute values. You need to deal with it -- but exact solution would depend on your particular task. You could try to substract the mean value on train set or predict the difference, not absolute value.</li>
  </ol>
  <p>Edit: here is simple example</p>
  <pre><code>import numpy as np
  raw = np.array([
  [414049364,21773560],
  [414049656,21773926],
  [414049938,21774287],
  [414050204,21774638],
  [414050453,21774975],
  [414050682,21775296],
  [414050895,21775597],
  [414051093,21775874],
  [414051278,21776125],
  [414051453,21776344],
  [414051620,21776530],
  [414051780,21776678],
  [414051935,21776785],
  [414052089,21776849],
  [414052242,21776865]
  ])
  
  X = raw[:-1]
  y = raw[1:]
  from sklearn.linear_model import LinearRegression
  model = LinearRegression()
  # Train the model
  model.fit(X, y)
  # Try to predict next step
  model.predict([[414051780,21776678]])
  # The predicted value [414051933,  21776806] and the true value would be [414051935,21776785], not so far
  
  </code></pre>
  <p>Next you could normalize the values, use few previous steps as a features, use more complex algorithm then linear regression, and make train/eval split for better model evaluation.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-17T22:35:56.660Z
Answers.Text: My problem is how to set the algorithms presented in the link above. My data is X however, I don't know what to use as y.
Answers.UserDisplayName: Poyita de troya
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-18T10:27:12.130Z
Answers.Text: You need to deal with time series, it's core challenge here. You could try following:
  1. Predict step n+1 from few previous steps. I.e. you have 5 steps, that's mean you have ten features and you could use any basic algorithm to predict values on step 6 (just apply regression/tree from you link). You could move the 'window' to generate to points, i.e. predict step 7 by 2-6, predict step 8 by 3-7 and so on.
  2. Use dedicated algorithms for the time series. There is a lot of tutorials, courses and even books in the wild on the topic.
Answers.UserDisplayName: Kirill Fedyanin
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-18T12:46:56.293Z
Answers.Text: Thanks for the advice, I've using ML since 2012, however, this context is new to me. I've done forecasting before. In previous cases, I had a set (y) of classes, here, I don't have classes. I've search and read a lot unsuccesfully. I don't pretend to get the solution here, just how to adapt my problem to current approaches.
Answers.UserDisplayName: Poyita de troya
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-19T13:47:38.760Z
Answers.Text: If you had classes, then you had classification problem (to predict class). In this case you have regression problem (to predict value). Algorithm from the link you provided should be doing fine. Simple baseline would be just to predict the next step from the current - I added example to the answer.
Answers.UserDisplayName: Kirill Fedyanin
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-19T15:31:25.223Z
Answers.Text: Great! I got it know. I was confused on how to treat my data. I guess if I want to predict more than one step ahead, I should use the same "training" but feeding multiple times the prediction
Answers.UserDisplayName: Poyita de troya
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-17T15:12:52.947Z
Answers.LastActivityDate: 2021-03-19T13:47:12.317Z
Answers.LastEditDate: 2021-03-19T13:47:12.317Z
Answers.UserDisplayName: Kirill Fedyanin
Body: <p>I need to forecast two non-correlated time-series (non-stationary). A sample is presented below:</p>
  <pre><code>414049364,21773560
  414049656,21773926
  414049938,21774287
  414050204,21774638
  414050453,21774975
  414050682,21775296
  414050895,21775597
  414051093,21775874
  414051278,21776125
  414051453,21776344
  414051620,21776530
  414051780,21776678
  414051935,21776785
  414052089,21776849
  414052242,21776865
  </code></pre>
  <p>The above is the input (two attributes) and the output (prediction) is composed of two targets (the same as input) for instance,</p>
  <pre><code>414052252,21776765
  </code></pre>
  <p>However, current regression techniques only consider a single attribute (class) forecasting but two or more. I've checked the following site <a href="https://machinelearningmastery.com/multi-output-regression-models-with-python/" rel="nofollow noreferrer">https://machinelearningmastery.com/multi-output-regression-models-with-python/</a> for multi-target regression or predictive clustering trees. Unfortunately, I don't know how to adapt my data to those techniques. Ideally, I would like to predict multiple steps.</p>
  <p>Any idea?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-03-17T08:30:47.567Z
Comments.Text: if they are independent it is better considered then as two separate time series and forecast accordingly.
Comments.UserDisplayName: raghu
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-03-17T09:53:10.127Z
Comments.Text: well, they are latitude and longitude values, in this case is also recommended to forecast separately or using MTR/PCT? in that last case, how can I adapt my data to those examples?
Comments.UserDisplayName: Poyita de troya
Tags: <python><regression><time-series>
Title: How to forecast multiple target attributes in Python?
UserDisplayName: Poyita de troya
ThreadText: # How to forecast multiple target attributes in Python?
  
  (Asked by: username_0 on 2021-03-16)
  
  I need to forecast two non-correlated time-series (non-stationary). A sample is presented below:
  
  ```
  414049364,21773560
  414049656,21773926
  414049938,21774287
  414050204,21774638
  414050453,21774975
  414050682,21775296
  414050895,21775597
  414051093,21775874
  414051278,21776125
  414051453,21776344
  414051620,21776530
  414051780,21776678
  414051935,21776785
  414052089,21776849
  414052242,21776865
  
  ```
  
  The above is the input (two attributes) and the output (prediction) is composed of two targets (the same as input) for instance,
  
  ```
  414052252,21776765
  
  ```
  
  However, current regression techniques only consider a single attribute (class) forecasting but two or more. I've checked the following site <https://machinelearningmastery.com/multi-output-regression-models-with-python/> for multi-target regression or predictive clustering trees. Unfortunately, I don't know how to adapt my data to those techniques. Ideally, I would like to predict multiple steps.
  
  Any idea?
  
  **Tags:** python, regression, time-series
  
  > **Comments:**
  > **username_1**: if they are independent it is better considered then as two separate time series and forecast accordingly.  
  > **username_0**: well, they are latitude and longitude values, in this case is also recommended to forecast separately or using MTR/PCT? in that last case, how can I adapt my data to those examples?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2021-03-17. Score: 1 | Accepted answer
  
  In general, multi output models is not that different.
  I.e.
  
  1. As username_1 mentioned in commentary, you could train separate model for each output. There is even helper module in sklearn for that (MultiOutputRegressor)
  2. DecisionTreeRegressor from sklearn allows multiple outputs out-of-the box
  3. Any neural network framework allows any number of outputs
  
  In your particular case there are two much bigger factors.
  
  1. It's timeseries. Timeseries requires whole another set of models then other data, i.e ANOVA, RNN or transformers.
  2. You data is not well scaled. The reason is that the change between points is insignificant in comparison with their absolute values. You need to deal with it -- but exact solution would depend on your particular task. You could try to substract the mean value on train set or predict the difference, not absolute value.
  
  Edit: here is simple example
  
  ```
  import numpy as np
  raw = np.array([
  [414049364,21773560],
  [414049656,21773926],
  [414049938,21774287],
  [414050204,21774638],
  [414050453,21774975],
  [414050682,21775296],
  [414050895,21775597],
  [414051093,21775874],
  [414051278,21776125],
  [414051453,21776344],
  [414051620,21776530],
  [414051780,21776678],
  [414051935,21776785],
  [414052089,21776849],
  [414052242,21776865]
  ])
  
  X = raw[:-1]
  y = raw[1:]
  from sklearn.linear_model import LinearRegression
  model = LinearRegression()
  # Train the model
  model.fit(X, y)
  # Try to predict next step
  model.predict([[414051780,21776678]])
  # The predicted value [414051933,  21776806] and the true value would be [414051935,21776785], not so far
  
  ```
  
  Next you could normalize the values, use few previous steps as a features, use more complex algorithm then linear regression, and make train/eval split for better model evaluation.
  
  > **Comments:**
  > **username_0**: My problem is how to set the algorithms presented in the link above. My data is X however, I don't know what to use as y.  
  > **username_2**: You need to deal with time series, it's core challenge here. You could try following: 1. Predict step n+1 from few previous steps. I.e. you have 5 steps, that's mean you have ten features and you could use any basic algorithm to predict values on step 6 (just apply regression/tree from you link). You could move the 'window' to generate to points, i.e. predict step 7 by 2-6, predict step 8 by 3-7 and so on. 2. Use dedicated algorithms for the time series. There is a lot of tutorials, courses and even books in the wild on the topic.  
  > **username_0**: Thanks for the advice, I've using ML since 2012, however, this context is new to me. I've done forecasting before. In previous cases, I had a set (y) of classes, here, I don't have classes. I've search and read a lot unsuccesfully. I don't pretend to get the solution here, just how to adapt my problem to current approaches.  
  > **username_2**: If you had classes, then you had classification problem (to predict class). In this case you have regression problem (to predict value). Algorithm from the link you provided should be doing fine. Simple baseline would be just to predict the next step from the current - I added example to the answer.  
  > **username_0**: Great! I got it know. I was confused on how to treat my data. I guess if I want to predict more than one step ahead, I should use the same "training" but feeding multiple times the prediction  
  
  ---
  
  