Open CMobley7 opened 1 year ago
Hey @CMobley7 did you ever figure this out? I would also love to see an example of how the fix in https://github.com/timeseriesAI/tsai/issues/231 should be used.
Also where is it mentioned that get_ts_dls
assumes continuous variables? Do you know if the same assumption is made when using TSDataLoaders.from_dsets
?
Sorry for the delay, @Awe42. I'd previously looked at the links you provided. While the MultiInputNet
with get_mixed_dls
would allow you to use a time series
and tabular
models together, I still don't yet see a way to use both continuous
and categorical
features with a sliding window. The get_tabular_ds
function takes a dataframe
, not the X
and y
arrays generated by apply_sliding_window
though you could create a function to apply the sliding window to a dataframe
and recreate the dataframe
with the additional features created by apply_sliding_window
, such as feature_1(ts-1)
to feature_X(ts-window_len)
. While this would allow you to use the tabular
models in Tsai
, I still don't see a way to use the time series
models with categorical
data as they appear to only work with continuous
data. So, you could use either just a tabular
model or a MultiInputNet
with a time series
model with just the continuous
data and the tabular
model with both as mentioned before. However, based on https://github.com/timeseriesAI/tsai/issues/231, it should be possible to use categorical
variables with at least a few of the time series
models, though I haven't dug deep enough in the source code to see how that could be done. Did you figure out a better way, @Awe42? @oguiza, is there an example or gist of using a time series model with both categorical
and continuous
features somewhere, and is there already a function in Tsai
that allows one to apply a sliding window but output a dataframe
instead of X
and y
arrays, along with lists of the new categorical
and continuous
column names for use with tabular
models?
Hi @CMobley7, @Awe42,
I'm currently testing some new functionality I've recently added to tsai
. It's in a module called tsai.models.multimodal
. It will allow you to use:
You may want to test it as well with your own data. I plan to create a tutorial if I find the tests work out well.
@oguiza Have you created a tutorial around the new tsai.models.multimodal module? Or is there another update on this thread?
My apologies for the dumb question. I have a target variable and continuous and categorical features in a dataframe. The categorical features are dynamic. I'd like to train a time series model, such as the
TSTPlus
, on a sliding window of these features that doesn't include the target. I plan to test this out with a categorical and continuous target, but the examples below assume a categorical target. Unfortunately, I'm struggling to ascertain how to do this.Using
apply_sliding_window
withwindow_len=20
andget_ts_dls
appears to get a data loader with the right window size but assumes continuous variables, whileget_tabular_ds
allows categorical variables but doesn't havewindow _len
parameters. I tried converting it to a dataloader withdls = to.dataloaders(bs=64, seq_len=20, seq_first=True)
, but I couldn't tell if this applied the desired window, and it caused the following error when runningI get the following error:
How can I accomplish what I wrote above, if possible? I've thought of some inelegant and nonideal solutions, such as using a ts_learner but dropping the categorical features entirely, using a tabular_learner without a window length, using a tabular_learner, but creating a function that takes window_len and appends the features to the original dataframe, such as feature_1(ts-1) to feature_X(ts-window_len). These are obviously nonideal solutions, and I'd rather use a ts_learner though I plan to test out tabular learners in the future; so, learning how to set a window_len in that would be awesome to know as well.
https://github.com/timeseriesAI/tsai/issues/231 seems to indicate that this is possible now, but I didn't see any example code.