diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | python-bohb-hpo.spec | 261 | ||||
| -rw-r--r-- | sources | 1 |
3 files changed, 263 insertions, 0 deletions
@@ -0,0 +1 @@ +/BOHB_HPO-0.5.2.tar.gz diff --git a/python-bohb-hpo.spec b/python-bohb-hpo.spec new file mode 100644 index 0000000..ffba1da --- /dev/null +++ b/python-bohb-hpo.spec @@ -0,0 +1,261 @@ +%global _empty_manifest_terminate_build 0 +Name: python-BOHB-HPO +Version: 0.5.2 +Release: 1 +Summary: Bayesian Optimization Hyperband Hyperparameter Optimization +License: MIT +URL: https://github.com/goktug97/bohb_hpo +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/76/11/1c093976ff45711e0f9060fb6ea0d02629522715f7d17463b397a6ae62c5/BOHB_HPO-0.5.2.tar.gz +BuildArch: noarch + + +%description +Implementation for [BOHB](http://proceedings.mlr.press/v80/falkner18a.html) +## Requirements + - numpy + - scipy + - statsmodels + - dask + - torch (example) +## Installation +```bash +pip3 install bohb-hpo +``` +## Usage +``` Python +from bohb import BOHB +import bohb.configspace as cs +def objective(step, alpha, beta): + return 1 / (alpha * step + 0.1) + beta +def evaluate(params, n_iterations): + loss = 0.0 + for i in range(int(n_iterations)): + loss += objective(**params, step=i) + return loss/n_iterations +if __name__ == '__main__': + alpha = cs.CategoricalHyperparameter('alpha', [0.001, 0.01, 0.1]) + beta = cs.CategoricalHyperparameter('beta', [1, 2, 3]) + configspace = cs.ConfigurationSpace([alpha, beta]) + opt = BOHB(configspace, evaluate, max_budget=10, min_budget=1) + # Parallel + # opt = BOHB(configspace, evaluate, max_budget=10, min_budget=1, n_proc=4) + logs = opt.optimize() +``` +See [examples](https://github.com/goktug97/bohb-hpo/tree/master/examples) +### Configspace Examples +- Basic +```python +import dehb.configspace as cs +lr = cs.UniformHyperparameter('lr', 1e-4, 1e-1, log=True) +batch_size = cs.CategoricalHyperparameter('batch_size', [8, 16, 32]) +configspace = cs.ConfigurationSpace([lr, batch_size], seed=123) +``` +- Conditional Parameters +```python +import bohb.configspace as cs +a = cs.IntegerUniformHyperparameter('a', 0, 4) +b = cs.CategoricalHyperparameter('b', ['a', 'b', 'c'], a == 0) +b_default = cs.CategoricalHyperparameter('b', ['d'], ~b.cond) +configspace = cs.ConfigurationSpace([a, b, b_default], seed=123) +``` +- Complex Conditional Parameters +```python +import bohb.configspace as cs +a = cs.IntegerUniformHyperparameter('a', 0, 4) +b1 = cs.UniformHyperparameter('b', 0, 0.5, a <= 1) +b2 = cs.UniformHyperparameter('b', 0.5, 1, ~b1.cond) +c1 = cs.CategoricalHyperparameter('c', ['a', 'b', 'c'], b1 < 0.25) +c2 = cs.CategoricalHyperparameter('c', ['c', 'd', 'e'], ~c1.cond) +d1 = cs.UniformHyperparameter('d', 0, 1, (b1 < 0.125) & (c1 == 'b')) +d2 = cs.NormalHyperparameter('d', 0, 0.1, (b1 > 0.125) & (c1 == 'c')) +d3 = cs.IntegerNormalHyperparameter('d', 5, 10, (b2 > 0.750) & (c2 == 'd')) +d4 = cs.UniformHyperparameter('d', 0, 0, ~(d1.cond | d2.cond | d3.cond)) +configspace = cs.ConfigurationSpace([a, b1, b2, c1, c2, d1, d2, d3, d4], seed=123) +``` +## License +bohb-hpo is licensed under the MIT License. + +%package -n python3-BOHB-HPO +Summary: Bayesian Optimization Hyperband Hyperparameter Optimization +Provides: python-BOHB-HPO +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-BOHB-HPO +Implementation for [BOHB](http://proceedings.mlr.press/v80/falkner18a.html) +## Requirements + - numpy + - scipy + - statsmodels + - dask + - torch (example) +## Installation +```bash +pip3 install bohb-hpo +``` +## Usage +``` Python +from bohb import BOHB +import bohb.configspace as cs +def objective(step, alpha, beta): + return 1 / (alpha * step + 0.1) + beta +def evaluate(params, n_iterations): + loss = 0.0 + for i in range(int(n_iterations)): + loss += objective(**params, step=i) + return loss/n_iterations +if __name__ == '__main__': + alpha = cs.CategoricalHyperparameter('alpha', [0.001, 0.01, 0.1]) + beta = cs.CategoricalHyperparameter('beta', [1, 2, 3]) + configspace = cs.ConfigurationSpace([alpha, beta]) + opt = BOHB(configspace, evaluate, max_budget=10, min_budget=1) + # Parallel + # opt = BOHB(configspace, evaluate, max_budget=10, min_budget=1, n_proc=4) + logs = opt.optimize() +``` +See [examples](https://github.com/goktug97/bohb-hpo/tree/master/examples) +### Configspace Examples +- Basic +```python +import dehb.configspace as cs +lr = cs.UniformHyperparameter('lr', 1e-4, 1e-1, log=True) +batch_size = cs.CategoricalHyperparameter('batch_size', [8, 16, 32]) +configspace = cs.ConfigurationSpace([lr, batch_size], seed=123) +``` +- Conditional Parameters +```python +import bohb.configspace as cs +a = cs.IntegerUniformHyperparameter('a', 0, 4) +b = cs.CategoricalHyperparameter('b', ['a', 'b', 'c'], a == 0) +b_default = cs.CategoricalHyperparameter('b', ['d'], ~b.cond) +configspace = cs.ConfigurationSpace([a, b, b_default], seed=123) +``` +- Complex Conditional Parameters +```python +import bohb.configspace as cs +a = cs.IntegerUniformHyperparameter('a', 0, 4) +b1 = cs.UniformHyperparameter('b', 0, 0.5, a <= 1) +b2 = cs.UniformHyperparameter('b', 0.5, 1, ~b1.cond) +c1 = cs.CategoricalHyperparameter('c', ['a', 'b', 'c'], b1 < 0.25) +c2 = cs.CategoricalHyperparameter('c', ['c', 'd', 'e'], ~c1.cond) +d1 = cs.UniformHyperparameter('d', 0, 1, (b1 < 0.125) & (c1 == 'b')) +d2 = cs.NormalHyperparameter('d', 0, 0.1, (b1 > 0.125) & (c1 == 'c')) +d3 = cs.IntegerNormalHyperparameter('d', 5, 10, (b2 > 0.750) & (c2 == 'd')) +d4 = cs.UniformHyperparameter('d', 0, 0, ~(d1.cond | d2.cond | d3.cond)) +configspace = cs.ConfigurationSpace([a, b1, b2, c1, c2, d1, d2, d3, d4], seed=123) +``` +## License +bohb-hpo is licensed under the MIT License. + +%package help +Summary: Development documents and examples for BOHB-HPO +Provides: python3-BOHB-HPO-doc +%description help +Implementation for [BOHB](http://proceedings.mlr.press/v80/falkner18a.html) +## Requirements + - numpy + - scipy + - statsmodels + - dask + - torch (example) +## Installation +```bash +pip3 install bohb-hpo +``` +## Usage +``` Python +from bohb import BOHB +import bohb.configspace as cs +def objective(step, alpha, beta): + return 1 / (alpha * step + 0.1) + beta +def evaluate(params, n_iterations): + loss = 0.0 + for i in range(int(n_iterations)): + loss += objective(**params, step=i) + return loss/n_iterations +if __name__ == '__main__': + alpha = cs.CategoricalHyperparameter('alpha', [0.001, 0.01, 0.1]) + beta = cs.CategoricalHyperparameter('beta', [1, 2, 3]) + configspace = cs.ConfigurationSpace([alpha, beta]) + opt = BOHB(configspace, evaluate, max_budget=10, min_budget=1) + # Parallel + # opt = BOHB(configspace, evaluate, max_budget=10, min_budget=1, n_proc=4) + logs = opt.optimize() +``` +See [examples](https://github.com/goktug97/bohb-hpo/tree/master/examples) +### Configspace Examples +- Basic +```python +import dehb.configspace as cs +lr = cs.UniformHyperparameter('lr', 1e-4, 1e-1, log=True) +batch_size = cs.CategoricalHyperparameter('batch_size', [8, 16, 32]) +configspace = cs.ConfigurationSpace([lr, batch_size], seed=123) +``` +- Conditional Parameters +```python +import bohb.configspace as cs +a = cs.IntegerUniformHyperparameter('a', 0, 4) +b = cs.CategoricalHyperparameter('b', ['a', 'b', 'c'], a == 0) +b_default = cs.CategoricalHyperparameter('b', ['d'], ~b.cond) +configspace = cs.ConfigurationSpace([a, b, b_default], seed=123) +``` +- Complex Conditional Parameters +```python +import bohb.configspace as cs +a = cs.IntegerUniformHyperparameter('a', 0, 4) +b1 = cs.UniformHyperparameter('b', 0, 0.5, a <= 1) +b2 = cs.UniformHyperparameter('b', 0.5, 1, ~b1.cond) +c1 = cs.CategoricalHyperparameter('c', ['a', 'b', 'c'], b1 < 0.25) +c2 = cs.CategoricalHyperparameter('c', ['c', 'd', 'e'], ~c1.cond) +d1 = cs.UniformHyperparameter('d', 0, 1, (b1 < 0.125) & (c1 == 'b')) +d2 = cs.NormalHyperparameter('d', 0, 0.1, (b1 > 0.125) & (c1 == 'c')) +d3 = cs.IntegerNormalHyperparameter('d', 5, 10, (b2 > 0.750) & (c2 == 'd')) +d4 = cs.UniformHyperparameter('d', 0, 0, ~(d1.cond | d2.cond | d3.cond)) +configspace = cs.ConfigurationSpace([a, b1, b2, c1, c2, d1, d2, d3, d4], seed=123) +``` +## License +bohb-hpo is licensed under the MIT License. + +%prep +%autosetup -n BOHB-HPO-0.5.2 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-BOHB-HPO -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Mon May 29 2023 Python_Bot <Python_Bot@openeuler.org> - 0.5.2-1 +- Package Spec generated @@ -0,0 +1 @@ +90aba4aa4197549d47b875fecef5d63e BOHB_HPO-0.5.2.tar.gz |
