1
$\begingroup$

I have a dataset timeseries forecasting that includes the categorical columns and numeric as well.

here is a sample of it

Date | categorical _fature_1 |categorical _fature_2|  Feature_1_numeric | feature_2_numeric | price

1-1-2020 | USA | A | 5.5 | 7.6 | 100

1-1-2020 | USA | B | 8.3 | 1.7| 20

1-1-2020 | USA | C | 3.6 | 2.1 | 17

1-2-2020 | USA | D | 5.5 | 7.6 | 40

1-2-2020 | USA | E | 77.5 | 35 | 22

1-2-2020 | USA | F | 69.5 | 2 | 22

as you can see in the sample in the date lets pick up the 1-1-2020 we have multiple observations at the same date .

i want to predict the Price column as a Y_label and taking the categorical _fature_1, categorical _fature_2, Feature_1_numeric, and Feature_2_numeric as the X_features

so from my understanding as im using multiple features for time series Forecasting predicting the Price column this is called Multivariate Time-Series Forecasting

My Question is

1-how can i manage the multiple observations at the same time from the different features as we saw for example in 1-1-2020 we have three different observations

2-i believe if we have multiple observations at the same time/date then we have a new kind of Time-series forecasting what is it Multi-timestep Multivariate Time-Series Forecasting or what ???

thanks

$\endgroup$

1 Answer 1

0
$\begingroup$

It is multivariate time series forecasting indeed, and you need to train your model on the past time of the features as well as the interdependencies between them.

One common solution is Vector Auto Regression (VAR).

They are basically models that calculates both time and values interdependencies using a matrix:

Source: wikipedia

Source: Wikipedia

Here is an overview for 3 features and second order: enter image description here Source: https://www.machinelearningplus.com/time-series/vector-autoregression-examples-python/

In your case, you will consider Y1 as feature_1, Y2 as feature_2 and Y3 as price.

This will calculate the interactions between Y1, Y2 and Y3, and you will get the prediction you want for the 3 of them, including Y3.

There is a library in Python, Statsmodel, that has a VAR function here.

VAR is a good start, but it is a linear algorithm, i.e you may not have good results if your features are complex to predict.

If you have complex features, there are non linear algorithms that would perform better, like Multivariate LSTM and Random Forest.

$\endgroup$
14
  • $\begingroup$ thanks for your answer Nicolas, from your answer you mean that i should consider categorical _fature_1, categorical _fature_2 are Y_labels just like price categorical _fature_1 --> y_label_1, categorical _fature_2 --> y_label_2, price --> y_label_3. and the X_features are Feature_1_numeric --> X_feature_1 , Feature_2_numeric --> X_feature_2 is that what you mean ???? $\endgroup$ Commented Aug 4, 2021 at 20:40
  • $\begingroup$ VAR works differently than most models like LSTM or Random Forest: there is no proper objective feature. You merely compare curves between each other and you try to make predictions based on those comparisons. Consequently, you just have Y features. See also: en.wikipedia.org/wiki/Vector_autoregression $\endgroup$ Commented Aug 5, 2021 at 7:30
  • $\begingroup$ lets pretend that im working on LSTM not VAR that means my y_labels are (categorical _fature_1, categorical _fature_2, price) and X_features Feature_1_numeric , Feature_2_numeric ..............................or what ?? $\endgroup$ Commented Aug 5, 2021 at 8:10
  • $\begingroup$ Yes. The shape will be 1 timestep + the X features (input_shape=(train_X.shape[1], train_X.shape[2]) ), one Y/Price output (=Dense(1)) . You can reuse the page above about LSTM. $\endgroup$ Commented Aug 5, 2021 at 8:34
  • $\begingroup$ and this regardless the multiple observations at the same time, because the LSTM will handle this using its multiple window sizes ( number of filters) that given to the LSTM parameters??? $\endgroup$ Commented Aug 5, 2021 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.