-
Notifications
You must be signed in to change notification settings - Fork 923
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
[QUESTION] Speed up scoring in ForecastAnomalyModel #2673
Comments
Hi @mcapuccini, yes and no :) Why Yes: It was the most robust parameter choice with the lowest implementation complexity. That means that all values were subject to the same forecast uncertainties. This "consistency" can play a crucial role when fitting the anomaly scorers., since they are trained on the error (or other statics) between the forecasts and the actuals. If we used a So, all in all, we chose to fix it for the beginning, to have a robust behavior and avoid some pitfalls (at the cost of efficiency). Why No: As you say, using |
Yeah, let's add it to the roadmap. To make our life maybe a bit easier, I would only support |
I see your point. With a windowed scorer though one could match the size of the window with the lookback plus the forecasting horizion. As I understand k-means scorer considers the forecasts for each window individually hence the accumulated forecasting error due an horizon >1 should be the same if the window matches lookback plus horizon. Does this make sense? |
@dennisbader I am trying out what you suggested but concatenating the historical forecast is also painfully slow: def concatenate_predictions(
historical_forecasts: List[List[TimeSeries]],
) -> List[TimeSeries]:
# Figure out tot iterations
total_iterations = sum(len(pred_list) - 1 for pred_list in historical_forecasts)
concatenated_forecasts = []
with tqdm(total=total_iterations, desc="Concatenating predictions") as pbar:
for pred_list in historical_forecasts:
concatenated = pred_list[0]
for pred in pred_list[1:]:
concatenated = concatenated.append(pred)
pbar.update(1)
concatenated_forecasts.append(concatenated)
return concatenated_forecasts Is there anything I can do to run this faster? |
If your forecasts are contiguous in time the you can use |
Cool! I assume that the results from historical_forecasts are contiguous in time. You meant trying something like this right? historical_forecasts = model.historical_forecasts(
series=train_target_series,
past_covariates=train_past_covariates,
future_covariates=train_future_covariates,
forecast_horizon=10,
stride=10,
last_points_only=False,
retrain=False,
verbose=True,
)
historical_forecasts = [concatenate(ts_list) for ts_list in historical_forecasts]
scorer.fit_from_prediction(train_target_series, historical_forecasts) |
Yes, exactly :) Yes, they will be contiguous with this config since |
Yes, it did :) |
Speed up scoring in ForecastAnomalyModel
Custom stride
Is there any reason for having a hard-coded stride (i.e. 1, code here) when running the
historical_forecasts
inForecastingAnomalyModel
? If the underlying model has a horizon of 10, I might as well set the stride to 10 to have 10x faster scoring processing.The text was updated successfully, but these errors were encountered: