Skip to content

Commit d209cc1

Browse files
authored
AutoMLx Upgrade (#643)
2 parents 15d4b2b + fd6e1b1 commit d209cc1

File tree

13 files changed

+46
-82
lines changed

13 files changed

+46
-82
lines changed

ads/opctl/operator/lowcode/anomaly/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ To run anomaly detection locally, create and activate a new conda environment (`
3737
```yaml
3838
- datapane
3939
- cerberus
40-
- oracle-automlx==23.2.3
40+
- oracle-automlx==23.4.1
41+
- oracle-automlx[classic]==23.4.1
4142
- "git+https://github.com/oracle/accelerated-data-science.git@feature/anomaly#egg=oracle-ads"
4243
```
4344

ads/opctl/operator/lowcode/anomaly/environment.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ dependencies:
77
- pip:
88
- datapane
99
- cerberus
10-
- oracle-automlx==23.2.3
10+
- oracle-automlx==23.4.1
11+
- oracle-automlx[classic]==23.4.1
1112
- "oracle-ads[anomaly]"

ads/opctl/operator/lowcode/anomaly/model/automlx.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,26 @@ class AutoMLXOperatorModel(AnomalyOperatorBaseModel):
1717
"""Class representing AutoMLX operator model."""
1818

1919
@runtime_dependency(
20-
module="automl",
20+
module="automlx",
2121
err_msg=(
22-
"Please run `pip3 install oracle-automlx==23.2.3` to "
23-
"install the required dependencies for automlx."
22+
"Please run `pip3 install oracle-automlx==23.4.1` and "
23+
"`pip3 install oracle-automlx[classic]==23.4.1` "
24+
"to install the required dependencies for automlx."
2425
),
2526
)
2627
def _build_model(self) -> pd.DataFrame:
28+
from automlx import init
29+
try:
30+
init(engine="ray", engine_opts={"ray_setup": {"_temp_dir": "/tmp/ray-temp"}})
31+
except Exception as e:
32+
logger.info("Ray already initialized")
2733
date_column = self.spec.datetime_column.name
2834
anomaly_output = AnomalyOutput(date_column=date_column)
35+
time_budget = self.spec.model_kwargs.pop("time_budget", -1)
2936

30-
time_budget = self.spec.model_kwargs.pop("time_budget", None)
3137
# Iterate over the full_data_dict items
3238
for target, df in self.datasets.full_data_dict.items():
33-
est = automl.Pipeline(task="anomaly_detection", **self.spec.model_kwargs)
39+
est = automlx.Pipeline(task="anomaly_detection", **self.spec.model_kwargs)
3440
est.fit(
3541
X=df,
3642
X_valid=self.X_valid_dict[target]
@@ -39,10 +45,10 @@ def _build_model(self) -> pd.DataFrame:
3945
y_valid=self.y_valid_dict[target]
4046
if self.y_valid_dict is not None
4147
else None,
42-
time_budget=time_budget,
4348
contamination=self.spec.contamination
4449
if self.y_valid_dict is not None
4550
else None,
51+
time_budget=time_budget,
4652
)
4753
y_pred = est.predict(df)
4854
scores = est.predict_proba(df)

ads/opctl/operator/lowcode/forecast/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ To run forecasting locally, create and activate a new conda environment (`ads-fo
3838
- datapane
3939
- cerberus
4040
- sktime
41-
- optuna==2.9.0
42-
- oracle-automlx==23.2.3
41+
- optuna==3.1.0
42+
- oracle-automlx==23.4.1
43+
- oracle-automlx[forecasting]==23.4.1
4344
- oracle-ads>=2.9.0
4445
```
4546

ads/opctl/operator/lowcode/forecast/environment.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ dependencies:
1515
- sktime
1616
- shap
1717
- autots[additional]
18-
- optuna==2.9.0
19-
- oracle-automlx==23.2.3
18+
- optuna==3.1.0
19+
- oracle-automlx==23.4.1
20+
- oracle-automlx[forecasting]==23.4.1

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

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def set_kwargs(self):
4545
model_kwargs_cleaned.get("score_metric", AUTOMLX_DEFAULT_SCORE_METRIC),
4646
)
4747
model_kwargs_cleaned.pop("task", None)
48-
time_budget = model_kwargs_cleaned.pop("time_budget", None)
48+
time_budget = model_kwargs_cleaned.pop("time_budget", -1)
4949
model_kwargs_cleaned[
5050
"preprocessing"
5151
] = self.spec.preprocessing or model_kwargs_cleaned.get("preprocessing", True)
@@ -55,9 +55,11 @@ def preprocess(self, data, series_id=None):
5555
return data.set_index(self.spec.datetime_column.name)
5656

5757
@runtime_dependency(
58-
module="automl",
58+
module="automlx",
5959
err_msg=(
60-
"Please run `pip3 install oracle-automlx==23.2.3` to install the required dependencies for automlx."
60+
"Please run `pip3 install oracle-automlx==23.4.1` and "
61+
"`pip3 install oracle-automlx[forecasting]==23.4.1` "
62+
"to install the required dependencies for automlx."
6163
),
6264
)
6365
@runtime_dependency(
@@ -67,15 +69,13 @@ def preprocess(self, data, series_id=None):
6769
),
6870
)
6971
def _build_model(self) -> pd.DataFrame:
70-
from automl import init
72+
from automlx import init
7173
from sktime.forecasting.model_selection import temporal_train_test_split
74+
try:
75+
init(engine="ray", engine_opts={"ray_setup": {"_temp_dir": "/tmp/ray-temp"}})
76+
except Exception as e:
77+
logger.info("Ray already initialized")
7278

73-
init(
74-
engine="local",
75-
engine_opts={"n_jobs": -1, "model_n_jobs": -1},
76-
check_deprecation_warnings=False,
77-
logger=50,
78-
)
7979

8080
full_data_dict = self.datasets.get_data_by_series()
8181

@@ -95,7 +95,7 @@ def _build_model(self) -> pd.DataFrame:
9595

9696
for i, (s_id, df) in enumerate(full_data_dict.items()):
9797
try:
98-
logger.debug(f"Running automl on series {s_id}")
98+
logger.debug(f"Running automlx on series {s_id}")
9999
model_kwargs = model_kwargs_cleaned.copy()
100100
target = self.original_target_column
101101
self.forecast_output.init_series_output(
@@ -110,7 +110,7 @@ def _build_model(self) -> pd.DataFrame:
110110
if self.loaded_models is not None:
111111
model = self.loaded_models[s_id]
112112
else:
113-
model = automl.Pipeline(
113+
model = automlx.Pipeline(
114114
task="forecasting",
115115
**model_kwargs,
116116
)
@@ -149,18 +149,7 @@ def _build_model(self) -> pd.DataFrame:
149149

150150
self.model_parameters[s_id] = {
151151
"framework": SupportedModels.AutoMLX,
152-
"score_metric": model.score_metric,
153-
"random_state": model.random_state,
154-
"model_list": model.model_list,
155-
"n_algos_tuned": model.n_algos_tuned,
156-
"adaptive_sampling": model.adaptive_sampling,
157-
"min_features": model.min_features,
158-
"optimization": model.optimization,
159-
"preprocessing": model.preprocessing,
160-
"search_space": model.search_space,
161152
"time_series_period": model.time_series_period,
162-
"min_class_instances": model.min_class_instances,
163-
"max_tuning_trials": model.max_tuning_trials,
164153
"selected_model": model.selected_model_,
165154
"selected_model_params": model.selected_model_params_,
166155
}

docs/source/user_guide/operators/anomaly_detection_operator/faq.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ More details in the documentation here: https://docs.oracle.com/en-us/iaas/tools
1010

1111
More details in the documentation here: https://winedarksea.github.io/AutoTS/build/html/source/tutorial.html
1212

13-
**Pip Install Failing with "ERROR: No matching distribution found for oracle-automlx==23.2.3; extra == "forecast""**
13+
**Pip Install Failing with "ERROR: No matching distribution found for oracle-automlx==23.4.1; extra == "forecast""**
1414

1515
Automlx only supports Python<=3.8, != 3.9, <= 3.10.7 . If you are builing in Python 3.9 or 3.10.8+, no automlx distribution will be available. It's recommended to use the conda pack available through Notebook Sessions, or to use Python 3.8

docs/source/user_guide/operators/forecasting_operator/faq.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ More details in the documentation here: https://docs.oracle.com/en-us/iaas/tools
1010

1111
More details in the documentation here: https://winedarksea.github.io/AutoTS/build/html/source/tutorial.html
1212

13-
**Pip Install Failing with "ERROR: No matching distribution found for oracle-automlx==23.2.3; extra == "forecast""**
13+
**Pip Install Failing with "ERROR: No matching distribution found for oracle-automlx==23.4.1; extra == "forecast""**
1414

1515
Automlx only supports Python<=3.8, != 3.9, <= 3.10.7 . If you are builing in Python 3.9 or 3.10.8+, no automlx distribution will be available. It's recommended to use the conda pack available through Notebook Sessions, or to use Python 3.8

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,10 @@ forecast = [
167167
"neuralprophet",
168168
"numpy",
169169
"oci-cli",
170-
"optuna==2.9.0",
170+
"optuna==3.1.0",
171171
"oracle-ads",
172-
"oracle-automlx[forecasting]==23.2.3",
172+
"oracle-automlx[forecasting]==23.4.1",
173+
"oracle-automlx[classic]==23.4.1",
173174
"pmdarima",
174175
"prophet",
175176
"shap",
@@ -181,7 +182,8 @@ forecast = [
181182
anomaly = [
182183
"oracle_ads[opctl]",
183184
"autots",
184-
"oracle-automlx[forecasting]==23.2.3",
185+
"oracle-automlx[forecasting]==23.4.1",
186+
"oracle-automlx[classic]==23.4.1",
185187
"oracledb",
186188
"datapane",
187189
]

tests/operators/anomaly/test_anomaly_simple.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def test_load_datasets(model, data_dict):
212212

213213
# run(yaml_i, backend="operator.local", debug=False)
214214

215-
with open(f"{tmpdirname}/anomaly.yaml", "w") as f:
215+
with open(anomaly_yaml_filename, "w") as f:
216216
f.write(yaml.dump(yaml_i))
217217
sleep(0.5)
218218
subprocess.run(

0 commit comments

Comments
 (0)