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

return single encoded covariates if called on single target #1193

Merged
merged 3 commits into from
Sep 13, 2022

Conversation

dennisbader
Copy link
Collaborator

Summary

  • fixes bug where add_encoders in RegressionModels was used in combination with a single target series in fit/predict
  • SequentialEncoder (called by model's add_encoders) now returns covariates as single TimeSeries when called on single series

Copy link
Contributor

@dumjax dumjax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good for me

Copy link
Contributor

@hrzn hrzn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dennisbader.
Do you know what was the impact? Were the encoders simply not working for single series (though I guess we would have cought it earlier)?

@dennisbader
Copy link
Collaborator Author

Reason was that SequentialEncoder always returned a list of TimeSeries even for single series input (@dumjax found this when testing for Shap integration).

For TorchForecastingModels this wasn't an issue as the series were internally converted to a list of series before using the encoders.
For RegressionModels the conversion isn't applied before the encodings are generated.

I only added RegressionModel encoder tests for the multi-ts case, which is why they didn't catch it.
Should I add another test for single-ts case?

@hrzn
Copy link
Contributor

hrzn commented Sep 12, 2022

I only added RegressionModel encoder tests for the multi-ts case, which is why they didn't catch it.
Should I add another test for single-ts case?

If you have a moment, this is always welcome, so we make sure the issue does not reproduce again.

@hrzn
Copy link
Contributor

hrzn commented Sep 13, 2022

As discussed, still to do:

  • Transform everything as a list in RegressionModels
  • Unify API for accessing model.encode_inference() in torch and regression models.

@dennisbader
Copy link
Collaborator Author

As discussed, still to do:

  • Transform everything as a list in RegressionModels
  • Unify API for accessing model.encode_inference() in torch and regression models.

I will open a new PR for these points as this is a bug fix.

If you have a moment, this is always welcome, so we make sure the issue does not reproduce again.

I checked and I had already added a test for single series in this PR:

# don't pass covariates, let them be generated by encoders. Test single target series input

@codecov-commenter
Copy link

Codecov Report

Base: 93.74% // Head: 93.73% // Decreases project coverage by -0.00% ⚠️

Coverage data is based on head (6ff4e22) compared to base (28ca88d).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1193      +/-   ##
==========================================
- Coverage   93.74%   93.73%   -0.01%     
==========================================
  Files          83       83              
  Lines        8407     8398       -9     
==========================================
- Hits         7881     7872       -9     
  Misses        526      526              
Impacted Files Coverage Δ
darts/utils/data/encoders.py 97.20% <100.00%> (+0.05%) ⬆️
darts/timeseries.py 92.23% <0.00%> (-0.07%) ⬇️
...arts/models/forecasting/torch_forecasting_model.py 87.45% <0.00%> (-0.05%) ⬇️
darts/models/forecasting/block_rnn_model.py 98.24% <0.00%> (-0.04%) ⬇️
darts/models/forecasting/nhits.py 99.27% <0.00%> (-0.01%) ⬇️
darts/datasets/__init__.py 100.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@dennisbader dennisbader merged commit 1c49f86 into master Sep 13, 2022
@dennisbader dennisbader deleted the fix/encoder_single_series branch September 13, 2022 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants