Skip to content

Add option to clip forecast based on context values#502

Open
abdulfatir wants to merge 1 commit into
amazon-science:mainfrom
abdulfatir:clip-forecast
Open

Add option to clip forecast based on context values#502
abdulfatir wants to merge 1 commit into
amazon-science:mainfrom
abdulfatir:clip-forecast

Conversation

@abdulfatir

Copy link
Copy Markdown
Contributor

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

assert context_minmax is not None
clamp_min = context_minmax[0] - clip_factor * loc_scale[1]
clamp_max = context_minmax[1] + clip_factor * loc_scale[1]
quantile_preds = quantile_preds.clamp(min=clamp_min, max=clamp_max)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this PR also take care of the issue of exploding predictions for all-NaN context?

import numpy as np
from chronos import Chronos2Pipeline

model = Chronos2Pipeline.from_pretrained("amazon/chronos-2")
model.predict(np.full((1, 1, 50), float("nan")), prediction_length=5)
# [tensor([[[-8.6131e+06, -1.0066e+07, -1.0386e+07, -1.0977e+07, -1.1329e+07],
#      [-1.2380e+05, -1.1830e+05, -1.5210e+05, -1.5608e+05, -1.5930e+05],
#      [-3.2544e+04, -2.7985e+04, -3.9638e+04, -4.4504e+04, -5.1272e+04],
#      ...

I have a hunch that this is also somehow related to the scale computation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants