Skip to content

Add qq_plot #604

Merged
merged 7 commits into from
Mar 16, 2022
Merged

Add qq_plot #604

merged 7 commits into from
Mar 16, 2022

Conversation

Mr-Geekman
Copy link
Contributor

@Mr-Geekman Mr-Geekman commented Mar 15, 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 #591.

Related Issue

#591.

Closing issues

Closes #591.

@Mr-Geekman Mr-Geekman added the enhancement New feature or request label Mar 15, 2022
@Mr-Geekman Mr-Geekman self-assigned this Mar 15, 2022
@Mr-Geekman
Copy link
Contributor Author

Script for plotting:

import matplotlib.pyplot as plt
import pandas as pd

from etna.analysis import qq_plot
from etna.analysis.plotters import get_residuals
from etna.datasets import TSDataset
from etna.models import ProphetModel
from etna.pipeline import Pipeline

HORIZON = 14


def main():
    df = pd.read_csv("examples/data/example_dataset.csv", parse_dates=["timestamp"])
    ts = TSDataset(df=TSDataset.to_dataset(df), freq="D")
    ts_train, ts_test = ts.train_test_split(test_size=HORIZON)

    model = ProphetModel()
    pipeline = Pipeline(model=model, horizon=HORIZON)
    pipeline.fit(ts_train)

    forecast_ts = pipeline.forecast()
    residuals_ts = get_residuals(forecast_df=forecast_ts.to_pandas(), ts=ts)

    qq_plot(residuals_ts=residuals_ts)
    plt.savefig("qq_plot")

    qq_plot(residuals_ts=residuals_ts, qq_plot_params=dict(fit=True))
    plt.savefig("qq_plot_with_fit")

    qq_plot(residuals_ts=residuals_ts, qq_plot_params=dict(fit=True, line="45"))
    plt.savefig("qq_plot_with_fit_and_line")


if __name__ == "__main__":
    main()

qq_plot:
qq_plot

qq_plot_with_fit:
qq_plot_with_fit

qq_plot_with_fit_and_line:
qq_plot_with_fit_and_line

@codecov-commenter
Copy link

codecov-commenter commented Mar 15, 2022

Codecov Report

Merging #604 (88cb62a) into master (1ec52f2) will decrease coverage by 0.11%.
The diff coverage is 66.66%.

@@            Coverage Diff             @@
##           master     #604      +/-   ##
==========================================
- Coverage   85.25%   85.13%   -0.12%     
==========================================
  Files         117      118       +1     
  Lines        5860     5881      +21     
==========================================
+ Hits         4996     5007      +11     
- Misses        864      874      +10     
Impacted Files Coverage Δ
etna/analysis/eda_utils.py 18.91% <23.07%> (+0.40%) ⬆️
etna/analysis/__init__.py 100.00% <100.00%> (ø)
etna/analysis/plotters.py 17.53% <100.00%> (-1.70%) ⬇️
etna/analysis/utils.py 100.00% <100.00%> (ø)

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

columns_num: int = 2,
figsize: Tuple[int, int] = (10, 5),
):
"""Plot STL decomposition for segments.
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy-paste development)

@Mr-Geekman Mr-Geekman merged commit 734f1f5 into master Mar 16, 2022
@Mr-Geekman Mr-Geekman deleted the issue-591 branch March 16, 2022 12:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create qq_plot
3 participants