Files
Mark Aron Szulyovszky b5ddee8dce feat(HPO): added run_hpo script (#237)
* feat(HPO): added `run_hpo` script

* fix(Linter): ran

* feat(HPO): removed any reference to sweep (superseeded by optuna)

* fix(HPO): optimize for sharpe

* fix(Config): removed glassnode data, save trials from hpo

* feat(Labelling): added three-balanced method works again

* fix(BetSizing): set the correct class labels

* fix(HPO): powerset should return what's expected, added two new normalization methods

* fix(Linter): ran

* fix(DataLoader): sort the dataframe when fetching data

* fix(Config): only take z-score of other assets
2022-03-15 14:43:16 +01:00

40 lines
1.4 KiB
Python

from config.types import RawConfig
from run_pipeline import run_pipeline
from config.presets import get_default_config
import optuna
from utils.helpers import powerset
config = get_default_config()
config.save_models = False
def train(trial):
search_space = {
"n_features_to_select": trial.suggest_int("n_features_to_select", 10, 200),
"forecasting_horizon": trial.suggest_int("forecasting_horizon", 3, 300),
"own_features": trial.suggest_categorical(
"own_features", powerset(["z_score", "level_2", "level_1"])
),
"other_features": trial.suggest_categorical(
"other_features", powerset(["z_score", "level_2", "level_1"])
),
"labeling": trial.suggest_categorical(
"labeling", ["two_class", "three_class_balanced", "three_class_imbalanced"]
),
"scaler": trial.suggest_categorical(
"scaler",
["normalize", "minmax", "standardize", "robust", "box-cox", "quantile"],
),
}
trial_config = RawConfig(**vars(config) | search_space)
outcome, _ = run_pipeline(
project_name="test", with_wandb=False, raw_config=trial_config
)
return 1 - outcome.get_output_stats()["sharpe"]
study = optuna.create_study()
study.optimize(train, n_trials=40)
print(study.best_params)
study.trials_dataframe().to_csv("output/trials.csv")