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

Enhance Optuna Visualization with Advanced Plotting for Optimization History #182

Closed
wants to merge 7 commits into from

Conversation

nourbc211
Copy link

Contributor Agreements

Please read the contributor agreements and if you agree, please click the checkbox below.

  • [ x] I agree to the contributor agreements.

Motivation

This pull request enhances Optuna’s visualization by introducing new customization options, improving the clarity and interpretability of optimization history plots.Originally, this feature was proposed in the main Optuna repository, but it was suggested by a maintainer that OptunaHub would be a more suitable location.

Description of the changes

•	Added display_param_label: Displays detailed parameter labels on hover for each trial.
•	Added view_x_in_log_scale: Enables a logarithmic x-axis scale for trial numbers, ideal for extensive trials.
•	Added display_log_difference: Plots the log difference between each trial’s objective value and the best value so far, aiding in convergence analysis.

TODO List towards PR Merge

Please remove this section if this PR is not an addition of a new package.
Otherwise, please check the following TODO list:

  • [ x] Copy ./template/ to create your package
  • [x ] Replace <COPYRIGHT HOLDER> in LICENSE of your package with your name
  • [x ] Fill out README.md in your package
  • [ x] Add import statements of your function or class names to be used in __init__.py
  • [x ] (Optional) Add from __future__ import annotations at the head of any Python files that include typing to support older Python versions
  • [x ] Apply the formatter based on the tips in README.md
  • [x ] Check whether your module works as intended based on the tips in README.md

@y0z y0z self-assigned this Nov 18, 2024
Copy link
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.

Thank you for your contribution!
To merge this PR, several fixes are needed.

Please update your PR following the comments below.

The following tutorials will help you update your PR. These documentations provide information to correctly and properly implement visualization packages and register the package.

Seeing PRs already merged to add visualization functionalities, e.g., #144, is also an excellent way to understand the proper process.

If you have any difficulties fixing the PR, please let me know.

test_optu.py Outdated
Comment on lines 4 to 8
module = optunahub.load_module(
package="optuna_enhanced_visualization",
repo_owner="nourbc211",
ref="main",
)
Copy link
Member

Choose a reason for hiding this comment

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

Please do not load the package from your fork of optunahub-registry.
I think this test file can be removed since it simply loads the module.

Suggested change
module = optunahub.load_module(
package="optuna_enhanced_visualization",
repo_owner="nourbc211",
ref="main",
)
module = optunahub.load_module(
package="visualization/optuna_enhanced_visualization",
)


```python
import optuna
from optuna_enhanced_visualization import plot_optimization_history
Copy link
Member

Choose a reason for hiding this comment

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

Please use optunahub.load_module to load your package.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for your feedback! I'll make the changes asap

@y0z y0z added the new-package New packages label Nov 18, 2024
@nourbc211
Copy link
Author

i have an issue caused by the readme file when pre-commit/action but i don't see where the problem could be. the .pre-commit-config.yaml is supposed to exclude this file anyway. Do you have an idea of what i could do to fix it ?

@y0z
Copy link
Member

y0z commented Nov 27, 2024

Your README may have a format error. Please correct the format carefully.

I discovered a problem.
Using display_param_label and display_log_difference simultaneously causes TypeError.
Could you fix this?

fig = plot_optimization_history(
    study,
    display_param_label=True,
    view_x_in_log_scale=False,
    display_log_difference=True,
)
fig.show()
    f"{plot_values[idx]:.4f}<br>{params}"
      ^^^^^^^^^^^^^^^^^^^^^^
TypeError: unsupported format string passed to NoneType.__format__

@y0z
Copy link
Member

y0z commented Dec 10, 2024

Due to a lack of reaction, I close this PR. If you want to continue working on this task, please reopen this PR.

@y0z y0z closed this Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-package New packages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants