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

Incorrect sorting of objective values in Trials Table #1021

Closed
robin-janssen opened this issue Jan 26, 2025 · 0 comments · Fixed by #1025
Closed

Incorrect sorting of objective values in Trials Table #1021

robin-janssen opened this issue Jan 26, 2025 · 0 comments · Fixed by #1025
Labels
bug Something isn't working

Comments

@robin-janssen
Copy link

Description

This issue was previously discussed and marked as solved in #20, but I am still facing this issue:

Image

The values seem to be sorted as strings, i.e., the scientific notation is not interpreted as float.
Note that in the Optuna-dashboard VSCode plugin, this issue does not arise - the trials are correctly sorted.


As an additional note, I would find it very helpful if the interval for scientific notation was increased. Currently, they seem to be used only for very small values starting from 1e-7, and not at all for very large values. Would it be possible to display values outside the interval [1e-4,1000) in this notation? I find this easier to interpret than 0.0002 and 0.00001, or 10000 and 100000.

How to Reproduce

  1. Run the following script to generate a dummy database:
import os
import random
import optuna

# Define the path for the SQLite database
DB_FILENAME = "optuna_study.db"
DB_URL = f"sqlite:///{DB_FILENAME}"

# Remove existing DB file if you want to start fresh each time
if os.path.exists(DB_FILENAME):
    os.remove(DB_FILENAME)


def objective(trial):
    """
    Objective function that returns a value with varying magnitudes.
    """
    prefactor = random.uniform(0.1, 1)
    integer = random.randint(1, 10)
    base_value = 10**-integer
    objective_value = prefactor * base_value

    # Add optuna dummy suggestion
    trial.suggest_float("prefactor", 0.1, 1)

    return objective_value


def create_dummy_study(n_trials=50):
    """
    Creates an Optuna study with dummy trials having objective values
    across different magnitudes.
    """
    # Create a study with SQLite backend
    study = optuna.create_study(
        direction="minimize",
        storage=DB_URL,
        study_name="dummy_study",
        load_if_exists=False,
    )

    # Optimize the study with the objective function
    study.optimize(objective, n_trials=n_trials)

    return study


if __name__ == "__main__":
    # Create the dummy study
    study = create_dummy_study(n_trials=50)
  1. Run optuna-dashboard: optuna-dashboard --port 8082 sqlite:///optuna_study.db
  2. Go to trials Table and play around with the sorting.

Python version

Python 3.10.12

Optuna version

4.2.0

optuna-dashboard version or git revision

0.17.0

Web browser

Safari

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant