From 21fdba46c28428b408f3ef479fb653012646fe93 Mon Sep 17 00:00:00 2001 From: Allen Hosler Date: Tue, 17 Sep 2024 10:42:35 +0100 Subject: [PATCH] Revert "Update preprocessing flag in automlx.py" --- CODEOWNERS | 2 +- ads/opctl/operator/lowcode/forecast/const.py | 2 +- .../lowcode/forecast/model/automlx.py | 2 +- .../lowcode/forecast/model/factory.py | 2 +- .../lowcode/forecast/model/ml_forecast.py | 35 ++++++++----------- .../operator/lowcode/forecast/schema.yaml | 2 +- tests/operators/forecast/test_datasets.py | 6 ++-- tests/operators/forecast/test_errors.py | 4 +-- 8 files changed, 24 insertions(+), 31 deletions(-) diff --git a/CODEOWNERS b/CODEOWNERS index 614983236..dfc39ec71 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @darenr @mayoor @mrDzurb @VipulMascarenhas @qiuosier @ahosler +* @darenr @mayoor @mrDzurb @VipulMascarenhas @qiuosier diff --git a/ads/opctl/operator/lowcode/forecast/const.py b/ads/opctl/operator/lowcode/forecast/const.py index 08412adcc..64cafc765 100644 --- a/ads/opctl/operator/lowcode/forecast/const.py +++ b/ads/opctl/operator/lowcode/forecast/const.py @@ -14,7 +14,7 @@ class SupportedModels(str, metaclass=ExtendedEnumMeta): Prophet = "prophet" Arima = "arima" NeuralProphet = "neuralprophet" - LGBForecast = "lgbforecast" + MLForecast = "mlforecast" AutoMLX = "automlx" AutoTS = "autots" Auto = "auto" diff --git a/ads/opctl/operator/lowcode/forecast/model/automlx.py b/ads/opctl/operator/lowcode/forecast/model/automlx.py index 3a9005756..453d46786 100644 --- a/ads/opctl/operator/lowcode/forecast/model/automlx.py +++ b/ads/opctl/operator/lowcode/forecast/model/automlx.py @@ -49,7 +49,7 @@ def set_kwargs(self): time_budget = model_kwargs_cleaned.pop("time_budget", -1) model_kwargs_cleaned[ "preprocessing" - ] = self.spec.preprocessing.enabled or model_kwargs_cleaned.get("preprocessing", True) + ] = self.spec.preprocessing or model_kwargs_cleaned.get("preprocessing", True) return model_kwargs_cleaned, time_budget def preprocess(self, data, series_id=None): # TODO: re-use self.le for explanations diff --git a/ads/opctl/operator/lowcode/forecast/model/factory.py b/ads/opctl/operator/lowcode/forecast/model/factory.py index e7fd8cf9c..c4e473a49 100644 --- a/ads/opctl/operator/lowcode/forecast/model/factory.py +++ b/ads/opctl/operator/lowcode/forecast/model/factory.py @@ -33,7 +33,7 @@ class ForecastOperatorModelFactory: SupportedModels.Prophet: ProphetOperatorModel, SupportedModels.Arima: ArimaOperatorModel, SupportedModels.NeuralProphet: NeuralProphetOperatorModel, - SupportedModels.LGBForecast: MLForecastOperatorModel, + SupportedModels.MLForecast: MLForecastOperatorModel, SupportedModels.AutoMLX: AutoMLXOperatorModel, SupportedModels.AutoTS: AutoTSOperatorModel } diff --git a/ads/opctl/operator/lowcode/forecast/model/ml_forecast.py b/ads/opctl/operator/lowcode/forecast/model/ml_forecast.py index b1f349fb0..6ee505ed3 100644 --- a/ads/opctl/operator/lowcode/forecast/model/ml_forecast.py +++ b/ads/opctl/operator/lowcode/forecast/model/ml_forecast.py @@ -1,18 +1,18 @@ #!/usr/bin/env python +# -*- coding: utf-8 -*-- # Copyright (c) 2024 Oracle and/or its affiliates. # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/ -import numpy as np import pandas as pd +import numpy as np -from ads.common.decorator import runtime_dependency from ads.opctl import logger +from ads.common.decorator import runtime_dependency from ads.opctl.operator.lowcode.forecast.utils import _select_plot_list - -from ..const import ForecastOutputColumns, SupportedModels -from ..operator_config import ForecastOperatorConfig from .base_model import ForecastOperatorBaseModel from .forecast_datasets import ForecastDatasets, ForecastOutput +from ..operator_config import ForecastOperatorConfig +from ..const import ForecastOutputColumns, SupportedModels class MLForecastOperatorModel(ForecastOperatorBaseModel): @@ -58,25 +58,18 @@ def _train_model(self, data_train, data_test, model_kwargs): from mlforecast.target_transforms import Differences lgb_params = { - "verbosity": model_kwargs.get("verbosity", -1), - "num_leaves": model_kwargs.get("num_leaves", 512), + "verbosity": -1, + "num_leaves": 512, } additional_data_params = {} if len(self.datasets.get_additional_data_column_names()) > 0: additional_data_params = { - "target_transforms": [ - Differences([model_kwargs.get("Differences", 12)]) - ], + "target_transforms": [Differences([12])], "lags": model_kwargs.get("lags", [1, 6, 12]), "lag_transforms": ( { 1: [ExpandingMean()], - 12: [ - RollingMean( - window_size=model_kwargs.get("RollingMean", 24), - min_samples=1, - ) - ], + 12: [RollingMean(window_size=24)], } ), } @@ -154,7 +147,7 @@ def _train_model(self, data_train, data_test, model_kwargs): ) self.model_parameters[s_id] = { - "framework": SupportedModels.LGBForecast, + "framework": SupportedModels.MLForecast, **lgb_params, } @@ -211,10 +204,10 @@ def _generate_report(self): self.datasets.list_series_ids(), ) - # Section 2: LGBForecast Model Parameters + # Section 2: MlForecast Model Parameters sec2_text = rc.Block( - rc.Heading("LGBForecast Model Parameters", level=2), - rc.Text("These are the parameters used for the LGBForecast model."), + rc.Heading("MlForecast Model Parameters", level=2), + rc.Text("These are the parameters used for the MlForecast model."), ) blocks = [ @@ -228,7 +221,7 @@ def _generate_report(self): all_sections = [sec1_text, sec_1, sec2_text, sec_2] model_description = rc.Text( - "LGBForecast uses mlforecast framework to perform time series forecasting using machine learning models" + "mlforecast is a framework to perform time series forecasting using machine learning models" "with the option to scale to massive amounts of data using remote clusters." "Fastest implementations of feature engineering for time series forecasting in Python." "Support for exogenous variables and static covariates." diff --git a/ads/opctl/operator/lowcode/forecast/schema.yaml b/ads/opctl/operator/lowcode/forecast/schema.yaml index ef358d156..b465b19cf 100644 --- a/ads/opctl/operator/lowcode/forecast/schema.yaml +++ b/ads/opctl/operator/lowcode/forecast/schema.yaml @@ -379,7 +379,7 @@ spec: - prophet - arima - neuralprophet - - lgbforecast + - mlforecast - automlx - autots - auto-select diff --git a/tests/operators/forecast/test_datasets.py b/tests/operators/forecast/test_datasets.py index fd440ab8d..b2b60e77b 100644 --- a/tests/operators/forecast/test_datasets.py +++ b/tests/operators/forecast/test_datasets.py @@ -32,7 +32,7 @@ "prophet", "neuralprophet", "autots", - "lgbforecast", + "mlforecast", "auto-select", ] @@ -135,7 +135,7 @@ def test_load_datasets(model, data_details): if model == "automlx": yaml_i["spec"]["model_kwargs"] = {"time_budget": 2} if model == "auto-select": - yaml_i["spec"]["model_kwargs"] = {"model_list": ['prophet', 'arima', 'lgbforecast']} + yaml_i["spec"]["model_kwargs"] = {"model_list": ['prophet', 'arima', 'mlforecast']} if dataset_name == f'{DATASET_PREFIX}dataset4.csv': pytest.skip("Skipping dataset4 with auto-select") # todo:// ODSC-58584 @@ -143,7 +143,7 @@ def test_load_datasets(model, data_details): subprocess.run(f"ls -a {output_data_path}", shell=True) if yaml_i["spec"]["generate_explanations"] and model not in [ "automlx", - "lgbforecast", + "mlforecast", "auto-select" ]: verify_explanations( diff --git a/tests/operators/forecast/test_errors.py b/tests/operators/forecast/test_errors.py index d01657eb7..41448e6a5 100644 --- a/tests/operators/forecast/test_errors.py +++ b/tests/operators/forecast/test_errors.py @@ -141,7 +141,7 @@ "prophet", "neuralprophet", "autots", - "lgbforecast", + "mlforecast", # "auto", ] @@ -687,7 +687,7 @@ def test_arima_automlx_errors(operator_setup, model): in error_content["13"]["error"] ), "Error message mismatch" - if model not in ["autots", "automlx", "lgbforecast"]: + if model not in ["autots", "automlx", "mlforecast"]: global_fn = f"{tmpdirname}/results/global_explanation.csv" assert os.path.exists( global_fn