-
Notifications
You must be signed in to change notification settings - Fork 35
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
Closed
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6381aa7
Apply pre-commit formatting and checks
nourbc211 f623a71
Finalize optuna enhanced visualization setup
nourbc211 578ddc9
Move optuna_enhanced_visualization to package/visualization
nourbc211 7e7e153
ReadMe modified, example.py and test_optu.py deleted
nourbc211 57fe714
.pre-commit-config.yaml restored
nourbc211 9cb2af9
ReadMe modified, example.py and test_optu.py deleted
nourbc211 3284427
bug fix
nourbc211 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 <DSBA Couscous Team> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
author: DSBA Couscous Team | ||
title: Optuna Enhanced Visualization | ||
description: Advanced visualization tools for Optuna, including optimization history plotting with detailed customization options. | ||
tags: [visualization] | ||
optuna_versions: ['3.6.1'] | ||
license: MIT License | ||
--- | ||
|
||
## Abstract | ||
|
||
This package offers advanced visualization functionalities for Optuna, enabling users to analyze optimization histories with customizable options, such as log-scale views and detailed parameter labels. This is useful for interpreting and optimizing complex hyperparameter tuning processes. | ||
|
||
## Class or Function Names | ||
|
||
- `plot_optimization_history` | ||
|
||
## Installation | ||
|
||
No additional dependencies are required beyond those included in Optuna. | ||
|
||
## Example | ||
|
||
```python | ||
import optuna | ||
from optuna_enhanced_visualization import plot_optimization_history | ||
|
||
def objective(trial): | ||
x = trial.suggest_float("x", -5, 5) | ||
return x**2 | ||
|
||
study = optuna.create_study() | ||
study.optimize(objective, n_trials=100) | ||
|
||
# Use the enhanced visualization | ||
plot_optimization_history(study) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from .visualization._optimization_history import plot_optimization_history | ||
|
||
|
||
__all__ = ["plot_optimization_history"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
This example is only for sampler. | ||
You can verify your sampler code using this file as well. | ||
Please feel free to remove this file if necessary. | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import optuna | ||
import optunahub | ||
|
||
|
||
def objective(trial: optuna.Trial) -> float: | ||
x = trial.suggest_float("x", -5, 5) | ||
y = trial.suggest_float("y", -5, 5) | ||
return x**2 + y**2 | ||
|
||
|
||
# TODO: Change package_name to test your package. | ||
package_name = "samplers/your_sampler" | ||
test_local = True | ||
|
||
if test_local: | ||
# This is an example of how to load a sampler from your local optunahub-registry. | ||
sampler = optunahub.load_local_module( | ||
package=package_name, | ||
registry_root="./", # Path to the root of the optunahub-registry. | ||
).YourSampler() | ||
else: | ||
# This is an example of how to load a sampler from your fork of the optunahub-registry. | ||
# Please remove repo_owner and ref arguments before submitting a pull request. | ||
sampler = optunahub.load_module( | ||
package=package_name, repo_owner="nourbc211", ref="main" | ||
).YourSampler() | ||
|
||
study = optuna.create_study(sampler=sampler) | ||
study.optimize(objective, n_trials=30) | ||
print(study.best_trials) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from ._optimization_history import plot_optimization_history | ||
|
||
|
||
__all__ = ["plot_optimization_history"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.There was a problem hiding this 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 feedback! I'll make the changes asap