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

Make error message for create_study's direction easier to understand #5806

Open
not522 opened this issue Nov 29, 2024 · 2 comments
Open

Make error message for create_study's direction easier to understand #5806

not522 opened this issue Nov 29, 2024 · 2 comments
Labels
code-fix Change that does not change the behavior, such as code refactoring. contribution-welcome Issue that welcomes contribution.

Comments

@not522
Copy link
Member

not522 commented Nov 29, 2024

Motivation

Users sometimes makes the mistake of passing the list of directions to the direction argument. The error message for this mistake is hard to understand what is the problem.

  • Correct
optuna.create_study(directions=["minimize", "minimize"])
  • Wrong

Using direction instead of directions

optuna.create_study(direction=["minimize", "minimize"])
ValueError: Please set either 'minimize' or 'maximize' to direction. You can also set the corresponding `StudyDirection` member.

Suggestion

We can make the error message more helpful for the mistake. It can be something like "for multi-objective optimization, using directions instead of direction".

Additional context (optional)

No response

@not522 not522 added code-fix Change that does not change the behavior, such as code refactoring. contribution-welcome Issue that welcomes contribution. labels Nov 29, 2024
@unKnownNG
Copy link
Contributor

Hello,
I would like to take this issue. Can I know which file I have to change it for the error message. There are many files so it is confusing.

Thank you.

@not522
Copy link
Member Author

not522 commented Dec 2, 2024

Thanks! It's study/study.py.

optuna/optuna/study/study.py

Lines 1254 to 1257 in b29fdff

raise ValueError(
"Please set either 'minimize' or 'maximize' to direction. You can also set the "
"corresponding `StudyDirection` member."
)

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. contribution-welcome Issue that welcomes contribution.
Projects
None yet
Development

No branches or pull requests

2 participants