2
$\begingroup$

I am trying to understand time-series data and model. In youtube tutorial and others, mostly univariate examples are shown. And they are applicable or suitable for those conditions. What if our dataset is multivariate (combination of categorical, numerical, date columns)? How can we analyze and understand the data and build a timeseries model?

Does other models like Random Forest, Gradient Boost Regressor, if we use these models, we don't have to worry about seasonality, trend and so on. How much truth is in this?

Is there a good book or reference to study about time series with good examples?

$\endgroup$

1 Answer 1

0
$\begingroup$

What if our dataset is multivariate (combination of categorical, numerical, date columns)? How can we analyze and understand the data [...]?

This is a typical case in machine learning where there are multiple inputs (features) to a model. A model could also have one or multiple outputs depending on nature of the target being predicted.

Ultimately, all of the features will need to be encoded into an appropriate numerical representation. The particular encoding scheme will depend on the nature of the data. For categorical features, one-hot and ordinal encoding are often used, and for date-time data you could perhaps break that down into new features like 'hour of the day', 'season', etc, depending on what matters for your task.

Before building a model, it helps to visualise and explore the data. This includes looking at feature distributions and their relationship with the target, amongst other things. In doing so you'll get a better feel for the preprocessing required to help models tease out pertinent factors.

That said, if you wanted to try a model without any preprocessing then RandomForestRegressor and some other models can take your data as-is and give you a quick baseline.

[...] and build a timeseries model?

Could you elaborate on the nature of the task? For example, if it's a forecasting task where you are predicting the next value in the sequence: how many values into the future do you need to predict, and is y a scalar or multivariate? Or are you instead rendering one classification per sequence?

It's often relevant to know the sequence length, and whether it is the same for each sample. This is because most models struggle with very long sequences, so you may need to segment each sequence into a series of shorter ones using sliding windows.

Does other models like Random Forest, Gradient Boost Regressor, if we use these models, we don't have to worry about seasonality, trend and so on. How much truth is in this?

I think they are good models to start off with. Even though you have a timeseries task, the more traditional models you outlined could perform as well as 'timeseries models' like ARIMA and recurrent neural nets. It depends on the specifics of the data you have and what the task is.

Seasonality, trend, etc, are features of the data so they would need to be considered to at least some extent, irrespective of the model. However, models specifically architected for sequential data (ARIMA, RNNs, LSTMs, etc) may be more picky about the temporal structure of the data, such as whether it is stationary and de-trended. Otherwise, they have a tendency to fall back on predicting the mean (flat line) or copying over the last value for each forecast.

Is there a good book or reference to study about time series with good examples?

I can recommend the chapter on sequences from this book/github - take a look at chapter 15 to get a feel for the timeseries analysis the author walks through. This page also introduces timeseries handling with pandas and goes through an example.

$\endgroup$
6
  • $\begingroup$ For example, if I have to predict 3 months in advance or 60 days in advance then how should we arrange the data for the model or preparing training dataset? $\endgroup$
    – Bad Coder
    Commented Jun 1 at 18:44
  • $\begingroup$ It depends on the model and the architecture. For long-range predictions like forecasting all of the next 60 steps, a sequence-to-sequence LSTM might be a better starting point than some of the simpler options. Define a window length, e.g. 150 steps, so you'll break the training data down into overlapping windows of 150 steps. For each step, the model would need to predict the subsequent 60 days. You could also try simpler techniques depending on the task. $\endgroup$ Commented Jun 1 at 19:17
  • $\begingroup$ So, my question for one of the case scenario(for example) is if I have to predict total # of sales before 60 days then, how can I adjust my training dataset and fit the model. For example today is June 1 so, today if I have to predict sales for Aug 1 then how to adjust training dataset? $\endgroup$
    – Bad Coder
    Commented Jun 2 at 3:41
  • $\begingroup$ You could start simple by feeding the model (could be a random forest) a 200-sample window at a time, and for each window of 200 samples, the target is a single number (the sum of sales over the next 60 days). $\endgroup$ Commented Jun 2 at 10:32
  • $\begingroup$ So, do you mean everytime train a model with 200 sample before predicting for 60 days? $\endgroup$
    – Bad Coder
    Commented Jun 2 at 14:20

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.