Skip to content

Commit e89fc96

Browse files
committed
- fixed warning: ChainedAssignmentError
- added theta forcaster to auto-select-series
1 parent 86475d3 commit e89fc96

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

ads/opctl/operator/lowcode/forecast/meta_selector.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ def __init__(self):
214214
"model": "autots",
215215
"priority": 17,
216216
},
217+
# Rule 18: Theta Forecaster
218+
"theta_0": {
219+
"conditions": [],
220+
"model": "theta",
221+
"priority": 18,
222+
},
217223
}
218224

219225
def _evaluate_condition(self, value, operator, threshold):

ads/opctl/operator/lowcode/forecast/model/forecast_datasets.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -346,40 +346,39 @@ def populate_series_output(
346346
) from e
347347

348348
if (output_i.shape[0] - self.horizon) == len(fit_val):
349-
output_i["fitted_value"].iloc[: -self.horizon] = (
350-
fit_val # Note: may need to do len(output_i) - (len(fit_val) + horizon) : -horizon
351-
)
349+
output_i.loc[output_i.index[
350+
: -self.horizon], "fitted_value"] = fit_val # Note: may need to do len(output_i) - (len(fit_val) + horizon) : -horizon
352351
elif (output_i.shape[0] - self.horizon) > len(fit_val):
353352
logger.debug(
354353
f"Fitted Values were only generated on a subset ({len(fit_val)}/{(output_i.shape[0] - self.horizon)}) of the data for Series: {series_id}."
355354
)
356355
start_idx = output_i.shape[0] - self.horizon - len(fit_val)
357-
output_i["fitted_value"].iloc[start_idx : -self.horizon] = fit_val
356+
output_i.loc[output_i.index[start_idx: -self.horizon], "fitted_value"] = fit_val
358357
else:
359-
output_i["fitted_value"].iloc[start_idx : -self.horizon] = fit_val[
360-
-(output_i.shape[0] - self.horizon) :
358+
output_i.loc[output_i.index[start_idx: -self.horizon], "fitted_value"] = fit_val[
359+
-(output_i.shape[0] - self.horizon):
361360
]
362361

363362
if len(forecast_val) != self.horizon:
364363
raise ValueError(
365364
f"Attempting to set forecast along horizon ({self.horizon}) for series: {series_id}, however forecast is only length {len(forecast_val)}"
366365
f"\nPlease refer to the troubleshooting guide at {TROUBLESHOOTING_GUIDE} for resolution steps."
367366
)
368-
output_i["forecast_value"].iloc[-self.horizon :] = forecast_val
367+
output_i.loc[output_i.index[-self.horizon:], "forecast_value"] = forecast_val
369368

370369
if len(upper_bound) != self.horizon:
371370
raise ValueError(
372371
f"Attempting to set upper_bound along horizon ({self.horizon}) for series: {series_id}, however upper_bound is only length {len(upper_bound)}"
373372
f"\nPlease refer to the troubleshooting guide at {TROUBLESHOOTING_GUIDE} for resolution steps."
374373
)
375-
output_i[self.upper_bound_name].iloc[-self.horizon :] = upper_bound
374+
output_i.loc[output_i.index[-self.horizon:], self.upper_bound_name] = upper_bound
376375

377376
if len(lower_bound) != self.horizon:
378377
raise ValueError(
379378
f"Attempting to set lower_bound along horizon ({self.horizon}) for series: {series_id}, however lower_bound is only length {len(lower_bound)}"
380379
f"\nPlease refer to the troubleshooting guide at {TROUBLESHOOTING_GUIDE} for resolution steps."
381380
)
382-
output_i[self.lower_bound_name].iloc[-self.horizon :] = lower_bound
381+
output_i.loc[output_i.index[-self.horizon:], self.lower_bound_name] = lower_bound
383382

384383
self.series_id_map[series_id] = output_i
385384
self.verify_series_output(series_id)

0 commit comments

Comments
 (0)