Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added boolean disables, generation of train (metrics.csv) and test metrics (test_metrics.csv) #397

Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions ads/opctl/operator/lowcode/forecast/model/arima.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@

from .. import utils
from .base_model import ForecastOperatorBaseModel
from ..operator_config import ForecastOperatorConfig


class ArimaOperatorModel(ForecastOperatorBaseModel):
"""Class representing ARIMA operator model."""

def __init__(self, config: ForecastOperatorConfig):
super().__init__(config)
self.train_metrics = False
Copy link
Member

Choose a reason for hiding this comment

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

If the all models require these extra attributes, maybe we can add them to the base model class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These values were defined for each model inside _generate_report method. I have abstracted them out as attributes because I needed them outside of that method.
The train_metrics value is True/False according to the model so I am not sure if we can define them in base_model. cc: @ahosler

Copy link
Member

Choose a reason for hiding this comment

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

One thing you could do is add self.train_metrics = False to the base class, and then update it to True only in prophet and neuralprophet so that if we add model classes in the future train_metrics is disabled by default.

self.forecast_col_name = "yhat"

def _build_model(self) -> pd.DataFrame:
full_data_dict = self.full_data_dict

Expand Down Expand Up @@ -153,17 +159,13 @@ def _generate_report(self):
"it predicts future values based on past values."
)
other_sections = all_sections
forecast_col_name = "yhat"
train_metrics = False
ds_column_series = self.data[self.spec.datetime_column.name]
ds_forecast_col = self.outputs[0].index
ci_col_names = ["yhat_lower", "yhat_upper"]

return (
model_description,
other_sections,
forecast_col_name,
train_metrics,
ds_column_series,
ds_forecast_col,
ci_col_names,
Expand Down
8 changes: 3 additions & 5 deletions ads/opctl/operator/lowcode/forecast/model/automlx.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def __init__(self, config: ForecastOperatorConfig):
super().__init__(config)
self.global_explanation = {}
self.local_explanation = {}
self.train_metrics = False
self.forecast_col_name = "yhat"

@runtime_dependency(
module="automl",
Expand Down Expand Up @@ -211,7 +213,7 @@ def _generate_report(self):

all_sections = [selected_models_text, selected_models_section]

if self.spec.explain:
if self.spec.generate_explanations:
# If the key is present, call the "explain_model" method
self.explain_model()

Expand Down Expand Up @@ -257,17 +259,13 @@ def _generate_report(self):
"high-quality features in your dataset, which are then provided for further processing."
)
other_sections = all_sections
forecast_col_name = "yhat"
train_metrics = False
ds_column_series = self.data[self.spec.datetime_column.name]
ds_forecast_col = self.outputs[0]["ds"]
ci_col_names = ["yhat_lower", "yhat_upper"]

return (
model_description,
other_sections,
forecast_col_name,
train_metrics,
ds_column_series,
ds_forecast_col,
ci_col_names,
Expand Down
10 changes: 6 additions & 4 deletions ads/opctl/operator/lowcode/forecast/model/autots.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from .. import utils
from .base_model import ForecastOperatorBaseModel
from ..operator_config import ForecastOperatorConfig
from ads.common.decorator.runtime_dependency import runtime_dependency


Expand All @@ -22,6 +23,11 @@
class AutoTSOperatorModel(ForecastOperatorBaseModel):
"""Class representing AutoTS operator model."""

def __init__(self, config: ForecastOperatorConfig):
super().__init__(config)
self.train_metrics = False
self.forecast_col_name = "yhat"

@runtime_dependency(
module="autots",
err_msg="Please run `pip3 install autots` to install the required dependencies for autots.",
Expand Down Expand Up @@ -250,8 +256,6 @@ def _generate_report(self) -> tuple:
)

other_sections = all_sections
forecast_col_name = "yhat"
train_metrics = False

ds_column_series = pd.to_datetime(self.data[self.spec.datetime_column.name])
ds_forecast_col = self.outputs[0].index
Expand All @@ -260,8 +264,6 @@ def _generate_report(self) -> tuple:
return (
model_description,
other_sections,
forecast_col_name,
train_metrics,
ds_column_series,
ds_forecast_col,
ci_col_names,
Expand Down
Loading