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

Fix differential evolution #1150

Open
wants to merge 3 commits into
base: development
Choose a base branch
from

Conversation

hadarshavit
Copy link

Fix for differential evolution acquisition function optimisation.
Fixing a bug that it didn't work when the configspace has categorical/integer hyperparameters.

@benjamc benjamc changed the base branch from main to development October 24, 2024 16:23
@benjamc
Copy link
Contributor

benjamc commented Oct 24, 2024

Can you merge the current development branch into your branch?

@hadarshavit
Copy link
Author

Done

Copy link
Contributor

@benjamc benjamc left a comment

Choose a reason for hiding this comment

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

In principle LGTM. Could you describe a bit more why we need this fix?
Why did it work before?

Oh and can you also update the CHANGELOG.md?
Thanks!

@hadarshavit
Copy link
Author

When using categorical hyperparameters differential evolution returned an exception.
For example, modifying the SVM example (examples/1_basics/2_svm_cv.py) to:

    initial_design = HyperparameterOptimizationFacade.get_initial_design(scenario, n_configs=5)
    acq_opt = DifferentialEvolution(classifier.configspace)

    # Now we use SMAC to find the best hyperparameters
    smac = HyperparameterOptimizationFacade(
        scenario,
        classifier.train,
        initial_design=initial_design,
        acquisition_maximizer=acq_opt,
        overwrite=True,  # If the run exists, we overwrite it; alternatively, we can continue from last state
    )

Results in:
ValueError: Got unexpected float value while trying to transform a vector representation into a value in ['linear' 'poly' 'rbf' 'sigmoid'].Expected integers but got [0.17368738] (dtype: float64)

The fix simply transforms float vectors (like the ones scipy's differential evolution outputs) to valid configs.
The test (tests/test_acquisition/test_maximizers.py) has a configspace of 2 float hyperparameters, and therefore passes.

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.

2 participants