Skip to content

Create assemble_pipelines 717 #774

Merged
merged 31 commits into from
Jul 14, 2022
Merged

Create assemble_pipelines 717 #774

merged 31 commits into from
Jul 14, 2022

Conversation

scanhex12
Copy link
Collaborator

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

Closing issues

closes #717

@github-actions
Copy link

github-actions bot commented Jun 27, 2022

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

@github-actions github-actions bot temporarily deployed to pull request June 27, 2022 14:27 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 28, 2022 07:32 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 28, 2022 08:34 Inactive
@iKintosh iKintosh self-requested a review June 28, 2022 11:45
@github-actions github-actions bot temporarily deployed to pull request June 28, 2022 13:44 Inactive
@codecov-commenter
Copy link

codecov-commenter commented Jun 28, 2022

Codecov Report

Merging #774 (77cec5b) into master (f1befc5) will increase coverage by 0.07%.
The diff coverage is 97.43%.

@@            Coverage Diff             @@
##           master     #774      +/-   ##
==========================================
+ Coverage   83.80%   83.87%   +0.07%     
==========================================
  Files         123      124       +1     
  Lines        6902     6941      +39     
==========================================
+ Hits         5784     5822      +38     
- Misses       1118     1119       +1     
Impacted Files Coverage Δ
etna/pipeline/assembling_pipelines.py 97.36% <97.36%> (ø)
etna/pipeline/__init__.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 1, 2022 09:58 Inactive
Copy link
Contributor

@iKintosh iKintosh left a comment

Choose a reason for hiding this comment

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

Code looks good, however it does not work as stated in the issue description.

It should match not only model-horizon, but transforms-models in case if we want different transform for different models. The example of this behaviour could be seen in the issue description.

Important note: if we want to skip transform for the model we use None instead

assemble_pipelines([Catboost(), Prophet()], [TrendTransform(in_column="target"), [LagTransform(lags=[1,2,3], in_column="target"), **None**], [1, 2])

Pipeline(model=Catboost(), transforms=[TrendTransform(in_column="target"), LagTransform(lags=[1,2,3], in_column="target")], horizon=1)
Pipeline(model=Prophet(), transforms=[TrendTransform(in_column="target")], horizon=2)

Also there are not enough tests.
You should add test case if we have different models for different horizons, as well as different transforms for different models.


def assemble_pipelines(
models: Union[BaseModel, Sequence[BaseModel]],
transforms: Sequence[Transform],
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be able to work with cases such as

assemble_pipelines(Catboost(), [TrendTransform(in_column="target"), [LagTransform(lags=[1,2,3], in_column="target"), LagTransform(lags=[2,3,4], in_column="target")]], [1, 2])

And as a result it should create the following two pipelines:

Pipeline(model=Catboost(), transforms=[TrendTransform(in_column="target"), LagTransform(lags=[1,2,3], in_column="target")], horizon=1)
Pipeline(model=Catboost(), transforms=[TrendTransform(in_column="target"), LagTransform(lags=[2,3,4], in_column="target")], horizon=2)

from etna.transforms import TrendTransform


def test_not_equal_lengths():
Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea for test! 👍

@github-actions github-actions bot temporarily deployed to pull request July 5, 2022 23:45 Inactive
@iKintosh iKintosh self-requested a review July 6, 2022 12:58
@github-actions github-actions bot temporarily deployed to pull request July 7, 2022 13:52 Inactive
@github-actions github-actions bot temporarily deployed to pull request July 7, 2022 14:18 Inactive
horizons:
Sequence of horizons

Raises
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should swap raises and returns blocks and add empty line between them.

@github-actions github-actions bot temporarily deployed to pull request July 14, 2022 07:32 Inactive
@@ -1,3 +1,4 @@
from etna.pipeline.autoregressive_pipeline import AutoRegressivePipeline
from etna.pipeline.base import FoldMask
from etna.pipeline.pipeline import Pipeline
from etna.pipeline.pipelines_fabric import assemble_pipelines
Copy link
Contributor

Choose a reason for hiding this comment

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

fabric -- is a material to make clothes. Try smth like "assmbling_pipelines" for file name.

Copy link
Contributor

Choose a reason for hiding this comment

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

pipeline_assembling

@github-actions github-actions bot temporarily deployed to pull request July 14, 2022 08:46 Inactive
transforms: Sequence[Union[Transform, Sequence[Optional[Transform]]]],
horizons: Union[int, Sequence[int]],
) -> List[Pipeline]:
"""Create pipelines from input horizons and models or sequence of models.
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 just:
Create pipelines with broadcasting from models, transforms and horizons.

Parameters
----------
models:
Instance or Sequence of the etna Model
Copy link
Contributor

Choose a reason for hiding this comment

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

Instance of Sequence of models

models:
Instance or Sequence of the etna Model
transforms:
Sequence of the transforms
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should explain here how broadcasting is made. It is not obvious.

horizons: Union[int, Sequence[int]],
) -> List[Pipeline]:
"""Create pipelines from input horizons and models or sequence of models.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or we should add description about broadcasting here.

iKintosh
iKintosh previously approved these changes Jul 14, 2022
Copy link
Contributor

@iKintosh iKintosh left a comment

Choose a reason for hiding this comment

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

Looks good. Ready to merge. Fixed import errors.

ValueError:
If the length of models sequence not equals to length of horizons sequence.

Examples
Copy link
Contributor

Choose a reason for hiding this comment

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

👍
This is a good practice

@github-actions github-actions bot temporarily deployed to pull request July 14, 2022 09:33 Inactive
@github-actions github-actions bot temporarily deployed to pull request July 14, 2022 10:24 Inactive
@github-actions github-actions bot temporarily deployed to pull request July 14, 2022 10:30 Inactive
@github-actions github-actions bot temporarily deployed to pull request July 14, 2022 10:37 Inactive
@github-actions github-actions bot temporarily deployed to pull request July 14, 2022 10:59 Inactive
@github-actions github-actions bot temporarily deployed to pull request July 14, 2022 11:05 Inactive
@scanhex12 scanhex12 merged commit ea68310 into master Jul 14, 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.

Create assemble_pipelines
4 participants