Skip to content

[BUG] Something went wrong with multi-index if backtest (issue #461) #771

Merged
merged 35 commits into from
Jul 13, 2022

Conversation

mvakhmenin
Copy link
Contributor

@mvakhmenin mvakhmenin commented Jun 22, 2022

IMPORTANT: Please do not create a Pull Request without creating an issue first.

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?

Type of Change

  • Examples / docs / tutorials / contributors update
  • Bug fix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves an existing feature)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Proposed Changes

Related Issue

Closing issues

closes #461

@mvakhmenin
Copy link
Contributor Author

mvakhmenin commented Jun 22, 2022

I did not update changlog and tests as I am not sure, that I corrected all the issues in the bug-report

@mvakhmenin mvakhmenin changed the title issue #461 [BUG] Something went wrong with multi-index if backtest (issue #461) Jun 22, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jun 22, 2022

Codecov Report

Merging #771 (b505d72) into master (0bb7a64) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #771   +/-   ##
=======================================
  Coverage   83.81%   83.81%           
=======================================
  Files         123      123           
  Lines        6895     6896    +1     
=======================================
+ Hits         5779     5780    +1     
  Misses       1116     1116           
Impacted Files Coverage Δ
etna/pipeline/base.py 94.53% <100.00%> (+0.02%) ⬆️

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

@@ -456,6 +456,7 @@ def _get_backtest_forecasts(self) -> pd.DataFrame:
forecast = forecast.join(fold_number_df)
forecasts_list.append(forecast)
forecasts = pd.concat(forecasts_list)
forecasts.sort_index(axis="columns", ascending=[True, False], inplace=True)
return forecasts
Copy link
Contributor

Choose a reason for hiding this comment

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

We dont need specify ascending order here.

Copy link
Contributor Author

@mvakhmenin mvakhmenin Jun 30, 2022

Choose a reason for hiding this comment

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

@martins0n
Checks failed with the following error. I cannot understand, what should I do
ImportError while loading conftest '/home/runner/work/etna/etna/tests/test_ensembles/conftest.py'. tests/test_ensembles/conftest.py:16: in <module> from etna.models import ProphetModel E ImportError: cannot import name 'ProphetModel' from 'etna.models' (/home/runner/work/etna/etna/etna/models/__init__.py) Error: Process completed with exit code 4.

Copy link
Contributor

@martins0n martins0n Jun 30, 2022

Choose a reason for hiding this comment

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

It's ok, will fix it today or next day

You can make futher changes and test locally, via command poetry run pytest tests -v --cov=etna -m "not long" --cov-report=xml and run linters via make lint

Copy link
Contributor

Choose a reason for hiding this comment

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

@mvakhmenin We've merged updates to master branch. You can rebase on updated master.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@martins0n
Tests fail without ascending order

Copy link
Contributor

@martins0n martins0n Jul 4, 2022

Choose a reason for hiding this comment

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

@mvakhmenin We don't expect such ordering anyway, it've just happened by chanse.

it's better to change fixtures in conftest to make tests pass

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@martins0n
I do not understand, what's the problem with lint

Copy link
Contributor

Choose a reason for hiding this comment

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

You can run linters locally and fix issues with command: make format and make lint

Current error could be fixed with make format I guess.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can find more information about contributing in guide

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.

Thank you for your PR!

  • Could you add test cases for that behaviour?
  • Could you add changelog record?

@@ -168,7 +168,7 @@ def step_ts() -> Tuple[TSDataset, pd.DataFrame, pd.DataFrame]:
forecast_df.columns = pd.MultiIndex.from_product(
[[segment], ["target", "fold_number"]], names=("segment", "feature")
)

forecast_df.sort_index(axis=1, inplace=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we fix it above at 168 line by hand changing target and fold_number to make it more determinitic?

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.

👍

@martins0n martins0n merged commit f1befc5 into tinkoff-ai:master Jul 13, 2022
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] Something went wrong with multi-index if backtest
3 participants