Name | hydra-smac JSON |
Version |
0.1.11
JSON |
| download |
home_page | |
Summary | Hydra + SMAC |
upload_time | 2023-03-23 11:20:27 |
maintainer | |
docs_url | None |
author | Corné Spek |
requires_python | >=3.10 |
license | BSD 3-Clause License Copyright (c) 2023, kw-corne Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
keywords |
hydra
smac
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Hydra-SMAC 0.1.11
A minimal Python re-implementation of [Hydra](https://www.cs.ubc.ca/labs/algorithms/Projects/Hydra/).
## Getting started
```bash
pip install hydra-smac
```
## Example
For more information on how to use Scenario objects, please refer to the [SMAC](https://github.com/automl/SMAC3) documentation.
```py
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("=================================")
```
Raw data
{
"_id": null,
"home_page": "",
"name": "hydra-smac",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "Hydra,SMAC",
"author": "Corn\u00e9 Spek",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/e3/64/c33ab9cc9a7671b3d0288f33742810d96b7470654147a6b8f145f2c1dd44/hydra-smac-0.1.11.tar.gz",
"platform": null,
"description": "# Hydra-SMAC 0.1.11\n\nA minimal Python re-implementation of [Hydra](https://www.cs.ubc.ca/labs/algorithms/Projects/Hydra/).\n\n## Getting started\n\n```bash\npip install hydra-smac\n```\n\n## Example\n\nFor more information on how to use Scenario objects, please refer to the [SMAC](https://github.com/automl/SMAC3) documentation.\n\n```py\nfrom ConfigSpace import Configuration, ConfigurationSpace, Float\nfrom hydrasmac import Hydra\nfrom smac import Scenario\n\ninstances = [\"a\", \"b\", \"c\"]\nfeatures = {\"a\": [0.0], \"b\": [1.0], \"c\": [2.0]}\n\ncs = ConfigurationSpace()\ncs.add_hyperparameters(\n [\n Float(\"x\", (1.0, 5.0)),\n Float(\"y\", (1.0, 5.0)),\n Float(\"z\", (1.0, 5.0)),\n ]\n)\n\n\ndef target_function(config: Configuration, instance: str, seed: int = 0) -> float:\n config_dict = config.get_dictionary()\n x, y, z = config_dict[\"x\"], config_dict[\"y\"], config_dict[\"z\"]\n\n if instance == \"a\" and x < 2.5 and y > 2.5 and z > 2.5:\n return 0.001\n\n if instance == \"b\" and y < 2.5 and x > 2.5 and z > 2.5:\n return 0.01\n\n if instance == \"c\" and z < 2.5 and y > 2.5 and x > 2.5:\n return 0.1\n\n return 1\n\n\nscenario = Scenario(\n configspace=cs,\n instances=instances,\n instance_features=features,\n n_trials=500,\n)\n\nhydra = Hydra(\n scenario,\n target_function,\n hydra_iterations=3,\n smac_runs_per_iter=1,\n incumbents_added_per_iter=1,\n stop_early=True,\n)\n\nportfolio = hydra.optimize()\nprint(\"====== Resulting portfolio ======\")\nprint(portfolio)\nprint(\"=================================\")\n```\n",
"bugtrack_url": null,
"license": "BSD 3-Clause License Copyright (c) 2023, kw-corne Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ",
"summary": "Hydra + SMAC",
"version": "0.1.11",
"split_keywords": [
"hydra",
"smac"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3df624a617f8fdedd3fa6b5e5c8748cac94a199cf6d24cab2988a6d6f814f587",
"md5": "d42c0a93a2764420163ecffe855f862e",
"sha256": "8ba7653a8e0988ccf98256f46b8496a9c4c9a6ee86eca24718c84710a461964b"
},
"downloads": -1,
"filename": "hydra_smac-0.1.11-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d42c0a93a2764420163ecffe855f862e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 9442,
"upload_time": "2023-03-23T11:20:25",
"upload_time_iso_8601": "2023-03-23T11:20:25.339461Z",
"url": "https://files.pythonhosted.org/packages/3d/f6/24a617f8fdedd3fa6b5e5c8748cac94a199cf6d24cab2988a6d6f814f587/hydra_smac-0.1.11-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e364c33ab9cc9a7671b3d0288f33742810d96b7470654147a6b8f145f2c1dd44",
"md5": "e5bad86ecfa0dbb1aa0caf70433f6bdf",
"sha256": "7e2b8d83496f666265bf97dd64d7c7447783d99af783e4c0fd5ea824c165b09b"
},
"downloads": -1,
"filename": "hydra-smac-0.1.11.tar.gz",
"has_sig": false,
"md5_digest": "e5bad86ecfa0dbb1aa0caf70433f6bdf",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 8890,
"upload_time": "2023-03-23T11:20:27",
"upload_time_iso_8601": "2023-03-23T11:20:27.229569Z",
"url": "https://files.pythonhosted.org/packages/e3/64/c33ab9cc9a7671b3d0288f33742810d96b7470654147a6b8f145f2c1dd44/hydra-smac-0.1.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-23 11:20:27",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "hydra-smac"
}