You can use our Python API Client to call API endpoints.
Our Python API Client is available via pip, with source code on Github:
pip install sigopt
Sign up for an account at
In order to use the API, you’ll need your
SIGOPT_API_TOKEN from your
Then, use your client token to instantiate a SigOpt
# Pass your API token directly, overriding any environment variables from sigopt import Connection conn = Connection(client_token=SIGOPT_API_TOKEN)
If you are connecting to SigOpt behind a proxy, you may need to set environment variables. Here are some example values:
os.environ['HTTP_PROXY'] = 'http://10.10.1.10:3128' os.environ['HTTPS_PROXY'] = 'http://user:[email protected]:1080'
documentation for the
for more information.
Run Some Code
Now, you can run SigOpt's Optimization Loop.
First, setup the experiment:
# Run `pip install sigopt` to download the python API client from sigopt import Connection from sigopt.examples import franke_function conn = Connection(client_token=SIGOPT_API_TOKEN) experiment = conn.experiments().create( name='Franke Optimization (Python)', parameters=[ dict(name='x', type='double', bounds=dict(min=0.0, max=1.0)), dict(name='y', type='double', bounds=dict(min=0.0, max=1.0)), ], ) print("Created experiment: https://sigopt.com/experiment/" + experiment.id)
Then, run the optimization loop itself:
# Evaluate your model with the suggested parameter assignments # Franke function - http://www.sfu.ca/~ssurjano/franke2d.html def evaluate_model(assignments): return franke_function(assignments['x'], assignments['y']) # Run the Optimization Loop between 10x - 20x the number of parameters for _ in range(30): suggestion = conn.experiments(experiment.id).suggestions().create() value = evaluate_model(suggestion.assignments) conn.experiments(experiment.id).observations().create( suggestion=suggestion.id, value=value, )
Run More Code: Tune a Random Forest
Learn how to Tune a Random Forest using SigOpt's Python API Client. We even have an easy-to-follow notebook format! This simple example uses an open source machine learning library and can be extended to tune the hyperparameters of any machine learning model.
To see more examples of how to use Sigopt and Python to tune machine learning models and more, clone our Github examples repository:
git clone https://github.com/sigopt/sigopt-examples.git
The SigOpt Python API Client returns Python objects. Here is an example where we fetch an experiment and print the name:
experiment = conn.experiments(experiment_id).fetch() print experiment.name
You can also refer to our complete API Object Reference.
Please refer to our complete API Endpoint Reference. Each page has a tab where you can view how to construct the endpoint call in Python. You can refer to the above section on objects for more information about the return type of the Python API Client calls.