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

[Feature] Change study to a property #5

Merged
merged 7 commits into from
Jul 19, 2024
Merged
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
10 changes: 7 additions & 3 deletions mqboost/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,13 @@ def _study_func(trial: optuna.Trial) -> float:
get_params_func=get_params_func,
)

study = optuna.create_study(
self._study = optuna.create_study(
study_name=f"MQBoost_{self._model}",
direction="minimize",
load_if_exists=True,
)
study.optimize(_study_func, n_trials=n_trials)
return study.best_params
self._study.optimize(_study_func, n_trials=n_trials)
return self._study.best_params

def __optuna_objective(
self,
Expand Down Expand Up @@ -282,3 +282,7 @@ def __is_xgb(self) -> bool:
def __is_fitted(self) -> None:
if not getattr(self, "_fitted", False):
raise FittingException("train must be executed before predict")

@property
def study(self) -> optuna.Study:
return getattr(self, "_study", None)