-
Notifications
You must be signed in to change notification settings - Fork 139
/
experiment.py
44 lines (32 loc) · 1.73 KB
/
experiment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding: utf-8 -*-
"""Classes for MOE optimizable experiments."""
import pprint
from moe.optimal_learning.python.data_containers import HistoricalData
from moe.optimal_learning.python.geometry_utils import ClosedInterval
from moe.optimal_learning.python.python_version.domain import TensorProductDomain
class Experiment(object):
"""A class for MOE optimizable experiments."""
def __init__(self, domain_bounds, points_sampled=None):
"""Construct a MOE optimizable experiment.
**Required arguments:**
:param domain_bounds: The bounds for the optimization experiment
:type domain_bounds: An iterable of iterables describing the [min, max] of the domain for each dimension
**Optional arguments:**
:param points_sampled: The historic points sampled and their objective function values
:type points_sampled: An iterable of iterables describing the [point, value, noise] of each objective function evaluation
"""
_domain_bounds = [ClosedInterval(bound[0], bound[1]) for bound in domain_bounds]
self.domain = TensorProductDomain(_domain_bounds)
self.historical_data = HistoricalData(
self.domain.dim,
sample_points=points_sampled,
)
def build_json_payload(self):
"""Construct a json serializeable and MOE REST recognizeable dictionary of the experiment."""
return {
'domain_info': self.domain.get_json_serializable_info(),
'gp_historical_info': self.historical_data.json_payload(),
}
def __str__(self):
"""Return a pprint formated version of the experiment dict."""
return pprint.pformat(self.build_json_payload)