New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ValueError for backtesting_forecaster when interval is provided #177
Comments
As far as I understood, the error comes from this file: you can see folowing lines: predictions_interval = self._estimate_boot_interval(
steps = steps,
last_window = copy(last_window_values_original),
exog = copy(exog_values_original),
interval = interval,
n_boot = n_boot,
random_state = random_state,
in_sample_residuals = in_sample_residuals
)
predictions = np.column_stack((predictions, predictions_interval))
predictions = pd.DataFrame(
data = predictions,
index = expand_index(
index = last_window_index,
steps = steps
),
columns = ['pred', 'lower_bound', 'upper_bound']
) according to your documentation: """
Returns
-------
prediction_interval : numpy ndarray, shape (steps, 2)
Interval estimated for each prediction by bootstrapping:
first column = lower bound of the interval.
second column= upper bound interval of the interval.
"""
I think Do you agree with that or is their something I don't understand? |
Hi @tkaraouzene, @JavierEscobarOrtiz I think we should explain this better in the docs. |
Hi ! Thanks for this information. def check_interval(interval: Optional[list[int]]) -> None:
"""Check provided confidence interval sequence is valid.
Parameters
----------
interval : list[int], optional
Confidence of the prediction interval estimated. Sequence of percentiles
to compute, which must be between 0 and 100 inclusive. If `None`, no check are made.
"""
if interval is not None:
if len(interval) != 2:
raise ValueError(
f"Interval sequence should contain exactly 2 values, respectively lower and upper interval bounds."
)
lower_bound = interval[0]
upper_bound = interval[1]
if lower_bound >= interval[1]:
raise ValueError(
f"Lower interval bound ({lower_bound}) has to be strictly smaller than upper interval bound "
f"({upper_bound}."
)
if interval[0] < 0:
raise ValueError(f"Lower interval bound ({lower_bound}) has to be >= 0.")
if interval[1] > 100:
raise ValueError(f"Upper interval bound ({upper_bound}) has to be <= 100.") |
I like this check @tkaraouzene We will add it in the new release. |
Hi @JoaquinAmatRodrigo ! If you want I can propose a pull request |
Hi @tkaraouzene, |
Hi @JoaquinAmatRodrigo !
I didn't see you've added the code so I made a PR (I saw your code thanks to the merge conflicts) 🤦♂️...
Yes perfect, thank you |
Hello @tkaraouzene, We are closing this issue. Thank you very much for your help. You can see it mentioned in the changelog: [0.5.0] - [Dev]Added
... |
Hi !
I'm trying to use your
backtesting_forecaster
and when I use and ask for intervals, it leads to
ValueError
When no intervals are asked, all works perfectly:
[in]:
[out]:
however asking for intervals leads to
ValueError
[in]:
[out]:
The text was updated successfully, but these errors were encountered: