Skip to content

Commit e5df5fc

Browse files
committed
Theta Forecaster added
1 parent 3bb5ff2 commit e5df5fc

File tree

10 files changed

+454
-12
lines changed

10 files changed

+454
-12
lines changed

ads/model/model_metadata.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ class Framework(ExtendedEnum):
165165
PYOD = "pyod"
166166
SPACY = "spacy"
167167
PROPHET = "prophet"
168+
THETA = "theta"
168169
SKTIME = "sktime"
169170
STATSMODELS = "statsmodels"
170171
CUML = "cuml"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class SupportedModels(ExtendedEnum):
1515
NeuralProphet = "neuralprophet"
1616
LGBForecast = "lgbforecast"
1717
AutoMLX = "automlx"
18+
Theta = "theta"
1819
AutoTS = "autots"
1920
# Auto = "auto"
2021

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from .ml_forecast import MLForecastOperatorModel
2424
from .neuralprophet import NeuralProphetOperatorModel
2525
from .prophet import ProphetOperatorModel
26+
from .theta import ThetaOperatorModel
2627

2728

2829
class UnSupportedModelError(Exception):
@@ -46,6 +47,7 @@ class ForecastOperatorModelFactory:
4647
SupportedModels.LGBForecast: MLForecastOperatorModel,
4748
SupportedModels.AutoMLX: AutoMLXOperatorModel,
4849
SupportedModels.AutoTS: AutoTSOperatorModel,
50+
SupportedModels.Theta: ThetaOperatorModel,
4951
}
5052

5153
@classmethod

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -345,41 +345,40 @@ def populate_series_output(
345345
f"\nPlease refer to the troubleshooting guide at {TROUBLESHOOTING_GUIDE} for resolution steps."
346346
) from e
347347

348+
start_idx = output_i.shape[0] - self.horizon - len(fit_val)
348349
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-
)
350+
output_i.loc[output_i.index[
351+
: -self.horizon], "fitted_value"] = fit_val # Note: may need to do len(output_i) - (len(fit_val) + horizon) : -horizon
352352
elif (output_i.shape[0] - self.horizon) > len(fit_val):
353353
logger.debug(
354354
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}."
355355
)
356-
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)