https://api.sigopt.com/v1/experiments/EXPERIMENT_ID/observations
Creates a new Observation . Every observation reports on a set of parameters which can come from a Suggestion or manually specified Assignments .
Request Method: POST
Parameters
Name
Type
Required?
Description
Manually specify values that the parameters held during this trial. You must specify exactly one value for each parameter in the experiment. Prefer using suggestion
.
A boolean indicating whether this observation failed for some reason. SigOpt takes this into consideration when optimizing. It is invalid for both failed
to be true
, and any of value
, value_stddev
, or values
to be present. The default value is false
.
Optional user-provided object. See Using Metadata for more information.
The id
of the Suggestion you are reporting on. Preferred over assignments
.
An array of Metric Evaluation objects. For experiments with more than one Metric , you must use this instead of value
and value_stddev
.
Deprecated Parameters
These parameters should no longer be used because there are better alternatives.
Name
Type
Required?
Description
The observed metric value from this trial.
The standard deviation in value
that was observed in this trial.
Response
Observation object.
Examples
Create an Observation
Python Bash Java
Copy observation = conn . experiments (EXPERIMENT_ID). observations (). create (
suggestion = "1" ,
values = [
dict (
name = "accuracy" ,
value = 0.95
),
dict (
name = "loss" ,
value = 123.45
)
]
)
Copy accuracy = 0.95
loss = 123.45
OBSERVATION = ` curl -s -X POST https://api.sigopt.com/v1/experiments/EXPERIMENT_ID/observations -u "$SIGOPT_API_TOKEN" : \
-H 'Content-Type: application/json' \
-d "{\"suggestion\":\"1\",\"values\":[{\"name\":\"accuracy\",\"value\":$accuracy},{\"name\":\"loss\",\"value\":$loss}]}"`
Copy Observation observation = new Experiment(EXPERIMENT_ID) . observations () . create ()
. data (
new Observation . Builder ()
. suggestion ( "1" )
. values ( java . util . Arrays . asList (
new Value . Builder ()
. name ( "accuracy" )
. value ( 0.95 )
. build () ,
new Value . Builder ()
. name ( "loss" )
. value ( 123.45 )
. build ()
))
. build ()
)
. call ();
Response
Copy {
"assignments" : {
"degree" : 2 ,
"gamma" : 3.6 ,
"kernel" : "rbf"
} ,
"created" : 1414800000 ,
"experiment" : "1" ,
"failed" : false ,
"id" : "1" ,
"metadata" : null ,
"object" : "observation" ,
"suggestion" : "1" ,
"value" : 1 ,
"value_stddev" : null ,
"values" : [
{
"name" : "Accuracy" ,
"object" : "metric_evaluation" ,
"value" : 1 ,
"value_stddev" : null
}
]
}
Create an Observation with custom Assignments
Python Bash Java
Copy observation = conn . experiments (EXPERIMENT_ID). observations (). create (
assignments = dict (
degree = 2 ,
gamma = 3.6 ,
kernel = "rbf"
),
values = [
dict (
name = "Accuracy" ,
value = 1
)
]
)
Copy OBSERVATION = ` curl -s -X POST https://api.sigopt.com/v1/experiments/EXPERIMENT_ID/observations -u "$SIGOPT_API_TOKEN" : \
-H 'Content-Type: application/json' \
-d "{\"assignments\":{\"degree\":2,\"gamma"\: 3.6, \" kernel \" : \" rbf \" }, \" values \" :[{ \" name \" : \" Accuracy \" , \" value \" :1}]} "`
Copy Observation observation = new Experiment(EXPERIMENT_ID) . observations () . create ()
. data (
new Observation . Builder ()
. assignments ( new Assignments . Builder ()
. set ( "degree" , 2 )
. set ( "gamma" , 3.6 )
. set ( "kernel" , "rbf" )
. build ())
. values ( java . util . Arrays . asList (
new MetricEvaluation . Builder ()
. name ( "Accuracy" )
. value ( 1 )
. build ()
))
. build ()
)
. call ();
Response
Copy {
"assignments" : {
"degree" : 2 ,
"gamma" : 3.6 ,
"kernel" : "rbf"
} ,
"created" : 1414800000 ,
"experiment" : "1" ,
"failed" : false ,
"id" : "1" ,
"metadata" : null ,
"object" : "observation" ,
"suggestion" : "1" ,
"value" : 1 ,
"value_stddev" : null ,
"values" : [
{
"name" : "Accuracy" ,
"object" : "metric_evaluation" ,
"value" : 1 ,
"value_stddev" : null
}
]
}
Create a Failed Observation
Python Bash Java
Copy observation = conn . experiments (EXPERIMENT_ID). observations (). create (
failed = True ,
suggestion = "2"
)
Copy OBSERVATION = ` curl -s -X POST https://api.sigopt.com/v1/experiments/EXPERIMENT_ID/observations -u "$SIGOPT_API_TOKEN" : \
-H 'Content-Type: application/json' \
-d "{\"suggestion\":\"2\",\"failed\":true}"`
Copy Observation observation = new Experiment(EXPERIMENT_ID) . observations () . create ()
. data (
new Observation . Builder ()
. failed ( true )
. suggestion ( "2" )
. build ()
)
. call ();
Response
Copy {
"assignments" : {
"degree" : 2 ,
"gamma" : 3.6 ,
"kernel" : "rbf"
} ,
"created" : 1414800000 ,
"experiment" : "1" ,
"failed" : true ,
"id" : "3" ,
"metadata" : null ,
"object" : "observation" ,
"suggestion" : "2" ,
"value" : null ,
"value_stddev" : null ,
"values" : []
}
Create an Observation with Metadata
Python Bash Java
Copy observation = conn . experiments (EXPERIMENT_ID). observations (). create (
metadata = dict (
estimated_training_time_s = 302
),
suggestion = "1" ,
values = [
dict (
name = "Accuracy" ,
value = 1 ,
value_stddev = 0.1
)
]
)
Copy OBSERVATION = ` curl -s -X POST https://api.sigopt.com/v1/experiments/EXPERIMENT_ID/observations -u "$SIGOPT_API_TOKEN" : \
-H 'Content-Type: application/json' \
-d "{\"suggestion\":\"1\",\"values\":[{\"name\":\"Accuracy\",\"value\":1,\"value_stddev\":0.1}],\"metadata\":{\"estimated_training_time_s\":302}}"`
Copy Observation observation = new Experiment(EXPERIMENT_ID) . observations () . create ()
. data (
new Observation . Builder ()
. metadata ( new Metadata . Builder ()
. set ( "estimated_training_time_s" , 302 )
. build ())
. suggestion ( "1" )
. values ( java . util . Arrays . asList (
new MetricEvaluation . Builder ()
. name ( "Accuracy" )
. value ( 1 )
. valueStddev ( 0.1 )
. build ()
))
. build ()
)
. call ();
Response
Copy {
"assignments" : {
"degree" : 2 ,
"gamma" : 3.6 ,
"kernel" : "rbf"
} ,
"created" : 1414800000 ,
"experiment" : "1" ,
"failed" : false ,
"id" : "2" ,
"metadata" : {
"estimated_training_time_s" : 302
} ,
"object" : "observation" ,
"suggestion" : "1" ,
"value" : 1 ,
"value_stddev" : 0.1 ,
"values" : [
{
"name" : "Accuracy" ,
"object" : "metric_evaluation" ,
"value" : 1 ,
"value_stddev" : 0.1
}
]
}