Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chronos: Add support for id_sensitive=True to Forecaster.from_tsdataset #5551

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ def from_tsdataset(cls, tsdataset, past_seq_len=None, future_seq_len=None, **kwa
"""
Build a Forecaster Model.

:param tsdataset: A bigdl.chronos.data.tsdataset.TSDataset instance.
:param tsdataset: Train tsdataset, a bigdl.chronos.data.tsdataset.TSDataset instance.
:param past_seq_len: int or "auto", Specify the history time steps (i.e. lookback).
Do not specify the 'past_seq_len' if your tsdataset has called
the 'TSDataset.roll' method or 'TSDataset.to_torch_data_loader'.
Expand Down Expand Up @@ -1151,6 +1151,11 @@ def check_time_steps(tsdataset, past_seq_len, future_seq_len):
fixMsg="Do not specify past_seq_len and future seq_len "
"or call tsdataset.roll method again and specify time step")

if tsdataset.id_sensitive:
_id_list_len = len(tsdataset.id_col)
input_feature_num *= _id_list_len
output_feature_num *= _id_list_len

return cls(past_seq_len=past_seq_len,
future_seq_len=future_seq_len,
input_feature_num=input_feature_num,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def from_tsdataset(cls, tsdataset, past_seq_len=None, **kwargs):
'''
Build a LSTM Forecaster Model.

:param tsdataset: A bigdl.chronos.data.tsdataset.TSDataset instance.
:param tsdataset: Train tsdataset, a bigdl.chronos.data.tsdataset.TSDataset instance.
:param past_seq_len: Specify the history time steps (i.e. lookback).
Do not specify the 'past_seq_len' if your tsdataset has called
the 'TSDataset.roll' method or 'TSDataset.to_torch_data_loader'.
Expand Down Expand Up @@ -198,6 +198,11 @@ def check_time_steps(tsdataset, past_seq_len):
fixMsg="Do not specify past_seq_len "
"or call tsdataset.roll method again and specify time step.")

if tsdataset.id_sensitive:
_id_list_len = len(tsdataset._id_list)
input_feature_num *= _id_list_len
output_feature_num *= _id_list_len

return cls(past_seq_len=past_seq_len,
input_feature_num=input_feature_num,
output_feature_num=output_feature_num,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def from_tsdataset(cls, tsdataset, past_seq_len=None, future_seq_len=None, **kwa
"""
Build a NBeats Forecaster Model.

:param tsdataset: A bigdl.chronos.data.tsdataset.TSDataset instance.
:param tsdataset: Train tsdataset, a bigdl.chronos.data.tsdataset.TSDataset instance.
:param past_seq_len: Specify the history time steps (i.e. lookback).
Do not specify the 'past_seq_len' if your tsdataset has called
the 'TSDataset.roll' method or 'TSDataset.to_torch_data_loader'.
Expand Down Expand Up @@ -225,6 +225,9 @@ def check_time_steps(tsdataset, past_seq_len, future_seq_len):
fixMsg="Do not specify past_seq_len and future seq_len "
"or call tsdataset.roll method again and specify time step")

invalidInputError(not all([tsdataset.id_sensitive, len(tsdataset._id_list) > 1]),
"NBeats only supports univariate forecasting.")

return cls(past_seq_len=past_seq_len,
future_seq_len=future_seq_len,
**kwargs)