Skip to content

Add plot_imputation #598

Merged
merged 5 commits into from
Mar 14, 2022
Merged

Add plot_imputation #598

merged 5 commits into from
Mar 14, 2022

Conversation

Mr-Geekman
Copy link
Contributor

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

Related Issue

#588.

Closing issues

Closes #588.

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

Mr-Geekman commented Mar 11, 2022

Example script

import matplotlib.pyplot as plt
import pandas as pd

from etna.analysis import plot_imputation
from etna.datasets import TSDataset
from etna.transforms import DensityOutliersTransform
from etna.transforms import TimeSeriesImputerTransform


def main():
    df = pd.read_csv("examples/data/example_dataset.csv", parse_dates=["timestamp"])
    ts = TSDataset(df=TSDataset.to_dataset(df), freq="D")
    outliers_transform = DensityOutliersTransform(in_column="target", distance_coef=1.0)
    ts.fit_transform(transforms=[outliers_transform])

    # imputers
    imputer_zero = TimeSeriesImputerTransform(in_column="target", strategy="zero")
    imputer_running_mean = TimeSeriesImputerTransform(in_column="target", strategy="running_mean")
    imputer_forward_fill = TimeSeriesImputerTransform(in_column="target", strategy="forward_fill")

    # plots
    plot_imputation(ts=ts, imputer=imputer_zero)
    plt.savefig("imputer_zero")

    plot_imputation(ts=ts, imputer=imputer_running_mean)
    plt.savefig("imputer_running_mean")

    plot_imputation(ts=ts, imputer=imputer_forward_fill)
    plt.savefig("imputer_forward_fill")


if __name__ == "__main__":
    main()

imputer_zero:
imputer_zero

imputer_running_mean:
imputer_running_mean

imputer_forward_fill:
imputer_forward_fill

@codecov-commenter
Copy link

codecov-commenter commented Mar 11, 2022

Codecov Report

Merging #598 (72339d8) into master (a321f5a) will decrease coverage by 31.94%.
The diff coverage is 11.76%.

@@             Coverage Diff             @@
##           master     #598       +/-   ##
===========================================
- Coverage   85.35%   53.41%   -31.95%     
===========================================
  Files         117      117               
  Lines        5789     5806       +17     
===========================================
- Hits         4941     3101     -1840     
- Misses        848     2705     +1857     
Impacted Files Coverage Δ
etna/analysis/plotters.py 11.87% <6.25%> (-4.94%) ⬇️
etna/analysis/__init__.py 100.00% <100.00%> (ø)
etna/commands/__init__.py 0.00% <0.00%> (-100.00%) ⬇️
etna/commands/backtest_command.py 0.00% <0.00%> (-96.43%) ⬇️
etna/commands/forecast_command.py 0.00% <0.00%> (-92.00%) ⬇️
etna/commands/__main__.py 0.00% <0.00%> (-87.50%) ⬇️
etna/commands/resolvers.py 0.00% <0.00%> (-80.00%) ⬇️
etna/analysis/outliers/density_outliers.py 22.44% <0.00%> (-75.52%) ⬇️
etna/datasets/datasets_generation.py 26.47% <0.00%> (-73.53%) ⬇️
etna/transforms/timestamp/time_flags.py 27.02% <0.00%> (-72.98%) ⬇️
... and 67 more

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

@martins0n martins0n self-requested a review March 14, 2022 07:48
Copy link
Contributor

@martins0n martins0n left a comment

Choose a reason for hiding this comment

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

👍

@martins0n martins0n enabled auto-merge (squash) March 14, 2022 18:50
@martins0n martins0n merged commit e16d25d into master Mar 14, 2022
@iKintosh iKintosh deleted the issue-588 branch March 22, 2022 08:39
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 Imputation plot
3 participants