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

Add rank plot #4427

Merged
merged 17 commits into from
Apr 12, 2023
Merged

Add rank plot #4427

merged 17 commits into from
Apr 12, 2023

Conversation

contramundum53
Copy link
Member

@contramundum53 contramundum53 commented Feb 16, 2023

Motivation

optuna/optuna-dashboard#384

Description of the changes

Add plot_rank function.
This plots the parameter relationship as pairwise scatter plots with colors indicating the (normalized) rank of the objective value within the entire study.

image

@github-actions github-actions bot added the optuna.visualization Related to the `optuna.visualization` submodule. This is automatically labeled by github-actions. label Feb 16, 2023
@codecov-commenter
Copy link

codecov-commenter commented Feb 16, 2023

Codecov Report

Merging #4427 (fe7859e) into master (1599d23) will increase coverage by 0.10%.
The diff coverage is 98.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master    #4427      +/-   ##
==========================================
+ Coverage   90.79%   90.89%   +0.10%     
==========================================
  Files         187      188       +1     
  Lines       13932    14132     +200     
==========================================
+ Hits        12649    12845     +196     
- Misses       1283     1287       +4     
Impacted Files Coverage Δ
optuna/visualization/_rank.py 97.98% <97.98%> (ø)
optuna/visualization/__init__.py 100.00% <100.00%> (ø)

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

@c-bata
Copy link
Member

c-bata commented Feb 17, 2023

@cross32768 Could you review this PR?

@c-bata c-bata assigned hvy and cross32768 and unassigned cross32768 Feb 17, 2023
@c-bata
Copy link
Member

c-bata commented Feb 17, 2023

@hvy Could you review this PR?

Copy link
Member

@hvy hvy 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 PR.
I've mostly only went over the data preparation part but left some comments if you could take a look.

Also,

  • Could you add unit tests similar to our other visualization functions and the logic indeed has several conditionals?
  • Could you add this function to the API reference under docs/?
  • Could you import this function in visualization/__init__.py?
  • How about making the plots consistent when plotting with a single parameter specified using params=["some_param"] and the diagonal plots created by params=None ?

This is more of a question but did you consider add a thin border around the scatter dots as in plot_slice? Applying it here as well might be consistent and perhaps make it easier to comprehend? 🤔

optuna/visualization/_rank.py Show resolved Hide resolved
optuna/visualization/_rank.py Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

This pull request has not seen any recent activity.

@github-actions github-actions bot added the stale Exempt from stale bot labeling. label Feb 27, 2023
@contramundum53
Copy link
Member Author

We noticed that this PR requires plotly.colors.sample_colorscale, which is newly introduced in plotly v5.0.0. There seems to be no workaround except for reimplementing the logic.

@contramundum53
Copy link
Member Author

contramundum53 commented Feb 28, 2023

did you consider add a thin border around the scatter dots as in plot_slice? Applying it here as well might be consistent and perhaps make it easier to comprehend? 🤔

I tried it but it produced no visible difference to me. I can add it to be consistent.

@contramundum53
Copy link
Member Author

@hvy Thanks for your comments. I fixed those points, could you take another look?

@github-actions github-actions bot removed the stale Exempt from stale bot labeling. label Feb 28, 2023
@contramundum53 contramundum53 added the enhancement Change that does not break compatibility and not affect public interfaces, but improves performance. label Mar 1, 2023
@hvy
Copy link
Member

hvy commented Mar 3, 2023

did you consider add a thin border around the scatter dots as in plot_slice? Applying it here as well might be consistent and perhaps make it easier to comprehend? 🤔

I tried it but it produced no visible difference to me. I can add it to be consistent.

Hm, I noticed a visual difference with "line":{"width": 0.5, "color": "Grey"}. What do you say, should we apply it?

