Skip to content

Commit

Permalink
Merge branch 'master' into issue-528
Browse files Browse the repository at this point in the history
  • Loading branch information
egoriyaa authored Dec 28, 2024
2 parents 2b3e3fc + 7fab7c7 commit abdf5e1
Show file tree
Hide file tree
Showing 5 changed files with 679 additions and 1,893 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add parameter `missing_mode` into `R2` and `MedAE` metrics ([#537](https://github.com/etna-team/etna/pull/537))
- Update `analysis.forecast.plots.plot_metric_per_segment` to handle `None` from metrics ([#540](https://github.com/etna-team/etna/pull/540))
- Add parameter `missing_mode` into `RMSE` and `MSLE` metrics ([#542](https://github.com/etna-team/etna/pull/542))
- Update `analysis.forecast.plots.metric_per_segment_distribution_plot` to handle `None` from metrics ([#543](https://github.com/etna-team/etna/pull/543))
-
-
-
- Add example on using custom `params_to_tune` in `Tune` ([#547](https://github.com/etna-team/etna/pull/547))

### Fixed
- Fix working with `embedding_sizes` in `202-NN_examples` notebook ([#489](https://github.com/etna-team/etna/pull/489))
Expand Down
19 changes: 17 additions & 2 deletions etna/analysis/forecast/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ def plot_metric_per_segment(
Warnings
--------
UserWarning:
There are segments without non-missing metric values.
There are segments with all missing metric values.
UserWarning:
Some segments have different set of folds to be aggregated on due to missing values.
"""
Expand Down Expand Up @@ -803,7 +803,12 @@ def metric_per_segment_distribution_plot(
seaborn_params: Optional[Dict[str, Any]] = None,
figsize: Tuple[int, int] = (10, 5),
):
"""Plot per-segment metrics distribution.
"""Plot distribution of metric values over all segments.
If for some segment all metric values are missing, it isn't plotted, and the warning is raised.
If some segments have different set of folds with non-missing metrics,
it can lead to incompatible values between folds. The warning is raised in such case.
Parameters
----------
Expand Down Expand Up @@ -831,6 +836,13 @@ def metric_per_segment_distribution_plot(
if ``metric_name`` isn't present in ``metrics_df``
NotImplementedError:
unknown ``per_fold_aggregation_mode`` is given
Warnings
--------
UserWarning:
There are segments with all missing metric values.
UserWarning:
Some segments have different set of folds to be aggregated on due to missing values.
"""
if seaborn_params is None:
seaborn_params = {}
Expand All @@ -844,6 +856,9 @@ def metric_per_segment_distribution_plot(
if metric_name not in metrics_df.columns:
raise ValueError("Given metric_name isn't present in metrics_df")

_check_metrics_df_empty_segments(metrics_df=metrics_df, metric_name=metric_name)
_check_metrics_df_same_folds_for_each_segment(metrics_df=metrics_df, metric_name=metric_name)

# draw plot for each fold
if per_fold_aggregation_mode is None and "fold_number" in metrics_df.columns:
if plot_type_enum == MetricPlotType.hist:
Expand Down
2 changes: 1 addition & 1 deletion etna/analysis/forecast/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,6 @@ def _check_metrics_df_same_folds_for_each_segment(metrics_df: pd.DataFrame, metr
df = metrics_df[["segment", "fold_number", metric_name]]
# we don't take into account segments without any non-missing metrics, they are handled by other check
df = df.dropna(subset=[metric_name])
num_unique = df.groupby("segment")["fold_number"].apply(frozenset).nunique()
num_unique = df.groupby("segment", group_keys=False)["fold_number"].apply(frozenset).nunique()
if num_unique > 1:
warnings.warn("Some segments have different set of folds to be aggregated on due to missing values.")
Loading

0 comments on commit abdf5e1

Please sign in to comment.