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

docs for forecasting task #443

Merged
merged 7 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
make ForecastingDependenciesNotInstalledError a str message
  • Loading branch information
dengdifan committed Jun 28, 2022
commit 3db6626423047fe29512cff30cef37a90080207a
15 changes: 3 additions & 12 deletions autoPyTorch/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

TABULAR_CLASSIFICATION = 1
IMAGE_CLASSIFICATION = 2
TABULAR_REGRESSION = 3
Expand Down Expand Up @@ -56,16 +54,9 @@
CLASSIFICATION_OUTPUTS = [BINARY, MULTICLASS, MULTICLASSMULTIOUTPUT]
REGRESSION_OUTPUTS = [CONTINUOUS, CONTINUOUSMULTIOUTPUT]


# Constants for Forecasting Tasks
# Exceptions
class ForecastingDependenciesNotInstalledError(ModuleNotFoundError):
def __init__(self, msg: Optional[str] = None):
if msg is None:
msg = "Additional dependencies must be installed to work with time series forecasting" \
"tasks! Please run \n pip install autoPyTorch[forecasting] \n to install the" \
"corresponding dependencies!"
super().__init__(msg)
ForecastingDependenciesNotInstalledMSG = "Additional dependencies must be installed to work with time series " \
"forecasting tasks! Please run \n pip install autoPyTorch[forecasting] \n to "\
"install the corresponding dependencies!"


# The constant values for time series forecasting comes from
Expand Down
4 changes: 2 additions & 2 deletions autoPyTorch/evaluation/abstract_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
CLASSIFICATION_TASKS,
FORECASTING_BUDGET_TYPE,
FORECASTING_TASKS,
ForecastingDependenciesNotInstalledError,
ForecastingDependenciesNotInstalledMSG,
IMAGE_TASKS,
MULTICLASS,
REGRESSION_TASKS,
Expand Down Expand Up @@ -498,7 +498,7 @@ def __init__(self, backend: Backend,
elif self.task_type in FORECASTING_TASKS:
if isinstance(self.configuration, int):
if not forecasting_dependencies_installed:
raise ForecastingDependenciesNotInstalledError
raise ModuleNotFoundError(ForecastingDependenciesNotInstalledMSG)
self.pipeline_class = DummyTimeSeriesForecastingPipeline
elif isinstance(self.configuration, str):
raise ValueError("Only tabular classifications tasks "
Expand Down
4 changes: 2 additions & 2 deletions autoPyTorch/evaluation/tae.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from autoPyTorch.automl_common.common.utils.backend import Backend
from autoPyTorch.constants import (
FORECASTING_BUDGET_TYPE,
ForecastingDependenciesNotInstalledError,
ForecastingDependenciesNotInstalledMSG,
STRING_TO_TASK_TYPES,
TIMESERIES_FORECASTING,
)
Expand Down Expand Up @@ -158,7 +158,7 @@ def __init__(

if STRING_TO_TASK_TYPES.get(dm.task_type, -1) == TIMESERIES_FORECASTING:
if not forecasting_dependencies_installed:
raise ForecastingDependenciesNotInstalledError
raise ModuleNotFoundError(ForecastingDependenciesNotInstalledMSG)
eval_function: Callable = forecasting_eval_train_function
if isinstance(self.resampling_strategy, (HoldoutValTypes, CrossValTypes)):
self.output_y_hat_optimization = output_y_hat_optimization
Expand Down
6 changes: 3 additions & 3 deletions autoPyTorch/pipeline/components/training/metrics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from autoPyTorch.constants import (
CLASSIFICATION_TASKS,
FORECASTING_TASKS,
ForecastingDependenciesNotInstalledError,
ForecastingDependenciesNotInstalledMSG,
REGRESSION_TASKS,
STRING_TO_TASK_TYPES,
TASK_TYPES,
Expand Down Expand Up @@ -49,7 +49,7 @@ def get_supported_metrics(dataset_properties: Dict[str, Any]) -> Dict[str, autoP
return CLASSIFICATION_METRICS
elif STRING_TO_TASK_TYPES[task_type] in FORECASTING_TASKS:
if len(FORECASTING_METRICS) == 0:
raise ForecastingDependenciesNotInstalledError
raise ModuleNotFoundError(ForecastingDependenciesNotInstalledMSG)
return FORECASTING_METRICS
else:
raise NotImplementedError(task_type)
Expand Down Expand Up @@ -129,7 +129,7 @@ def calculate_score(
score_dict = dict()
if task_type in FORECASTING_TASKS:
if len(MASE_LOSSES) == 0:
raise ForecastingDependenciesNotInstalledError
raise ModuleNotFoundError(ForecastingDependenciesNotInstalledMSG)
cprediction = sanitize_array(prediction)
for metric_ in metrics:
if metric_ in MASE_LOSSES and 'mase_coefficient' in score_kwargs:
Expand Down
6 changes: 3 additions & 3 deletions autoPyTorch/utils/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from autoPyTorch.constants import (
CLASSIFICATION_TASKS,
FORECASTING_TASKS,
ForecastingDependenciesNotInstalledError,
ForecastingDependenciesNotInstalledMSG,
IMAGE_TASKS,
REGRESSION_TASKS,
STRING_TO_TASK_TYPES,
Expand Down Expand Up @@ -79,7 +79,7 @@ def get_dataset_requirements(info: Dict[str, Any],
)
else:
if not forecasting_dependencies_installed:
raise ForecastingDependenciesNotInstalledError
raise ModuleNotFoundError(ForecastingDependenciesNotInstalledMSG)
return _get_forecasting_dataset_requirements(info,
include if include is not None else {},
exclude if exclude is not None else {},
Expand Down Expand Up @@ -137,7 +137,7 @@ def _get_forecasting_dataset_requirements(info: Dict[str, Any],

if task_type in FORECASTING_TASKS:
if not forecasting_dependencies_installed:
raise ForecastingDependenciesNotInstalledError
raise ModuleNotFoundError(ForecastingDependenciesNotInstalledMSG)
return TimeSeriesForecastingPipeline(
dataset_properties=info,
include=include,
Expand Down