@@ -71,7 +71,7 @@ jobs:
# Install dependencies with minimum versions.
pip uninstall -y alembic cmaes packaging sqlalchemy plotly scikit-learn
pip install alembic==1.5.0 cmaes==0.9.1 packaging==20.0 sqlalchemy==1.3.0 numpy==1.20.3 tqdm==4.27.0 colorlog==0.3 PyYAML==5.1
pip install plotly==4.9.0 scikit-learn==0.24.2 # optional extras
pip install plotly==5.0.0 scikit-learn==0.24.2 # optional extras
Copy link
Member

Choose a reason for hiding this comment

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

should we check this with the other maintainers? also, should we not update pyproject.toml ?

Copy link
Member Author

@contramundum53 contramundum53 Mar 3, 2023

Choose a reason for hiding this comment

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

Updating pyproject.toml would prevent plotly-4.9.0 users from using other visualization tools or accessing other optuna updates, so I don't think that's desirable.
For whether to depend on the newer version of plotly or reimplment the logic ourselves, I think we could have a discussion. What do you think, @toshihikoyanase ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I had a discussion with @toshihikoyanase . We agreed that

  • Updating the required dependency would be undesirable.
  • Since this functionality is experimental, we could add a nice assertion message on plotly version and reimplement the logic if users really need it.

Copy link
Member

Choose a reason for hiding this comment

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

I think we may want to memorize why plotly versions are inconsistent between pyproject.toml and this configuration. Someone may try to fix the inconsistency. How about leaving a comment on it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a comment.

@hvy hvy removed their assignment Mar 3, 2023
@contramundum53
Copy link
Member Author

contramundum53 commented Mar 3, 2023

Hm, I noticed a visual difference with "line":{"width": 0.5, "color": "Grey"}. What do you say, should we apply it?

Could you show me some images? I'm not sure if I'm reproducing it right. @hvy

@contramundum53
Copy link
Member Author

@not522 Could you review this PR?

docs/source/reference/visualization/index.rst Show resolved Hide resolved
optuna/visualization/_rank.py Outdated Show resolved Hide resolved
optuna/visualization/_rank.py Outdated Show resolved Hide resolved
optuna/visualization/_rank.py Outdated Show resolved Hide resolved
@cross32768
Copy link
Contributor

Thank you for responding to the review. LGTM!

@github-actions
Copy link
Contributor

This pull request has not seen any recent activity.

@github-actions github-actions bot added the stale Exempt from stale bot labeling. label Mar 21, 2023
@cross32768 cross32768 removed their assignment Mar 24, 2023
optuna/visualization/_rank.py Show resolved Hide resolved
showscale=True,
cmin=0,
cmax=1,
colorbar=dict(thickness=10, tickvals=tick_coloridxs, ticktext=ticktext),
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 adding the title?

Suggested change
colorbar=dict(thickness=10, tickvals=tick_coloridxs, ticktext=ticktext),
colorbar=dict(thickness=10, tickvals=tick_coloridxs, ticktext=ticktext, title=f"Rank ({info.target_name})"),

Copy link
Member Author

Choose a reason for hiding this comment

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

image

In my opinion, this looks a bit too redundant and noisy.

Copy link
Member

Choose a reason for hiding this comment

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

Hmmm, but without that, isn't it hard to understand what the numbers mean?

Copy link
Member Author

Choose a reason for hiding this comment

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

What about changing the title of the plot to Rank (Objective Value)?

Copy link
Member

Choose a reason for hiding this comment

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

That seems reasonable!

Copy link
Member Author

Choose a reason for hiding this comment

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

@not522 PTAL.

@github-actions github-actions bot removed the stale Exempt from stale bot labeling. label Mar 26, 2023
Copy link
Member

@not522 not522 left a comment

Choose a reason for hiding this comment

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

LGTM.
@hvy Have your concerns been resolved? If so, please merge it.

@not522 not522 removed their assignment Apr 11, 2023
@hvy hvy mentioned this pull request Apr 12, 2023
Copy link
Member

@hvy hvy left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Change that does not break compatibility and not affect public interfaces, but improves performance. 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.

None yet

7 participants