Skip to content

Add MADTransform #441

Merged
merged 7 commits into from
Jan 14, 2022
Merged

Add MADTransform #441

merged 7 commits into from
Jan 14, 2022

Conversation

julia-shenshina
Copy link
Contributor

@julia-shenshina julia-shenshina commented Jan 10, 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 #426

@julia-shenshina julia-shenshina self-assigned this Jan 10, 2022
name of processed column
window: int
size of window to aggregate
out_column: str, optional
Copy link
Collaborator

Choose a reason for hiding this comment

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

Many it would be better to put it in the last place

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed it in all the statistics Transforms 👌🏼

self.min_periods = min_periods
self.fillna = fillna
self.out_column = out_column
super().__init__(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better to follow the order of the parameters of the superclass

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Arguments orders in WindowStatisticsTransform and all it's inheritors are different.
I think it's better to make MADTransform's argument order the same with MeanTransform, MaxTransform, etc.
Moreover, I think that we should change the arguments order in WindowStatisticsTransform but not at this PR (looks like big change).

df["target"] = [-1, 1, 3, 2, 4, 9, 8, 5, 6, 0]
df["segment"] = "segment_1"

df = df.pivot(index="timestamp", columns="segment")
Copy link
Collaborator

Choose a reason for hiding this comment

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

TSDataset.to_dataset ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed all the fixtures here 👌🏼

@@ -177,6 +210,7 @@ def test_std_feature(simple_df_for_agg: pd.DataFrame, window: int, periods: int,
MeanTransform(in_column="target", window=5),
StdTransform(in_column="target", window=5),
StdTransform(in_column="target", window=5),
MADTransform(in_column="target", window=5),
),
)
def test_fit_transform_with_nans(transform, ts_diff_endings):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a method was created to check that transforms simply don't fail working with NaNs. May you also create test that checks that this transform handles NaNs correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -39,6 +54,8 @@ def simple_df_for_agg() -> pd.DataFrame:
(MeanTransform, "test_mean"),
(StdTransform, None),
(StdTransform, "test_std"),
(MADTransform, None),
(MADTransform, "test_mad"),
),
)
def test_interface_simple(simple_df_for_agg: pd.DataFrame, class_name: Any, out_column: str):
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 it is better to add docstring with description to the test like "Test that everything is fine"(oversimplified).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@iKintosh says no comments for tests 😄

@codecov-commenter
Copy link

codecov-commenter commented Jan 12, 2022

Codecov Report

Merging #441 (686c37c) into master (5ef9223) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #441      +/-   ##
==========================================
+ Coverage   87.64%   87.68%   +0.03%     
==========================================
  Files         112      112              
  Lines        5276     5293      +17     
==========================================
+ Hits         4624     4641      +17     
  Misses        652      652              
Impacted Files Coverage Δ
etna/transforms/__init__.py 100.00% <100.00%> (ø)
etna/transforms/math/__init__.py 100.00% <100.00%> (ø)
etna/transforms/math/statistics.py 98.54% <100.00%> (+0.17%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5ef9223...686c37c. Read the comment docs.

@@ -177,6 +227,7 @@ def test_std_feature(simple_df_for_agg: pd.DataFrame, window: int, periods: int,
MeanTransform(in_column="target", window=5),
StdTransform(in_column="target", window=5),
StdTransform(in_column="target", window=5),
Copy link
Collaborator

Choose a reason for hiding this comment

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

May you also remove duplicates from the list of parameters here:pray:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@julia-shenshina julia-shenshina merged commit 445fe85 into master Jan 14, 2022
@martins0n martins0n deleted the issue426 branch January 21, 2022 09:39
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 MADTransform
4 participants