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

Display conditional parameters properly in TrialTable #740

Conversation

nabenabe0928
Copy link
Collaborator

Contributor License Agreement

This repository (optuna-dashboard) and Goptuna share common code.
This pull request may therefore be ported to Goptuna.
Make sure that you understand the consequences concerning licenses and check the box below if you accept the term before creating this pull request.

  • I agree this patch may be ported to Goptuna by other Goptuna contributors.

Reference Issues/PRs

This PR solves issue#734.

What does this implement/fix? Explain your changes.

By this PR, TrialTable can:

  1. display conditional parameters appropriately, and
  2. filter missing value via filtering.

Copy link

codecov bot commented Dec 28, 2023

Codecov Report

Attention: 21 lines in your changes are missing coverage. Please review.

Comparison is base (1203501) 68.22% compared to head (c13654f) 69.71%.
Report is 443 commits behind head on main.

Files Patch % Lines
optuna_dashboard/artifact/_backend.py 59.45% 15 Missing ⚠️
optuna_dashboard/_app.py 85.71% 5 Missing ⚠️
optuna_dashboard/_serializer.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #740      +/-   ##
==========================================
+ Coverage   68.22%   69.71%   +1.48%     
==========================================
  Files          35       35              
  Lines        2329     2364      +35     
==========================================
+ Hits         1589     1648      +59     
+ Misses        740      716      -24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nabenabe0928 nabenabe0928 marked this pull request as ready for review December 28, 2023 06:54
@c-bata c-bata assigned c-bata and keisuke-umezawa and unassigned c-bata Jan 11, 2024
@c-bata
Copy link
Member

c-bata commented Jan 11, 2024

@keisuke-umezawa Could you review this PR?

@c-bata
Copy link
Member

c-bata commented Feb 6, 2024

Let me assign @porink0424 as an additional reviewer 🙏

@porink0424
Copy link
Collaborator

Sure.

Copy link
Collaborator

@porink0424 porink0424 left a comment

Choose a reason for hiding this comment

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

LGTM!

@c-bata
Copy link
Member

c-bata commented Feb 6, 2024

@keisuke-umezawa Please merge this PR after you approved 🙏

Copy link
Member

@keisuke-umezawa keisuke-umezawa left a comment

Choose a reason for hiding this comment

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

Sorry for being late. I left one comment. Could you check it?

trials[i].params.find((p) => p.name === s.name)?.param_external_value ||
null,
sortable: sortable,
filterChoices: isDynamicSpace ? filterChoicesWithNull : filterChoices,
Copy link
Member

Choose a reason for hiding this comment

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

isDynamicSpace is calculated for each study, but filterChoices is set for each column. This isDynamicSpace should be implemented as the value whether the column is dynamic space.

import optuna


def objective(trial):
    category = trial.suggest_categorical("category", ["foo", "bar"])
    if category == "foo":
        return (trial.suggest_float("x1", 0, 10) - 2) ** 2
    else:
        return -((trial.suggest_float("x2", -10, 0) + 5) ** 2)


study = optuna.create_study(storage="sqlite:///test.db")
study.optimize(objective, n_trials=100)

In the above code, this study's isDynamicSpace is always true because some of columns are dynamic spaces. As a result, filterChoices will be filterChoicesWithNull even though category is not dynamic space.

Copy link
Member

Choose a reason for hiding this comment

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

Or, something like this?

const filterChoices =
      s.distribution.type === "CategoricalDistribution"
        ? s.distribution.choices.map((c) => c.value)
        : undefined
values = trials[i].params.find((p) => p.name === s.name)?.param_external_value
if values.contain(null):
    filterChoices.append(null)

@nabenabe0928 nabenabe0928 force-pushed the bug-fix/display-conditional-params-properly branch from 275542a to c63f15b Compare February 13, 2024 16:20
@nabenabe0928 nabenabe0928 force-pushed the bug-fix/display-conditional-params-properly branch from c63f15b to c13654f Compare February 13, 2024 16:22
@nabenabe0928
Copy link
Collaborator Author

@keisuke-umezawa Thank you for the suggestion, I addressed your point!

Copy link
Member

@keisuke-umezawa keisuke-umezawa left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you for quick fix.

@keisuke-umezawa keisuke-umezawa merged commit e0bc7d9 into optuna:main Feb 22, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants