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

Allow user-defined objective names in hyperparameter importance plots #4986

Merged

Conversation

xadrianzetx
Copy link
Collaborator

Motivation

Closes #4895. Names can be specified via optuna.study.Study.set_metric_names. Additionally, _get_importances_infos has been factored out to DRY the code a bit.

Description of the changes

  • Use study.metric_names in plot_param_importances to derive custom objective names.
  • Factored out _get_importances_infos to DRY the code.
  • Added a test case.

Examples

Screenshot from 2023-10-01 13-51-30

Screenshot from 2023-10-01 13-50-47

Names can be specified via `optuna.study.Study.set_metric_names`.
Additionally, `_get_importances_infos` has been factored out to
DRY the code a bit.
@github-actions github-actions bot added the optuna.visualization Related to the `optuna.visualization` submodule. This is automatically labeled by github-actions. label Oct 1, 2023
@codecov
Copy link

codecov bot commented Oct 1, 2023

Codecov Report

Merging #4986 (0c58dbe) into master (0f3d2f8) will decrease coverage by 0.01%.
Report is 45 commits behind head on master.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #4986      +/-   ##
==========================================
- Coverage   89.49%   89.48%   -0.01%     
==========================================
  Files         202      202              
  Lines       14910    14938      +28     
==========================================
+ Hits        13343    13368      +25     
- Misses       1567     1570       +3     
Files Coverage Δ
optuna/visualization/_param_importances.py 98.41% <100.00%> (+0.16%) ⬆️
...una/visualization/matplotlib/_param_importances.py 100.00% <100.00%> (ø)

... and 12 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@not522 not522 added the feature Change that does not break compatibility, but affects the public interfaces. label Oct 2, 2023
@not522
Copy link
Member

not522 commented Oct 2, 2023

@HideakiImamura @Alnusjaponica Could you review this PR?

specific_create_study: Callable[[], Study], objective_names: list[str]
) -> None:
study = specific_create_study()
study.set_metric_names(objective_names)
Copy link
Member

Choose a reason for hiding this comment

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

How about testing the case of not setting the metric names?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added 👍

Copy link
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.

Thanks for the update! LGTM!

@HideakiImamura HideakiImamura removed their assignment Oct 5, 2023
Copy link
Collaborator

@Alnusjaponica Alnusjaponica left a comment

Choose a reason for hiding this comment

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

LGTM.

@Alnusjaponica Alnusjaponica added this to the v3.4.0 milestone Oct 12, 2023
@Alnusjaponica Alnusjaponica merged commit 3895ff8 into optuna:master Oct 12, 2023
33 checks passed
@xadrianzetx xadrianzetx deleted the param-importances-metric-names branch October 12, 2023 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Change that does not break compatibility, but affects the public interfaces. optuna.visualization Related to the `optuna.visualization` submodule. This is automatically labeled by github-actions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow user-defined objective names in hyperparameter importance plots
4 participants