-
Notifications
You must be signed in to change notification settings - Fork 80
Add metric_per_segment_distribution_plot
#666
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Example script: import matplotlib.pyplot as plt
import pandas as pd
from etna.analysis import metric_per_segment_distribution_plot
from etna.datasets import TSDataset
from etna.metrics import MAE
from etna.metrics import SMAPE
from etna.models import ProphetModel
from etna.pipeline import Pipeline
def main():
df = pd.read_csv("examples/data/example_dataset.csv", parse_dates=["timestamp"])
df_wide = TSDataset.to_dataset(df)
ts = TSDataset(df=df_wide, freq="D")
pipeline = Pipeline(model=ProphetModel(), horizon=10)
metrics_df, _, _ = pipeline.backtest(ts=ts, n_folds=3, metrics=[MAE(), SMAPE()])
metric_per_segment_distribution_plot(
metrics_df=metrics_df,
metric_name="MAE",
plot_type="hist",
per_fold_aggregation_mode=None,
seaborn_params=dict(multiple="stack"),
)
plt.savefig("plot_hist_no_agg")
metric_per_segment_distribution_plot(
metrics_df=metrics_df, metric_name="MAE", plot_type="box", per_fold_aggregation_mode=None
)
plt.savefig("plot_box_no_agg")
metric_per_segment_distribution_plot(
metrics_df=metrics_df, metric_name="MAE", plot_type="violin", per_fold_aggregation_mode=None
)
plt.savefig("plot_violin_no_agg")
metric_per_segment_distribution_plot(
metrics_df=metrics_df, metric_name="MAE", plot_type="hist", per_fold_aggregation_mode="mean"
)
plt.savefig("plot_hist_mean")
metric_per_segment_distribution_plot(
metrics_df=metrics_df, metric_name="MAE", plot_type="box", per_fold_aggregation_mode="mean"
)
plt.savefig("plot_box_mean")
metric_per_segment_distribution_plot(
metrics_df=metrics_df, metric_name="MAE", plot_type="violin", per_fold_aggregation_mode="mean"
)
plt.savefig("plot_violin_mean")
# case of already aggregated metrics
pipeline = Pipeline(model=ProphetModel(), horizon=10)
metrics_df, _, _ = pipeline.backtest(ts=ts, n_folds=3, metrics=[MAE(), SMAPE()], aggregate_metrics=True)
metric_per_segment_distribution_plot(
metrics_df=metrics_df, metric_name="MAE", plot_type="hist", per_fold_aggregation_mode=None
)
plt.savefig("plot_hist_is_agg")
if __name__ == "__main__":
main() |
🚀 Deployed on https://deploy-preview-666--etna-docs.netlify.app |
Codecov Report
@@ Coverage Diff @@
## master #666 +/- ##
==========================================
- Coverage 84.45% 84.06% -0.39%
==========================================
Files 119 119
Lines 6322 6370 +48
==========================================
+ Hits 5339 5355 +16
- Misses 983 1015 +32
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
iKintosh
previously approved these changes
Apr 29, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# Conflicts: # etna/analysis/plotters.py
iKintosh
approved these changes
Apr 29, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
IMPORTANT: Please do not create a Pull Request without creating an issue first.
Before submitting (must do checklist)
Type of Change
Proposed Changes
Look #654.
Related Issue
#654.
Closing issues
Closes #654.