Skip to content

Fix bugs and documentation for cross_corr_plot #691

Merged
merged 4 commits into from May 17, 2022
Merged

Conversation

Mr-Geekman
Copy link
Contributor

@Mr-Geekman Mr-Geekman commented May 13, 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

Look #663.

Related Issue

#663.

Closing issues

Closes #663.

@Mr-Geekman Mr-Geekman added bug Something isn't working documentation Improvements or additions to documentation labels May 13, 2022
@Mr-Geekman Mr-Geekman self-assigned this May 13, 2022
@Mr-Geekman
Copy link
Contributor Author

Example script:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

from etna.datasets import TSDataset
from etna.analysis import cross_corr_plot


def main():
    df = pd.read_csv("examples/data/example_dataset.csv")
    df = TSDataset.to_dataset(df)
    ts = TSDataset(df, freq="D")

    cross_corr_plot(ts=ts, n_segments=6, columns_num=2, maxlags=20)
    plt.savefig("plot_columns_num_2.png")

    cross_corr_plot(ts=ts, n_segments=6, columns_num=3, maxlags=20)
    plt.savefig("plot_columns_num_3.png")

    cross_corr_plot(ts=ts, segments=["segment_a", "segment_b", "segment_c"], maxlags=20)
    plt.savefig("plot_set_segments.png")

    # add some NaNs at the beginning of one segment
    df.iloc[:5, 0] = np.NaN
    ts = TSDataset(df, freq="D")
    cross_corr_plot(ts=ts, maxlags=20)
    plt.savefig("plot_nans_beginning.png")

    # add some NaNs at the center of one segment
    df.iloc[10, 1] = np.NaN
    ts = TSDataset(df, freq="D")
    cross_corr_plot(ts=ts, maxlags=20)
    plt.savefig("plot_nans_middle.png")


if __name__ == "__main__":
    main()

plot_columns_num_2:
plot_columns_num_2

plot_columns_num_3:
plot_columns_num_3

plot_set_segments:
plot_set_segments

plot_nans_beginning:
plot_nans_beginning

plot_nans_middle:
plot_nans_middle

@github-actions
Copy link

github-actions bot commented May 13, 2022

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

@github-actions github-actions bot temporarily deployed to pull request May 13, 2022 10:35 Inactive
@codecov-commenter
Copy link

codecov-commenter commented May 13, 2022

Codecov Report

Merging #691 (49ea1c2) into master (24d36d6) will increase coverage by 0.15%.
The diff coverage is 70.37%.

@@            Coverage Diff             @@
##           master     #691      +/-   ##
==========================================
+ Coverage   84.09%   84.25%   +0.15%     
==========================================
  Files         119      119              
  Lines        6412     6432      +20     
==========================================
+ Hits         5392     5419      +27     
+ Misses       1020     1013       -7     
Impacted Files Coverage Δ
etna/analysis/plotters.py 21.27% <20.00%> (ø)
etna/analysis/eda_utils.py 54.23% <78.94%> (+5.57%) ⬆️
etna/analysis/utils.py 100.00% <100.00%> (ø)

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

@@ -33,11 +32,83 @@
plot_pacf = sm.graphics.tsa.plot_pacf


def _cross_correlation(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Try to rewrite this method using np.convolve to compute correlation and norms

@github-actions github-actions bot temporarily deployed to pull request May 17, 2022 12:51 Inactive
Copy link
Collaborator

@alex-hse-repository alex-hse-repository 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 enabled auto-merge (squash) May 17, 2022 12:57
@alex-hse-repository alex-hse-repository merged commit 93fe247 into master May 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some fixes for cross_corr_plot
3 participants