-
Notifications
You must be signed in to change notification settings - Fork 696
[ENH] Test framework for ptf-v2
#1841
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
Merged
Merged
Changes from 99 commits
Commits
Show all changes
112 commits
Select commit
Hold shift + click to select a range
b3644a6
test suite
fkiraly a1d64c6
Merge branch 'main' into test-suite
fkiraly 4b2486e
skeleton
fkiraly 02b0ce6
skeleton
fkiraly 41cbf66
Update test_all_estimators.py
fkiraly cef62d3
Update _base_object.py
fkiraly bc2e93b
Update _lookup.py
fkiraly eee1c86
Update _lookup.py
fkiraly 164fe0d
base metadatda
fkiraly 20e88d0
registry
fkiraly 318c1fb
fix private name
fkiraly 012ab3d
Update _base_object.py
fkiraly 86365a0
test failure
fkiraly f6dee46
Update test_all_estimators.py
fkiraly 9b0e4ec
Update test_all_estimators.py
fkiraly 7de5285
Update test_all_estimators.py
fkiraly 57dfe3a
test folders
fkiraly c9f12db
Update test.yml
fkiraly fa8144e
test integration
fkiraly 232a510
fixes
fkiraly 1c8d4b5
Update _conftest.py
fkiraly f632e32
try scenarios
fkiraly 252598d
D1, D2 layer commit
phoeenniixx d0d1c3e
remove one comment
phoeenniixx 80e64d2
model layer commit
phoeenniixx 6364780
update docstring
phoeenniixx 82b3dc7
Merge branch 'refactor-d1-d2' into refactor-model
phoeenniixx 257183c
update data_module.py
phoeenniixx 9cdcb19
update data_module.py
phoeenniixx a83bf32
Merge branch 'refactor-d1-d2' into refactor-model
phoeenniixx ac56d4f
Add disclaimer
phoeenniixx 0e7e36f
Merge branch 'refactor-d1-d2' into refactor-model
phoeenniixx 4bfff21
update docstring
phoeenniixx ef98273
Merge branch 'refactor-d1-d2' into refactor-model
phoeenniixx 8a53ed6
Add tests for D1,D2 layer
phoeenniixx 9f9df31
Merge branch 'main' into refactor-d1-d2
phoeenniixx cdecb77
Code quality
phoeenniixx 86360fd
Merge branch 'refactor-d1-d2' into refactor-model
phoeenniixx 20aafb7
refactor file
fkiraly 043820d
warning
fkiraly 1720a15
linting
fkiraly af44474
move coercion to utils
fkiraly a3cb8b7
linting
fkiraly 75d7fb5
Update _timeseries_v2.py
fkiraly 1b946e6
Update __init__.py
fkiraly 3edb08b
Update __init__.py
fkiraly a4bc9d8
Merge branch 'main' into pr/1811
fkiraly 4c0d570
Merge branch 'pr/1811' into pr/1812
fkiraly ef37f55
Merge branch 'main' into test-suite
fkiraly a669134
Update _lookup.py
fkiraly d78bf5d
Update _lookup.py
fkiraly e350291
update tests
phoeenniixx f90c94f
Merge branch 'refactor-d1-d2' into refactor-model
phoeenniixx 3099691
update tft_v2
phoeenniixx 77cb979
warnings and init attr handling
fkiraly 28df3c3
Merge branch 'refactor-d1-d2' of https://github.com/phoeenniixx/pytor…
fkiraly f8c94e6
simplify TimeSeries.__getitem__
fkiraly c289255
Update _timeseries_v2.py
fkiraly 9467f38
Update data_module.py
fkiraly c3b40ad
backwards compat of private/public attrs
fkiraly c007310
Merge branch 'refactor-d1-d2' into refactor-model
phoeenniixx 2e25052
Merge branch 'main' into refactor-model
phoeenniixx 38c28dc
add tests
phoeenniixx 9d80eb8
add tests
phoeenniixx a8ccfe3
add tests
phoeenniixx f900ba5
add more docstrings
phoeenniixx ed1b799
add note about the commented out tests
phoeenniixx c947910
Merge branch 'main' into refactor-model
phoeenniixx c0ceb8a
add the commented out tests
phoeenniixx 3828c26
remove note
phoeenniixx 6d6d18e
Merge branch 'main' into refactor-model
phoeenniixx 3144865
Merge branch 'test-suite' of https://github.com/sktime/pytorch-foreca…
phoeenniixx 30b541b
make the modules private
phoeenniixx 3f1e11f
Merge remote-tracking branch 'origin/refactor-model' into refactor-model
phoeenniixx 5cc3ff1
initial commit
phoeenniixx 1bcf181
Merge branch 'refactor-model' into test-framework
phoeenniixx f18e09d
add TFTMetadata class
phoeenniixx e1e360e
add TFTMetadata class
phoeenniixx 168e16a
Merge branch 'main' into test-framework
phoeenniixx 92c12bf
add TFT tests
phoeenniixx 1d478d5
remove refactored TFT
phoeenniixx f9992f2
Merge branch 'main' into test-framework
phoeenniixx d049019
update test_all_estimators
phoeenniixx e72486b
linting
phoeenniixx 7443b0b
Merge branch 'main' into test-framework
phoeenniixx a734f26
refactor
phoeenniixx 7f466b2
Add more test_params
phoeenniixx 0968452
Add metadata tests
phoeenniixx 525bbb9
Merge branch 'main' into test-framework
phoeenniixx 4267da6
Merge branch 'main' into test-framework
phoeenniixx 4e8f863
add object-filter to ptf-v1
phoeenniixx c117092
Merge branch 'main' into test-framework
phoeenniixx f6d39fe
Merge branch 'main' into test-framework
phoeenniixx 2c518ee
add new base classes
phoeenniixx 7a5c58f
remove try block
phoeenniixx cb3e944
Merge branch 'main' into test-framework
phoeenniixx 3b9de6d
add support for multiple datamodules
phoeenniixx 032a7b0
typo
phoeenniixx 4d9a19a
Merge branch 'main' into test-framework
phoeenniixx 03c06e8
Merge branch 'main' into test-framework
phoeenniixx 8b0087e
linting
phoeenniixx d328fae
Merge branch 'main' into test-framework
phoeenniixx 68df4b6
merge main
phoeenniixx 57d635b
add pkg name to v2
phoeenniixx e35a4ff
Merge branch 'main' into test-framework
phoeenniixx c4d5628
revert changes to conftest
fkiraly 6129d33
reverts and fixes
fkiraly 32ef57e
v2
fkiraly 93ea865
Update __init__.py
fkiraly 8e95e6e
Update __init__.py
fkiraly f990c8a
Update test_all_estimators_v2.py
fkiraly 53747e0
Update _tft_pkg_v2.py
fkiraly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
pytorch_forecasting/models/temporal_fusion_transformer/tft_v2_metadata.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
"""TFT metadata container.""" | ||
|
||
from pytorch_forecasting.models.base._base_object import _BasePtForecasterV2 | ||
|
||
|
||
class TFTMetadata(_BasePtForecasterV2): | ||
"""TFT metadata container.""" | ||
|
||
_tags = { | ||
"info:name": "TFT", | ||
"authors": ["phoeenniixx"], | ||
"capability:exogenous": True, | ||
"capability:multivariate": True, | ||
"capability:pred_int": True, | ||
"capability:flexible_history_length": False, | ||
} | ||
|
||
@classmethod | ||
def get_model_cls(cls): | ||
"""Get model class.""" | ||
from pytorch_forecasting.models.temporal_fusion_transformer._tft_v2 import TFT | ||
|
||
return TFT | ||
|
||
@classmethod | ||
def _get_test_datamodule_from(cls, trainer_kwargs): | ||
"""Create test dataloaders from trainer_kwargs - following v1 pattern.""" | ||
from pytorch_forecasting.data.data_module import ( | ||
EncoderDecoderTimeSeriesDataModule, | ||
) | ||
from pytorch_forecasting.tests._conftest import make_datasets_v2 | ||
from pytorch_forecasting.tests._data_scenarios import data_with_covariates_v2 | ||
|
||
data_with_covariates = data_with_covariates_v2() | ||
|
||
data_loader_default_kwargs = dict( | ||
target="target", | ||
group_ids=["agency_encoded", "sku_encoded"], | ||
add_relative_time_idx=True, | ||
) | ||
|
||
data_loader_kwargs = trainer_kwargs.get("data_loader_kwargs", {}) | ||
data_loader_default_kwargs.update(data_loader_kwargs) | ||
|
||
datasets_info = make_datasets_v2( | ||
data_with_covariates, **data_loader_default_kwargs | ||
) | ||
|
||
training_dataset = datasets_info["training_dataset"] | ||
validation_dataset = datasets_info["validation_dataset"] | ||
training_max_time_idx = datasets_info["training_max_time_idx"] | ||
|
||
max_encoder_length = data_loader_kwargs.get("max_encoder_length", 4) | ||
max_prediction_length = data_loader_kwargs.get("max_prediction_length", 3) | ||
add_relative_time_idx = data_loader_kwargs.get("add_relative_time_idx", True) | ||
batch_size = data_loader_kwargs.get("batch_size", 2) | ||
|
||
train_datamodule = EncoderDecoderTimeSeriesDataModule( | ||
time_series_dataset=training_dataset, | ||
max_encoder_length=max_encoder_length, | ||
max_prediction_length=max_prediction_length, | ||
add_relative_time_idx=add_relative_time_idx, | ||
batch_size=batch_size, | ||
train_val_test_split=(0.8, 0.2, 0.0), | ||
) | ||
|
||
val_datamodule = EncoderDecoderTimeSeriesDataModule( | ||
time_series_dataset=validation_dataset, | ||
max_encoder_length=max_encoder_length, | ||
max_prediction_length=max_prediction_length, | ||
min_prediction_idx=training_max_time_idx, | ||
add_relative_time_idx=add_relative_time_idx, | ||
batch_size=batch_size, | ||
train_val_test_split=(0.0, 1.0, 0.0), | ||
) | ||
|
||
test_datamodule = EncoderDecoderTimeSeriesDataModule( | ||
time_series_dataset=validation_dataset, | ||
max_encoder_length=max_encoder_length, | ||
max_prediction_length=max_prediction_length, | ||
min_prediction_idx=training_max_time_idx, | ||
add_relative_time_idx=add_relative_time_idx, | ||
batch_size=1, | ||
train_val_test_split=(0.0, 0.0, 1.0), | ||
) | ||
|
||
train_datamodule.setup("fit") | ||
val_datamodule.setup("fit") | ||
test_datamodule.setup("test") | ||
|
||
train_dataloader = train_datamodule.train_dataloader() | ||
val_dataloader = val_datamodule.val_dataloader() | ||
test_dataloader = test_datamodule.test_dataloader() | ||
|
||
return { | ||
"train": train_dataloader, | ||
"val": val_dataloader, | ||
"test": test_dataloader, | ||
"data_module": train_datamodule, | ||
} | ||
|
||
@classmethod | ||
def get_test_train_params(cls): | ||
"""Return testing parameter settings for the trainer. | ||
|
||
Returns | ||
------- | ||
params : dict or list of dict, default = {} | ||
Parameters to create testing instances of the class | ||
Each dict are parameters to construct an "interesting" test instance, i.e., | ||
`MyClass(**params)` or `MyClass(**params[i])` creates a valid test instance. | ||
`create_test_instance` uses the first (or only) dictionary in `params` | ||
""" | ||
return [ | ||
{}, | ||
dict( | ||
hidden_size=25, | ||
attention_head_size=5, | ||
), | ||
dict( | ||
data_loader_kwargs=dict(max_encoder_length=5, max_prediction_length=3) | ||
), | ||
dict( | ||
hidden_size=24, | ||
attention_head_size=8, | ||
data_loader_kwargs=dict( | ||
max_encoder_length=5, | ||
max_prediction_length=3, | ||
add_relative_time_idx=False, | ||
), | ||
), | ||
dict( | ||
hidden_size=12, | ||
data_loader_kwargs=dict(max_encoder_length=7, max_prediction_length=10), | ||
), | ||
dict(attention_head_size=2), | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.