Skip to content

Commit

Permalink
Raise warning in QuantileForecast.mean when mean is not there (#2843)
Browse files Browse the repository at this point in the history
  • Loading branch information
lostella authored Aug 30, 2023
1 parent b19238f commit 7c4b05d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion 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 @@ -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 7c4b05d

Please sign in to comment.