Skip to content

Deprecate consider_prior in TPESampler#6005

Merged
y0z merged 1 commit intooptuna:masterfrom
sawa3030:deprecate-consider-prior
Mar 11, 2025
Merged

Deprecate consider_prior in TPESampler#6005
y0z merged 1 commit intooptuna:masterfrom
sawa3030:deprecate-consider-prior

Conversation

@sawa3030
Copy link
Copy Markdown
Collaborator

@sawa3030 sawa3030 commented Mar 10, 2025

Motivation

In TPESampler, when consider_prior is set to False, samples that were not selected during the initial exploration are unlikely to be chosen in subsequent samplings. This behavior is undesirable, so consider_prior should be deprecated and always set to True.

Description of the changes

  • Deprecation warning is added to the code and the docstring of TPESampler.
    • consider_prior constructs _ParzenEstimatorParameters in the init function of TPESampler, so ideally, deprecation warning is generated in the _ParzenEstimatorParameters. However, NamedTuple doesn’t support overriding new, and the adding a deprecation warning there would require extensive refactoring. Therefore, the warning is instead placed in TPESampler.
    • In addition to that, field names in NamedTuple cannot start with an underscore, and changing the field name to _consider_prior is not allowed in _ParzenEstimatorParameters.
  • consider_prior will be fixed to True in future PRs.

@sawa3030 sawa3030 marked this pull request as ready for review March 10, 2025 06:49
@y0z y0z added the code-fix Change that does not change the behavior, such as code refactoring. label Mar 10, 2025
@y0z
Copy link
Copy Markdown
Member

y0z commented Mar 10, 2025

@HideakiImamura Could you review this PR?

Copy link
Copy Markdown
Member

@HideakiImamura HideakiImamura left a comment

Choose a reason for hiding this comment

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

Looks very good.

@HideakiImamura HideakiImamura removed their assignment Mar 11, 2025
Copy link
Copy Markdown
Member

@y0z y0z left a comment

Choose a reason for hiding this comment

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

LGTM

@y0z y0z added this to the v4.3.0 milestone Mar 11, 2025
@y0z y0z removed their assignment Mar 11, 2025
@y0z y0z merged commit 281a9c0 into optuna:master Mar 11, 2025
15 checks passed
@sawa3030 sawa3030 deleted the deprecate-consider-prior branch November 14, 2025 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-fix Change that does not change the behavior, such as code refactoring.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants