Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions ads/opctl/operator/lowcode/forecast/model/automlx.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ def _generate_report(self):
self.explain_model()

global_explanation_section = None

# Convert the global explanation data to a DataFrame
global_explanation_df = pd.DataFrame(self.global_explanation)

Expand Down Expand Up @@ -470,13 +469,22 @@ def explain_model(self):
self.global_explanation[s_id] = dict(
zip(
self.local_explanation[s_id].columns,
np.nanmean((self.local_explanation[s_id]), axis=0),
np.nanmean(np.abs(self.local_explanation[s_id]), axis=0),
)
)
else:
# Fall back to the default explanation generation method
super().explain_model()
except Exception as e:
if s_id in self.errors_dict:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should make a function for this logic
log_error(self.errors, s_id, e)

self.errors_dict[s_id]["explainer_error"] = str(e)
self.errors_dict[s_id]["explainer_error_trace"] = traceback.format_exc()
else:
self.errors_dict[s_id] = {
"model_name": self.spec.model,
"explainer_error": str(e),
"explainer_error_trace": traceback.format_exc(),
}
logger.warning(
f"Failed to generate explanations for series {s_id} with error: {e}."
)
Expand Down
4 changes: 2 additions & 2 deletions ads/opctl/operator/lowcode/forecast/model/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ def _save_report(
# explanations csv reports
if self.spec.generate_explanations:
try:
if self.formatted_global_explanation is not None:
if not self.formatted_global_explanation.empty:
write_data(
data=self.formatted_global_explanation,
filename=os.path.join(
Expand All @@ -586,7 +586,7 @@ def _save_report(
f"Attempted to generate global explanations for the {self.spec.global_explanation_filename} file, but an issue occured in formatting the explanations."
)

if self.formatted_local_explanation is not None:
if not self.formatted_local_explanation.empty:
write_data(
data=self.formatted_local_explanation,
filename=os.path.join(
Expand Down