A simple tool for automatic parameter tuning.
Project description
DI-toolkit
A simple tool for automatic parameter tuning.
Installation
You can simply install it with pip
command line from the official PyPI site.
pip install DI-toolkit
For more information about installation, you can refer to Installation.
Quick Start for HPO
Here is a simple example
import random
import sys
import time
from ditk.hpo import hpo, R, M, choice, uniform, randint
@hpo
def opt_func(v): # this function is still usable after decorating
x, y = v['x'], v['y']
time.sleep(0.1)
print("This [u]time's[/] config:", v) # stdout will be captured
print("This is print line in stderr", file=sys.stderr) # stderr will be captured
if random.random() < 0.5: # randomly raise exception
raise ValueError('Fxxk this shxt') # retry is supported
return {
'result': x * y,
'sum': x + y,
}
if __name__ == '__main__':
print(opt_func.random() # random algorithm
.max_steps(30) # max steps
.minimize(R['result']) # the maximize/minimize target you need to optimize,
.concern(M['time'], 'time_cost') # extra concerned values (from metrics)
.concern(R['sum'], 'sum') # extra concerned values (from return value of function)
.stop_when(R['result'] <= -800) # conditional stop is supported
.spaces( # search spaces
{
'x': uniform(-10, 110), # continuous space
'y': randint(-10, 20), # integer based space
'z': {
't': choice(['a', 'b', 'c', 'd', 'e']), # enumerate space
},
}
).run())
Contributing
We appreciate all contributions to improve DI-toolkit
, both logic and system designs. Please refer to CONTRIBUTING.md for more guides.
License
DI-toolkit
released under the Apache 2.0 license.
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
DI-toolkit-0.0.1.tar.gz
(22.0 kB
view hashes)
Built Distribution
DI_toolkit-0.0.1-py3-none-any.whl
(30.5 kB
view hashes)
Close
Hashes for DI_toolkit-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23bcfac0176b143c8f75c68a68dc1e2a113f32880dc8c3b8cceaefaa9f234a55 |
|
MD5 | e60bfaa5a86e22493a70ac77449dddfd |
|
BLAKE2b-256 | 363e958da3b1fbd5fcf843890b3ddf57d091bf780557d9ed03e003c5f4a3ca69 |