Skip to content

Teach BATS/TBATS to work with in-sample, out-sample predictions correctly #806

Merged
merged 10 commits into from Jul 22, 2022

Conversation

Mr-Geekman
Copy link
Contributor

@Mr-Geekman Mr-Geekman commented Jul 19, 2022

Before submitting (must do checklist)

  • Did you read the contribution guide?
  • Did you update the docs? We use Numpy format for all the methods and classes.
  • Did you write any new necessary tests?
  • Did you update the CHANGELOG?

Proposed Changes

Look #800.

Closing issues

Closes #800.

@github-actions
Copy link

github-actions bot commented Jul 19, 2022

🚀 Deployed on https://deploy-preview-806--etna-docs.netlify.app

@github-actions github-actions bot temporarily deployed to pull request July 19, 2022 14:06 Inactive
@codecov-commenter
Copy link

codecov-commenter commented Jul 19, 2022

Codecov Report

Merging #806 (10cc33e) into master (e475d5d) will increase coverage by 0.04%.
The diff coverage is 96.66%.

@@            Coverage Diff             @@
##           master     #806      +/-   ##
==========================================
+ Coverage   84.01%   84.05%   +0.04%     
==========================================
  Files         125      126       +1     
  Lines        7193     7220      +27     
==========================================
+ Hits         6043     6069      +26     
- Misses       1150     1151       +1     
Impacted Files Coverage Δ
etna/models/tbats.py 94.64% <93.75%> (-0.71%) ⬇️
etna/models/utils.py 100.00% <100.00%> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@github-actions github-actions bot temporarily deployed to pull request July 19, 2022 14:34 Inactive
@martins0n martins0n self-requested a review July 20, 2022 07:46
return self

def _determine_num_steps_to_forecast(self, last_test_timestamp: pd.Timestamp) -> int:
Copy link
Contributor

Choose a reason for hiding this comment

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

May be we should get this function out of class -- and add it to utils.
I guess something like this logic we have already

def predict(self, df: pd.DataFrame, prediction_interval: bool, quantiles: Iterable[float]) -> pd.DataFrame:
if self._fitted_model is None:
raise ValueError("Model is not fitted! Fit the model before calling predict method!")

if df["timestamp"].min() <= self._last_train_timestamp:
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's rewrite message smth like: in-sample predictions are not supported by current implementation

if df["timestamp"].min() <= self._last_train_timestamp:
raise NotImplementedError("It is not possible to make in-sample predictions with BATS/TBATS model!")

steps_to_forecast = self._determine_num_steps_to_forecast(df["timestamp"].max())
Copy link
Contributor

@martins0n martins0n Jul 20, 2022

Choose a reason for hiding this comment

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

May we should raise Exception and stop execution in case if we have mix of in-sample and out-of-sample data?

It looks current behaviour may be error prone

P.S. id we are going to leave it as is. It seems we don't have tests for such cases.

@github-actions github-actions bot temporarily deployed to pull request July 21, 2022 11:45 Inactive
Copy link
Contributor

@martins0n martins0n left a comment

Choose a reason for hiding this comment

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

Some small fixes are needed

etna/models/sarimax.py Outdated Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to pull request July 22, 2022 07:52 Inactive
@martins0n martins0n enabled auto-merge (squash) July 22, 2022 07:53
@github-actions github-actions bot temporarily deployed to pull request July 22, 2022 07:56 Inactive
@martins0n martins0n merged commit 41fcce4 into master Jul 22, 2022
@Mr-Geekman Mr-Geekman deleted the issue-800 branch July 22, 2022 08:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Teach BATS/TBATS to work with in-sample, out-sample predictions correctly
3 participants