Skip to main content

Hydra + SMAC

Project description

Hydra-SMAC 0.1.11

A minimal Python re-implementation of Hydra.

Getting started

pip install hydra-smac

Example

For more information on how to use Scenario objects, please refer to the SMAC documentation.

from ConfigSpace import Configuration, ConfigurationSpace, Float
from hydrasmac import Hydra
from smac import Scenario

instances = ["a", "b", "c"]
features = {"a": [0.0], "b": [1.0], "c": [2.0]}

cs = ConfigurationSpace()
cs.add_hyperparameters(
    [
        Float("x", (1.0, 5.0)),
        Float("y", (1.0, 5.0)),
        Float("z", (1.0, 5.0)),
    ]
)


def target_function(config: Configuration, instance: str, seed: int = 0) -> float:
    config_dict = config.get_dictionary()
    x, y, z = config_dict["x"], config_dict["y"], config_dict["z"]

    if instance == "a" and x < 2.5 and y > 2.5 and z > 2.5:
        return 0.001

    if instance == "b" and y < 2.5 and x > 2.5 and z > 2.5:
        return 0.01

    if instance == "c" and z < 2.5 and y > 2.5 and x > 2.5:
        return 0.1

    return 1


scenario = Scenario(
    configspace=cs,
    instances=instances,
    instance_features=features,
    n_trials=500,
)

hydra = Hydra(
    scenario,
    target_function,
    hydra_iterations=3,
    smac_runs_per_iter=1,
    incumbents_added_per_iter=1,
    stop_early=True,
)

portfolio = hydra.optimize()
print("====== Resulting portfolio ======")
print(portfolio)
print("=================================")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hydra-smac-0.1.11.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

hydra_smac-0.1.11-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file hydra-smac-0.1.11.tar.gz.

File metadata

  • Download URL: hydra-smac-0.1.11.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for hydra-smac-0.1.11.tar.gz
Algorithm Hash digest
SHA256 7e2b8d83496f666265bf97dd64d7c7447783d99af783e4c0fd5ea824c165b09b
MD5 e5bad86ecfa0dbb1aa0caf70433f6bdf
BLAKE2b-256 e364c33ab9cc9a7671b3d0288f33742810d96b7470654147a6b8f145f2c1dd44

See more details on using hashes here.

File details

Details for the file hydra_smac-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: hydra_smac-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for hydra_smac-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 8ba7653a8e0988ccf98256f46b8496a9c4c9a6ee86eca24718c84710a461964b
MD5 d42c0a93a2764420163ecffe855f862e
BLAKE2b-256 3df624a617f8fdedd3fa6b5e5c8748cac94a199cf6d24cab2988a6d6f814f587

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page