Skip to content
This repository was archived by the owner on Aug 16, 2024. It is now read-only.
This repository was archived by the owner on Aug 16, 2024. It is now read-only.

FanovaImportanceEvaluator mutates study.trials[-1].distributions when a parameter has dynamic range #23

@sgrubas

Description

@sgrubas

Hello,
Thank you for your great work!

I ran into an issue with using FanovaImportanceEvaluator. For some reason, it changes the last trial of a study when the search space of a parameter depends on another parameter. See the code snippet below:

import optuna
from optuna_fast_fanova import FanovaImportanceEvaluator
optuna.logging.set_verbosity(optuna.logging.WARNING)

def test_objective(trial):
    x = trial.suggest_float('x', 1, 4)
    y = trial.suggest_float('y', x, 5)
    return x**2 + y**2
    

test_study = optuna.create_study(study_name="Test", direction='minimize')
test_study.optimize(test_objective, n_trials=100, show_progress_bar=True)

importances = optuna.importance.get_param_importances(test_study, evaluator=FanovaImportanceEvaluator())
for trial in test_study.trials:
    if trial.distributions.keys() != trial.params.keys():
        print(trial)

The output:

FrozenTrial(number=99, state=TrialState.COMPLETE, values=[3.7186055946265806], 
datetime_start=datetime.datetime(2024, 2, 22, 18, 43, 50, 977310), 
datetime_complete=datetime.datetime(2024, 2, 22, 18, 43, 50, 981316), 
params={'x': 1.3032071826948155, 'y': 1.4213573208729824}, user_attrs={}, system_attrs={}, intermediate_values={}, 
distributions={'x': FloatDistribution(high=4.0, log=False, low=1.0, step=None)}, trial_id=99, value=None)

P.S. Usage of the default evaluator evaluator=None does not give this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions