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

Conversation

chulhongsung
Copy link
Contributor

@chulhongsung chulhongsung commented Jul 19, 2024

What does this PR do?

Change optuna.Study to property.

How to test this?

mq_lgb = MQRegressor(
    x=x_data,
    y=y_data,
    alphas=alphas,
)

mq_lgb.train(n_trials=5)
mq_lgb.study

Copy link
Owner

@RektPunk RektPunk left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution. BTW, please install pre-commit so that makes code lint.

mqboost/engine.py Outdated Show resolved Hide resolved
@RektPunk RektPunk changed the title [Feature] Add study method [Feature] Change study to a property Jul 19, 2024
@chulhongsung chulhongsung requested a review from RektPunk July 19, 2024 07:14
@RektPunk RektPunk self-assigned this Jul 19, 2024
Copy link
Owner

@RektPunk RektPunk left a comment

Choose a reason for hiding this comment

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

LGTM


@property
def study(self) -> optuna.Study:
return self._study
Copy link
Owner

Choose a reason for hiding this comment

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

Could you replace this line with something like:

Suggested change
return self._study
return getattr(self, "_study", None)

This helps prevent calling a variable before it's assigned.

@RektPunk RektPunk merged commit 5bbe58d into RektPunk:main Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants