You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 with window_len=20and get_ts_dls appears to get a data loader with the right window size but assumes continuous variables, while get_tabular_ds allows categorical variables but doesn't have window _len parameters. I tried converting it to a dataloader with dls = 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 running
AttributeError Traceback (most recent call last)
Cell In[43], line 1
----> 1 learn = ts_learner(
2 dls,
3 TSTPlus,
4 metrics=[F1Score(average="macro")],
5 loss_func=CrossEntropyLossFlat(weight=class_weights),
6 lr=1e-4,
7 )
File [~/.../site-packages/tsai/learner.py:549), in ts_learner(dls, arch, c_in, c_out, seq_len, d, splitter, loss_func, opt_func, lr, cbs, metrics, path, model_dir, wd, wd_bn_bias, train_bn, moms, train_metrics, valid_metrics, **kwargs)
547 if arch is None: arch = InceptionTimePlus
548 elif isinstance(arch, str): arch = get_arch(arch)
--> 549 model = build_ts_model(arch, dls=dls, c_in=c_in, c_out=c_out, seq_len=seq_len, d=d, **kwargs)
550 if hasattr(model, "backbone") and hasattr(model, "head"):
551 splitter = ts_splitter
File [~/.../site-packages/tsai/models/utils.py:147), in build_ts_model(arch, c_in, c_out, seq_len, d, dls, device, verbose, pretrained, weights_path, exclude_head, cut, init, arch_config, **kwargs)
145 device = ifnone(device, default_device())
146 if dls is not None:
--> 147 c_in = ifnone(c_in, dls.vars)
148 c_out = ifnone(c_out, dls.c)
149 seq_len = ifnone(seq_len, dls.len)
...
172 res = [t for t in att.attrgot(k) if t is not None]
--> 173 if not res: raise AttributeError(k)
174 return res[0] if len(res)==1 else L(res)
AttributeError: vars
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.
#231 seems to indicate that this is possible now, but I didn't see any example code.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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.
#231 seems to indicate that this is possible now, but I didn't see any example code.
Beta Was this translation helpful? Give feedback.
All reactions