oracle-ads 2.11.6__py3-none-any.whl → 2.11.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ads/aqua/__init__.py +24 -14
- ads/aqua/base.py +0 -2
- ads/aqua/cli.py +50 -2
- ads/aqua/decorator.py +8 -0
- ads/aqua/deployment.py +37 -34
- ads/aqua/evaluation.py +106 -49
- ads/aqua/extension/base_handler.py +18 -10
- ads/aqua/extension/common_handler.py +21 -2
- ads/aqua/extension/deployment_handler.py +1 -4
- ads/aqua/extension/evaluation_handler.py +1 -2
- ads/aqua/extension/finetune_handler.py +0 -1
- ads/aqua/extension/ui_handler.py +1 -12
- ads/aqua/extension/utils.py +4 -4
- ads/aqua/finetune.py +24 -11
- ads/aqua/model.py +2 -4
- ads/aqua/utils.py +39 -23
- ads/catalog/model.py +3 -3
- ads/catalog/notebook.py +3 -3
- ads/catalog/project.py +2 -2
- ads/catalog/summary.py +2 -4
- ads/cli.py +21 -2
- ads/common/serializer.py +5 -4
- ads/common/utils.py +6 -2
- ads/config.py +1 -0
- ads/data_labeling/metadata.py +2 -2
- ads/dataset/dataset.py +3 -5
- ads/dataset/factory.py +2 -3
- ads/dataset/label_encoder.py +1 -1
- ads/dataset/sampled_dataset.py +3 -5
- ads/jobs/ads_job.py +26 -2
- ads/jobs/builders/infrastructure/dsc_job.py +20 -7
- ads/llm/serializers/runnable_parallel.py +7 -1
- ads/model/model_artifact_boilerplate/artifact_introspection_test/model_artifact_validate.py +1 -1
- ads/opctl/operator/lowcode/anomaly/README.md +1 -1
- ads/opctl/operator/lowcode/anomaly/environment.yaml +1 -1
- ads/opctl/operator/lowcode/anomaly/model/anomaly_dataset.py +8 -15
- ads/opctl/operator/lowcode/anomaly/model/automlx.py +16 -10
- ads/opctl/operator/lowcode/anomaly/model/autots.py +9 -10
- ads/opctl/operator/lowcode/anomaly/model/base_model.py +36 -39
- ads/opctl/operator/lowcode/anomaly/model/tods.py +4 -4
- ads/opctl/operator/lowcode/anomaly/operator_config.py +18 -1
- ads/opctl/operator/lowcode/anomaly/schema.yaml +16 -4
- ads/opctl/operator/lowcode/common/data.py +16 -2
- ads/opctl/operator/lowcode/common/transformations.py +48 -14
- ads/opctl/operator/lowcode/forecast/README.md +1 -1
- ads/opctl/operator/lowcode/forecast/environment.yaml +5 -4
- ads/opctl/operator/lowcode/forecast/model/arima.py +36 -29
- ads/opctl/operator/lowcode/forecast/model/automlx.py +91 -90
- ads/opctl/operator/lowcode/forecast/model/autots.py +200 -166
- ads/opctl/operator/lowcode/forecast/model/base_model.py +144 -140
- ads/opctl/operator/lowcode/forecast/model/neuralprophet.py +86 -80
- ads/opctl/operator/lowcode/forecast/model/prophet.py +68 -63
- ads/opctl/operator/lowcode/forecast/operator_config.py +18 -2
- ads/opctl/operator/lowcode/forecast/schema.yaml +20 -4
- ads/opctl/operator/lowcode/forecast/utils.py +8 -4
- ads/opctl/operator/lowcode/pii/README.md +1 -1
- ads/opctl/operator/lowcode/pii/environment.yaml +1 -1
- ads/opctl/operator/lowcode/pii/model/report.py +71 -70
- ads/pipeline/ads_pipeline_step.py +11 -12
- {oracle_ads-2.11.6.dist-info → oracle_ads-2.11.8.dist-info}/METADATA +8 -7
- {oracle_ads-2.11.6.dist-info → oracle_ads-2.11.8.dist-info}/RECORD +64 -64
- {oracle_ads-2.11.6.dist-info → oracle_ads-2.11.8.dist-info}/LICENSE.txt +0 -0
- {oracle_ads-2.11.6.dist-info → oracle_ads-2.11.8.dist-info}/WHEEL +0 -0
- {oracle_ads-2.11.6.dist-info → oracle_ads-2.11.8.dist-info}/entry_points.txt +0 -0
@@ -2,7 +2,7 @@
|
|
2
2
|
# -*- coding: utf-8 -*--
|
3
3
|
import traceback
|
4
4
|
|
5
|
-
# Copyright (c) 2023 Oracle and/or its affiliates.
|
5
|
+
# Copyright (c) 2023, 2024 Oracle and/or its affiliates.
|
6
6
|
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
|
7
7
|
|
8
8
|
import pandas as pd
|
@@ -22,6 +22,7 @@ from ads.opctl.operator.lowcode.common.utils import (
|
|
22
22
|
seconds_to_datetime,
|
23
23
|
datetime_to_seconds,
|
24
24
|
)
|
25
|
+
from ads.opctl.operator.lowcode.forecast.utils import _label_encode_dataframe
|
25
26
|
|
26
27
|
AUTOMLX_N_ALGOS_TUNED = 4
|
27
28
|
AUTOMLX_DEFAULT_SCORE_METRIC = "neg_sym_mean_abs_percent_error"
|
@@ -51,8 +52,12 @@ class AutoMLXOperatorModel(ForecastOperatorBaseModel):
|
|
51
52
|
] = self.spec.preprocessing or model_kwargs_cleaned.get("preprocessing", True)
|
52
53
|
return model_kwargs_cleaned, time_budget
|
53
54
|
|
54
|
-
def preprocess(self, data, series_id=None):
|
55
|
-
|
55
|
+
def preprocess(self, data, series_id=None): # TODO: re-use self.le for explanations
|
56
|
+
_, df_encoded = _label_encode_dataframe(
|
57
|
+
data,
|
58
|
+
no_encode={self.spec.datetime_column.name, self.original_target_column},
|
59
|
+
)
|
60
|
+
return df_encoded.set_index(self.spec.datetime_column.name)
|
56
61
|
|
57
62
|
@runtime_dependency(
|
58
63
|
module="automlx",
|
@@ -70,17 +75,20 @@ class AutoMLXOperatorModel(ForecastOperatorBaseModel):
|
|
70
75
|
)
|
71
76
|
def _build_model(self) -> pd.DataFrame:
|
72
77
|
from automlx import init
|
73
|
-
|
78
|
+
import logging
|
79
|
+
|
74
80
|
try:
|
75
|
-
init(
|
81
|
+
init(
|
82
|
+
engine="ray",
|
83
|
+
engine_opts={"ray_setup": {"_temp_dir": "/tmp/ray-temp"}},
|
84
|
+
loglevel=logging.CRITICAL,
|
85
|
+
)
|
76
86
|
except Exception as e:
|
77
87
|
logger.info("Ray already initialized")
|
78
88
|
|
79
|
-
|
80
89
|
full_data_dict = self.datasets.get_data_by_series()
|
81
90
|
|
82
91
|
self.models = dict()
|
83
|
-
date_column = self.spec.datetime_column.name
|
84
92
|
horizon = self.spec.horizon
|
85
93
|
self.spec.confidence_interval_width = self.spec.confidence_interval_width or 0.8
|
86
94
|
self.forecast_output = ForecastOutput(
|
@@ -107,7 +115,7 @@ class AutoMLXOperatorModel(ForecastOperatorBaseModel):
|
|
107
115
|
|
108
116
|
logger.debug(f"Time Index Monotonic: {data_i.index.is_monotonic}")
|
109
117
|
|
110
|
-
if self.loaded_models is not None:
|
118
|
+
if self.loaded_models is not None and s_id in self.loaded_models:
|
111
119
|
model = self.loaded_models[s_id]
|
112
120
|
else:
|
113
121
|
model = automlx.Pipeline(
|
@@ -163,12 +171,6 @@ class AutoMLXOperatorModel(ForecastOperatorBaseModel):
|
|
163
171
|
|
164
172
|
return self.forecast_output.get_forecast_long()
|
165
173
|
|
166
|
-
@runtime_dependency(
|
167
|
-
module="datapane",
|
168
|
-
err_msg=(
|
169
|
-
"Please run `pip3 install datapane` to install the required dependencies for report generation."
|
170
|
-
),
|
171
|
-
)
|
172
174
|
def _generate_report(self):
|
173
175
|
"""
|
174
176
|
Generate the report for the automlx model.
|
@@ -179,106 +181,105 @@ class AutoMLXOperatorModel(ForecastOperatorBaseModel):
|
|
179
181
|
|
180
182
|
Returns
|
181
183
|
-------
|
182
|
-
- model_description (
|
183
|
-
- other_sections (List[Union[
|
184
|
+
- model_description (report-creator.Text): A Text component containing the description of the automlx model.
|
185
|
+
- other_sections (List[Union[report-creator.Text, report-creator.Block]]): A list of Text and Blocks components representing various sections of the report.
|
184
186
|
- forecast_col_name (str): The name of the forecasted column.
|
185
187
|
- train_metrics (bool): A boolean value indicating whether to include train metrics in the report.
|
186
188
|
- ds_column_series (pd.Series): The pd.Series object representing the datetime column of the dataset.
|
187
189
|
- ds_forecast_col (pd.Series): The pd.Series object representing the forecasted column.
|
188
190
|
- ci_col_names (List[str]): A list of column names for the confidence interval in the report.
|
189
191
|
"""
|
190
|
-
import
|
192
|
+
import report_creator as rc
|
191
193
|
|
192
194
|
"""The method that needs to be implemented on the particular model level."""
|
193
|
-
selected_models_text = dp.Text(
|
194
|
-
f"## Selected Models Overview \n "
|
195
|
-
"The following tables provide information regarding the "
|
196
|
-
"chosen model for each series and the corresponding parameters of the models."
|
197
|
-
)
|
198
195
|
selected_models = dict()
|
199
196
|
models = self.models
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
197
|
+
other_sections = []
|
198
|
+
|
199
|
+
if len(self.models) > 0:
|
200
|
+
for i, (s_id, m) in enumerate(models.items()):
|
201
|
+
selected_models[s_id] = {
|
202
|
+
"series_id": s_id,
|
203
|
+
"selected_model": m.selected_model_,
|
204
|
+
"model_params": m.selected_model_params_,
|
205
|
+
}
|
206
|
+
selected_models_df = pd.DataFrame(
|
207
|
+
selected_models.items(), columns=["series_id", "best_selected_model"]
|
208
|
+
)
|
209
|
+
selected_df = selected_models_df["best_selected_model"].apply(pd.Series)
|
210
|
+
selected_models_section = rc.Block(
|
211
|
+
rc.Heading("Selected Models Overview", level=2),
|
212
|
+
rc.Text(
|
213
|
+
"The following tables provide information regarding the "
|
214
|
+
"chosen model for each series and the corresponding parameters of the models."
|
215
|
+
),
|
216
|
+
rc.DataTable(selected_df, index=True),
|
217
|
+
)
|
213
218
|
|
214
|
-
|
219
|
+
other_sections = [selected_models_section]
|
215
220
|
|
216
221
|
if self.spec.generate_explanations:
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
# Create a markdown text block for the global explanation section
|
222
|
-
global_explanation_text = dp.Text(
|
223
|
-
f"## Global Explanation of Models \n "
|
224
|
-
"The following tables provide the feature attribution for the global explainability."
|
225
|
-
)
|
222
|
+
try:
|
223
|
+
# If the key is present, call the "explain_model" method
|
224
|
+
self.explain_model()
|
226
225
|
|
227
|
-
|
228
|
-
|
226
|
+
# Convert the global explanation data to a DataFrame
|
227
|
+
global_explanation_df = pd.DataFrame(self.global_explanation)
|
229
228
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
229
|
+
self.formatted_global_explanation = (
|
230
|
+
global_explanation_df / global_explanation_df.sum(axis=0) * 100
|
231
|
+
)
|
232
|
+
self.formatted_global_explanation = (
|
233
|
+
self.formatted_global_explanation.rename(
|
234
|
+
{self.spec.datetime_column.name: ForecastOutputColumns.DATE},
|
235
|
+
axis=1,
|
236
|
+
)
|
236
237
|
)
|
237
|
-
)
|
238
|
-
|
239
|
-
# Create a markdown section for the global explainability
|
240
|
-
global_explanation_section = dp.Blocks(
|
241
|
-
"### Global Explainability ",
|
242
|
-
dp.DataTable(self.formatted_global_explanation),
|
243
|
-
)
|
244
238
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
239
|
+
# Create a markdown section for the global explainability
|
240
|
+
global_explanation_section = rc.Block(
|
241
|
+
rc.Heading("Global Explanation of Models", level=2),
|
242
|
+
rc.Text(
|
243
|
+
"The following tables provide the feature attribution for the global explainability."
|
244
|
+
),
|
245
|
+
rc.DataTable(self.formatted_global_explanation, index=True),
|
251
246
|
)
|
252
|
-
self.formatted_local_explanation = aggregate_local_explanations
|
253
247
|
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
248
|
+
aggregate_local_explanations = pd.DataFrame()
|
249
|
+
for s_id, local_ex_df in self.local_explanation.items():
|
250
|
+
local_ex_df_copy = local_ex_df.copy()
|
251
|
+
local_ex_df_copy["Series"] = s_id
|
252
|
+
aggregate_local_explanations = pd.concat(
|
253
|
+
[aggregate_local_explanations, local_ex_df_copy], axis=0
|
254
|
+
)
|
255
|
+
self.formatted_local_explanation = aggregate_local_explanations
|
256
|
+
|
257
|
+
blocks = [
|
258
|
+
rc.DataTable(
|
259
|
+
local_ex_df.div(local_ex_df.abs().sum(axis=1), axis=0) * 100,
|
260
|
+
label=s_id,
|
261
|
+
index=True,
|
262
|
+
)
|
263
|
+
for s_id, local_ex_df in self.local_explanation.items()
|
264
|
+
]
|
265
|
+
local_explanation_section = rc.Block(
|
266
|
+
rc.Heading("Local Explanation of Models", level=2),
|
267
|
+
rc.Select(blocks=blocks),
|
259
268
|
)
|
260
|
-
for s_id, local_ex_df in self.local_explanation.items()
|
261
|
-
]
|
262
|
-
local_explanation_section = (
|
263
|
-
dp.Select(blocks=blocks) if len(blocks) > 1 else blocks[0]
|
264
|
-
)
|
265
269
|
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
model_description = dp.Text(
|
270
|
+
# Append the global explanation text and section to the "other_sections" list
|
271
|
+
other_sections = other_sections + [
|
272
|
+
global_explanation_section,
|
273
|
+
local_explanation_section,
|
274
|
+
]
|
275
|
+
except Exception as e:
|
276
|
+
logger.warn(f"Failed to generate Explanations with error: {e}.")
|
277
|
+
logger.debug(f"Full Traceback: {traceback.format_exc()}")
|
278
|
+
|
279
|
+
model_description = rc.Text(
|
278
280
|
"The AutoMLx model automatically preprocesses, selects and engineers "
|
279
281
|
"high-quality features in your dataset, which are then provided for further processing."
|
280
282
|
)
|
281
|
-
other_sections = all_sections
|
282
283
|
|
283
284
|
return (
|
284
285
|
model_description,
|