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

remove all proloaf references #517

Merged
merged 5 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,20 @@ SPDX-License-Identifier: MPL-2.0
OpenSTEF is a Python package designed for generating short-term forecasts in the energy sector. The repository includes all the essential components required for machine learning pipelines that facilitate the forecasting process. To utilize the package, users are required to furnish their own data storage and retrieval interface.

# Table of contents
- [OpenSTEF](#openstef)
- [Table of contents](#table-of-contents)
- [External information sources](#external-information-sources)
- [Installation](install)
- [Usage](usage)
- [Reference Implementation](reference-implementation)
- [Database connector for OpenSTEF](Openstef-dbc-Database-connector-for-openstef)
- [License](license)
- [Licences third-party libraries](licenses-third-party-libraries)
- [Contributing](contributing)
- [Contact](contact)
- [Installation](#installation)
- [Install the openstef package](#install-the-openstef-package)
- [Remark regarding installation within a **conda environment on Windows**:](#remark-regarding-installation-within-a-conda-environment-on-windows)
- [Usage](#usage)
- [Reference Implementation](#reference-implementation)
- [Openstef-dbc - Database connector for openstef](#openstef-dbc---database-connector-for-openstef)
- [Example notebooks](#example-notebooks)
- [License](#license)
- [Licenses third-party libraries](#licenses-third-party-libraries)
- [Contributing](#contributing)
- [Contact](#contact)

# External information sources
- [Documentation website](https://openstef.github.io/openstef/index.html);
Expand All @@ -52,10 +57,6 @@ OpenSTEF is a Python package designed for generating short-term forecasts in the
pip install openstef
```

_**Optional**_: if you would like to use the proloaf model with OpenSTEF install the proloaf dependencies by running:
```shell
pip install openstef[proloaf]
```
### Remark regarding installation within a **conda environment on Windows**:

A version of the pywin32 package will be installed as a secondary dependency along with the installation of the openstef package. Since conda relies on an old version of pywin32, the new installation can break conda's functionality. The following command can solve this issue:
Expand Down
1 change: 0 additions & 1 deletion openstef/data_classes/prediction_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class PredictionJobDataClass(BaseModel):
- ``"xgb_quantile"``
- ``"lgb"``
- ``"linear"``
- ``"proloaf"`` (extra dependencies requiered, see README)

If unsure what to pick, choose ``"xgb"``.

Expand Down
1 change: 0 additions & 1 deletion openstef/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class MLModelType(Enum):
XGB_QUANTILE = "xgb_quantile"
LGB = "lgb"
LINEAR = "linear"
ProLoaf = "proloaf"
ARIMA = "arima"


Expand Down
6 changes: 0 additions & 6 deletions openstef/feature_engineering/apply_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
import pandas as pd

from openstef.data_classes.prediction_job import PredictionJobDataClass
from openstef.feature_engineering.historic_features import (
add_historic_load_as_a_feature,
)
from openstef.feature_engineering.holiday_features import (
generate_holiday_feature_functions,
)
Expand Down Expand Up @@ -69,9 +66,6 @@ def apply_features(
np.random.uniform(0.7,1.7, 200)))

"""
# Add if needed the proloaf feature (historic_load)
data = add_historic_load_as_a_feature(data, pj)

# Get lag feature functions
feature_functions = generate_lag_feature_functions(feature_names, horizon)

Expand Down
6 changes: 1 addition & 5 deletions openstef/feature_engineering/feature_applicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,7 @@ def add_features(

# NOTE this is required since apply_features could add additional features
if self.feature_names is not None:
# Add horizon to requested features else it is removed, and if needed the proloaf feature (historic_load)
if pj.get("model") == "proloaf":
features = self.feature_names + ["historic_load"] + ["horizon"]
else:
features = self.feature_names + ["horizon"]
features = self.feature_names + ["horizon"]
result = remove_non_requested_feature_columns(result, features)

# Sort all features except for the (first) load and (last) horizon columns
Expand Down
40 changes: 0 additions & 40 deletions openstef/feature_engineering/historic_features.py

This file was deleted.

27 changes: 0 additions & 27 deletions openstef/model/model_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
from openstef.model.regressors.arima import ARIMAOpenstfRegressor

logger = structlog.get_logger(__name__)
try:
from openstef.model.regressors.proloaf import OpenstfProloafRegressor
except ImportError:
logger.info("Proloaf not available, setting constructor to None")
OpenstfProloafRegressor = None

valid_model_kwargs = {
MLModelType.XGB: [
Expand Down Expand Up @@ -84,27 +79,6 @@
"max_depth",
"early_stopping_rounds",
],
MLModelType.ProLoaf: [
"relu_leak",
"encoder_features",
"decoder_features",
"core_layers",
"rel_linear_hidden_size",
"rel_core_hidden_size",
"dropout_fc",
"dropout_core",
"training_metric",
"metric_options",
"optimizer_name",
"early_stopping_patience",
"early_stopping_margin",
"learning_rate",
"max_epochs",
"device",
"batch_size",
"history_horizon",
"horizon_minutes",
],
MLModelType.LINEAR: [
"missing_values",
"imputation_strategy",
Expand All @@ -127,7 +101,6 @@ class ModelCreator:
MLModelType.XGB: XGBOpenstfRegressor,
MLModelType.LGB: LGBMOpenstfRegressor,
MLModelType.XGB_QUANTILE: XGBQuantileOpenstfRegressor,
MLModelType.ProLoaf: OpenstfProloafRegressor,
MLModelType.LINEAR: LinearOpenstfRegressor,
MLModelType.ARIMA: ARIMAOpenstfRegressor,
}
Expand Down
53 changes: 3 additions & 50 deletions openstef/model/objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: MPL-2.0
import copy
from datetime import datetime
from datetime import datetime, timezone
from typing import Any, Callable, Optional

import optuna
Expand Down Expand Up @@ -59,7 +59,7 @@ def __init__(
self.validation_data = None
self.test_data = None
self.model = model
self.start_time = datetime.utcnow()
self.start_time = datetime.now(timezone.utc)
self.test_fraction = test_fraction
self.validation_fraction = validation_fraction
self.eval_metric = eval_metric
Expand Down Expand Up @@ -94,7 +94,7 @@ def __call__(
split_args = self.split_args
if split_args is None:
split_args = {
"stratification_min_max": self.model_type != MLModelType.ProLoaf,
"stratification_min_max": True,
"back_test": True,
}
(
Expand Down Expand Up @@ -349,53 +349,6 @@ def get_pruning_callback(self, trial: optuna.trial.FrozenTrial):
)


class ProLoafRegressorObjective(RegressorObjective):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.model_type = MLModelType.ProLoaf

def get_params(self, trial: optuna.trial.FrozenTrial) -> dict:
"""Get parameters for ProLoaf Regressor Objective with objective specific parameters.

Args: trial

Returns:
Dictionary with hyperparameter name as key and hyperparamer value as value.

"""
# Filtered default parameters
model_params = super().get_params(trial)

# ProLoaf specific parameters
params = {
# TODO: look into optimizing this pipeline for proloaf
# "relu_leak": trial.suggest_float("relu_leak", 0.1, 1.0),
# "core_layers": trial.suggest_int("core_layers", 1, 3),
# "rel_linear_hidden_size": trial.suggest_float(
# "rel_linear_hidden_size", 0.1, 1
# ),
# "rel_core_hidden_size": trial.suggest_float("rel_core_hidden_size", 0.1, 1),
# "dropout_fc": trial.suggest_float("dropout_fc", 0.1, 0.9),
# "dropout_core": trial.suggest_float("dropout_core", 0.1, 0.9),
# "early_stopping_patience": trial.suggest_int(
# "early_stopping_patience", 5, 10
# ),
# "early_stopping_margin": trial.suggest_float(
# "early_stopping_margin", 0.1, 0.9
# ),
"max_epochs": trial.suggest_int(
"max_epochs", 1, 1
), # TODO: change after having availability to gpu resource
"batch_size": trial.suggest_int("batch_size", 1, 24),
}
return {**model_params, **params}

def get_pruning_callback(self, trial: optuna.trial.FrozenTrial):
return optuna.integration.PyTorchLightningPruningCallback(
trial, monitor="val_loss"
)


class LinearRegressorObjective(RegressorObjective):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down
2 changes: 0 additions & 2 deletions openstef/model/objective_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from openstef.model.objective import (
LGBRegressorObjective,
LinearRegressorObjective,
ProLoafRegressorObjective,
RegressorObjective,
XGBQuantileRegressorObjective,
XGBRegressorObjective,
Expand All @@ -25,7 +24,6 @@ class ObjectiveCreator:
MLModelType.XGB: XGBRegressorObjective,
MLModelType.LGB: LGBRegressorObjective,
MLModelType.XGB_QUANTILE: XGBQuantileRegressorObjective,
MLModelType.ProLoaf: ProLoafRegressorObjective,
MLModelType.LINEAR: LinearRegressorObjective,
MLModelType.ARIMA: ARIMARegressorObjective,
}
Expand Down
Loading
Loading