Skip to content

plot trend #565

Merged
merged 12 commits into from
Mar 9, 2022
Merged

plot trend #565

merged 12 commits into from
Mar 9, 2022

Conversation

Ama16
Copy link
Contributor

@Ama16 Ama16 commented Feb 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 #515

@Ama16
Copy link
Contributor Author

Ama16 commented Feb 22, 2022

Снимок экрана 2022-02-22 в 12 23 49

Снимок экрана 2022-02-22 в 12 24 09

Снимок экрана 2022-02-22 в 12 24 24

Снимок экрана 2022-02-22 в 12 24 38

@codecov-commenter
Copy link

codecov-commenter commented Feb 22, 2022

Codecov Report

Merging #565 (a351975) into master (9ea2a81) will decrease coverage by 0.44%.
The diff coverage is 11.76%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #565      +/-   ##
==========================================
- Coverage   86.80%   86.36%   -0.45%     
==========================================
  Files         119      119              
  Lines        5739     5773      +34     
==========================================
+ Hits         4982     4986       +4     
- Misses        757      787      +30     
Impacted Files Coverage Δ
etna/analysis/plotters.py 17.50% <9.09%> (-1.06%) ⬇️
etna/analysis/__init__.py 100.00% <100.00%> (ø)

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 9ea2a81...a351975. Read the comment docs.

etna/analysis/plotters.py Outdated Show resolved Hide resolved
etna/analysis/plotters.py Outdated Show resolved Hide resolved
etna/analysis/plotters.py Outdated Show resolved Hide resolved
etna/analysis/plotters.py Outdated Show resolved Hide resolved
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.

Added comments on how it should be changed

Comment on lines 773 to 776
labels = [transform.__repr__() for transform in trend_transform]
labels_short = [i[: i.find("(")] for i in labels]
if len(np.unique(labels_short)) == len(labels_short):
labels = labels_short
Copy link
Contributor

@iKintosh iKintosh Feb 24, 2022

Choose a reason for hiding this comment

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

Let's make it a private method, that constructs labels.
It should have small docsting on how it works:

If only unique transform classes are used then show their short names (without parameters)
Otherwise show their full repr as label

Comment on lines 777 to 779
else:
df_detrend = [trend_transform.fit_transform(df.copy())]
labels = [trend_transform.__repr__()[: trend_transform.__repr__().find("(")]]
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this else because it repeats the code above.

Comment on lines 780 to 783
if isinstance(trend_transform, LinearTrendTransform) or isinstance(trend_transform, TheilSenTrendTransform):
for seg in segments:

linear_coeffs[seg] = ", k=" + str(trend_transform.segment_transforms[seg]._linear_model.coef_[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

This check should be done afterwards as a separate check.

@Ama16 Ama16 requested a review from iKintosh February 28, 2022 12:31
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.

Just one fix needed

]


def __get_labels_names(trend_transform, segments):
Copy link
Contributor

@iKintosh iKintosh Mar 1, 2022

Choose a reason for hiding this comment

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

Suggested change
def __get_labels_names(trend_transform, segments):
def _get_labels_names(trend_transform, segments):

https://stackoverflow.com/a/1301369/7415703

trend_transform = [trend_transform]

df_detrend = [transform.fit_transform(df.copy()) for transform in trend_transform]
labels, linear_coeffs = __get_labels_names(trend_transform, segments)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
labels, linear_coeffs = __get_labels_names(trend_transform, segments)
labels, linear_coeffs = _get_labels_names(trend_transform, segments)

Same as above https://stackoverflow.com/a/1301369/7415703

@Ama16 Ama16 requested a review from iKintosh March 6, 2022 08:28
@Ama16
Copy link
Contributor Author

Ama16 commented Mar 9, 2022

Снимок экрана 2022-03-09 в 11 03 23

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.

👍

@alex-hse-repository alex-hse-repository merged commit 8b3c063 into master Mar 9, 2022
@iKintosh iKintosh deleted the issue-515 branch March 22, 2022 08:36
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.

Trend Plot
4 participants