{"id":13737630,"url":"https://github.com/arnowaczynski/spaceopt","last_synced_at":"2025-05-08T14:33:13.471Z","repository":{"id":45320645,"uuid":"235198994","full_name":"arnowaczynski/spaceopt","owner":"arnowaczynski","description":"Hyperparameter optimization via gradient boosting regression","archived":false,"fork":false,"pushed_at":"2022-07-10T10:26:17.000Z","size":34,"stargazers_count":41,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T13:07:44.131Z","etag":null,"topics":["automl","hyperparameter-optimization","machine-learning","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arnowaczynski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-20T21:04:53.000Z","updated_at":"2025-04-06T18:28:00.000Z","dependencies_parsed_at":"2022-07-19T03:02:07.227Z","dependency_job_id":null,"html_url":"https://github.com/arnowaczynski/spaceopt","commit_stats":null,"previous_names":["ar-nowaczynski/spaceopt"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnowaczynski%2Fspaceopt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnowaczynski%2Fspaceopt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnowaczynski%2Fspaceopt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnowaczynski%2Fspaceopt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arnowaczynski","download_url":"https://codeload.github.com/arnowaczynski/spaceopt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253085784,"owners_count":21851700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automl","hyperparameter-optimization","machine-learning","python"],"created_at":"2024-08-03T03:01:55.534Z","updated_at":"2025-05-08T14:33:11.447Z","avatar_url":"https://github.com/arnowaczynski.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# SpaceOpt: hyperparameter optimization via gradient boosting regression\n\n[![Python](https://img.shields.io/badge/Python-3.7%20%7C%203.8%20%7C%203.9-blue)](https://www.python.org/downloads/)\n[![PyPI version](https://img.shields.io/pypi/v/spaceopt?color=1)](https://pypi.org/project/spaceopt/)\n[![license](https://img.shields.io/pypi/l/spaceopt)](https://github.com/ar-nowaczynski/spaceopt)\n\nSpaceOpt is a hyperparameter optimization algorithm that uses gradient boosting regression to find the most promising candidates for the next trial by predicting their evaluation score.\n\n## Installation\n\n```bash\n$ pip install spaceopt\n```\n\n## Usage\n\n1. Define a discrete hyperparameter search space, for example:\n\n```python\nsearch_space = {\n    'a': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],  # list of ordered numbers: ints\n    'b': [-3.5, -0.1, 0.0, 2.5, 10.0],    # list of ordered numbers: floats\n    'c': [256, 512, 1024, 2048],          # another list of ordered numbers\n    'd': ['ABC', 'IJK', 'XYZ'],           # categorical variable\n    'e': [True, False],                   # boolean variable\n    # ... (add as many as you need)\n}\n```\n\n2. Define your evaluation function:\n\n```python\ndef evaluation_function(spoint: dict) -\u003e float:\n    # your code (e.g. model fit)\n    return y  # score (e.g. model accuracy)\n\nspoint = {'a': 4, 'b': 0.0, 'c': 512, 'd': 'XYZ', 'e': False}\ny = evaluation_function(spoint)\n```\n\n3. Use SpaceOpt for a hyperparameter optimization:\n\n```python\nfrom spaceopt import SpaceOpt\n\nspaceopt = SpaceOpt(search_space=search_space,\n                    target_name='y',\n                    objective='maximize')  # or 'minimize'\n\nfor iteration in range(200):\n    if iteration \u003c 20:\n        spoint = spaceopt.get_random()     # exploration\n    else:\n        spoint = spaceopt.fit_predict()    # exploitation\n\n    spoint['y'] = evaluation_function(spoint)\n    spaceopt.append_evaluated_spoint(spoint)\n```\n\nMore examples [here](https://github.com/ar-nowaczynski/spaceopt/tree/master/examples).\n\n## Advanced\n\n- get multiple points by setting `num_spoints`:\n```python\nspoints = spaceopt.get_random(num_spoints=2)\n# or\nspoints = spaceopt.fit_predict(num_spoints=5)\n```\n\n- control exploration vs. exploitation behaviour by adjusting `sample_size` (default=10000), which is the number of candidates sampled for ranking:\n```python\nspoint = spaceopt.fit_predict(sample_size=1000)  # decreasing `sample_size` increses exploration\nspoint = spaceopt.fit_predict(sample_size=100000)  # increasing `sample_size` increses exploitation\n```\n\n- add manually selected evaluation points to SpaceOpt:\n```python\nmy_spoint = {'a': 8, 'b': -3.5, 'c': 256, 'd': 'IJK', 'e': False}\nmy_spoint['y'] = evaluation_function(my_spoint)\nspaceopt.append_evaluated_spoint(my_spoint)\n```\n\n- learn more by reading the code, there are only 3 classes: [SpaceOpt](https://github.com/ar-nowaczynski/spaceopt/blob/master/spaceopt/optimizer.py), [Space](https://github.com/ar-nowaczynski/spaceopt/blob/master/spaceopt/space.py) and [Variable](https://github.com/ar-nowaczynski/spaceopt/blob/master/spaceopt/variable.py).\n\n## License\n\nMIT License (see [LICENSE](https://github.com/ar-nowaczynski/spaceopt/blob/master/LICENSE)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnowaczynski%2Fspaceopt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farnowaczynski%2Fspaceopt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnowaczynski%2Fspaceopt/lists"}