Skip to content

Commit

Permalink
Backports v0.13.5 (#3004)
Browse files Browse the repository at this point in the history
* Raise warning in `QuantileForecast.mean` when mean is not there (#2843)

* [R] Bug fix for running R methods via ParallelizedPredictor (#2983)

* Fix Forecast plot method (#3006)

Latest matplotlib update had broken it since we were using internal API

* fixup to support py37

---------

Co-authored-by: Syama Sundar Rangapuram <[email protected]>
  • Loading branch information
lostella and rshyamsundar authored Sep 18, 2023
1 parent fd816ce commit 234dc4e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/gluonts/ext/r_forecast/_univariate_predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def __init__(
params["intervals"] = sorted(
set([level for level, _ in intervals_info])
)
params.pop("quantiles")

self.params.update(params)

Expand Down
11 changes: 9 additions & 2 deletions src/gluonts/model/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# permissions and limitations under the License.

import re
import logging
from dataclasses import field
from typing import Callable, Dict, List, Optional, Union, Tuple

Expand All @@ -22,6 +23,8 @@
from gluonts.core.component import validated
from gluonts import maybe

logger = logging.getLogger(__name__)


def _linear_interpolation(
xs: np.ndarray, ys: np.ndarray, x: float
Expand Down Expand Up @@ -313,7 +316,7 @@ def plot(
# If no color is provided, we use matplotlib's internal color cycle.
# Note: This is an internal API and might change in the future.
color = maybe.unwrap_or_else(
color, lambda: next(ax._get_lines.prop_cycler)["color"]
color, lambda: ax._get_lines.get_next_color()
)

# Plot median forecast
Expand Down Expand Up @@ -656,7 +659,11 @@ def mean(self) -> np.ndarray:
"""
if "mean" in self._forecast_dict:
return self._forecast_dict["mean"]

logger.warning(
"The mean prediction is not stored in the forecast data; "
"the median is being returned instead. "
"This behaviour may change in the future."
)
return self.quantile("p50")

def dim(self) -> int:
Expand Down

0 comments on commit 234dc4e

Please sign in to comment.