optuna_dashboard.ChoiceWidget

class optuna_dashboard.ChoiceWidget(choices, values, description=None, user_attr_key=None)

A widget representing a choice with associated values.

Parameters:
  • choices (list[str]) – A list of strings representing the available choices.

  • values (list[float]) – A list of float values associated with each choice.

  • description (Optional[str]) – A description of the widget. Defaults to None.

  • user_attr_key (Optional[str]) – The key used by register_user_attr_form_widgets. Form output is saved as trial.user_attrs[user_attr_key]. Defaults to None.

Example

from optuna_dashboard import ChoiceWidget


choice_widget = ChoiceWidget(
    choices=["A", "B", "C"], values=[1.0, 2.0, 3.0], description="Choose one"
)

Methods

to_dict()

Convert the ChoiceWidget object to a dictionary.

Attributes

description

user_attr_key

choices

values

to_dict()

Convert the ChoiceWidget object to a dictionary.

Returns:

A dictionary representing the ChoiceWidget object.

Return type:

ChoiceWidgetJSON