moe.views package

Submodules

moe.views.bandit_pretty_view module

A class to encapsulate Bandit ‘pretty’ views.

class moe.views.bandit_pretty_view.BanditPrettyView(request)[source]

Bases: moe.views.pretty_view.PrettyView

A class to encapsulate Bandit ‘pretty’ views.

See moe.views.pretty_view.PrettyView superclass for more details.

moe.views.constant module

Route names and endpoints for all MOE routes.

Regular GP REST routes:

  • ei - compute the Expected Improvement at a set of points
  • mean_var - compute the mean and variance of the gaussian process for a set of points

Next Points GP REST routes:

  • epi - compute the next points to sample using Expected Parallel Improvement
  • kriging - compute the next points to sample using Kriging Believer
  • constant_liar - compute the next points to sample using Constant Liar

New routes have the form:

GP_<NAME>_ROUTE_NAME = ‘gp_<name>’ GP_<NAME>_ENDPOINT = ‘/gp/<name>’ GP_<NAME>_MOE_ROUTE = MoeRoute(GP_<NAME>_ROUTE_NAME, GP_<NAME>_ENDPOINT) GP_<NAME>_PRETTY_ROUTE_NAME = ‘gp_<name>_pretty’ GP_<NAME>_PRETTY_ENDPOINT = ‘/gp/<name>/pretty’ GP_<NAME>_PRETTY_MOE_ROUTE = MoeRoute(GP_<NAME>_PRETTY_ROUTE_NAME, GP_<NAME>_PRETTY_ENDPOINT)

New next_points routes have the form:

GP_NEXT_POINTS_<NAME>_ROUTE_NAME = ‘gp_next_points_<name>’ GP_NEXT_POINTS_<NAME>_ENDPOINT = ‘/gp/next_points/<name>’ GP_NEXT_POINTS_<NAME>_MOE_ROUTE = MoeRoute(GP_NEXT_POINTS_<NAME>_ROUTE_NAME, GP_NEXT_POINTS_<NAME>_ENDPOINT) GP_NEXT_POINTS_<NAME>_PRETTY_ROUTE_NAME = ‘gp_next_points_<name>_pretty’ GP_NEXT_POINTS_<NAME>_PRETTY_ENDPOINT = ‘/gp/next_points/<name>/pretty’ GP_NEXT_POINTS_<NAME>_PRETTY_MOE_ROUTE = MoeRoute(GP_NEXT_POINTS_<NAME>_PRETTY_ROUTE_NAME, GP_NEXT_POINTS_<NAME>_PRETTY_ENDPOINT) GP_NEXT_POINTS_<NAME>_OPTIMIZER_METHOD_NAME = <method name from moe.optimal_learning.python.cpp_wrappers.expected_improvement>
moe.views.constant.ALL_REST_ROUTES_ROUTE_NAME_TO_ENDPOINT = {'gp_hyper_opt': '/gp/hyper_opt', 'gp_var_diag': '/gp/var/diag', 'gp_next_points_kriging': '/gp/next_points/kriging', 'bandit_ucb': '/bandit/ucb', 'bandit_epsilon': '/bandit/epsilon', 'gp_mean': '/gp/mean', 'gp_var': '/gp/var', 'gp_next_points_epi': '/gp/next_points/epi', 'bandit_bla': '/bandit/bla', 'gp_ei': '/gp/ei', 'gp_mean_var_diag': '/gp/mean_var/diag', 'gp_mean_var': '/gp/mean_var', 'gp_next_points_constant_liar': '/gp/next_points/constant_liar'}

dict mapping from MOE route names to MOE endpoint names

class moe.views.constant.MoeRestLogLine[source]

Bases: moe.views.constant.MoeLogLine

The information logged for all MOE REST requests/responses.

Variables:
  • endpoint – The endpoint that was called
  • type – Whether this is a 'request' or 'response'
  • content – The json of the request/response
class moe.views.constant.MoeRoute[source]

Bases: moe.views.constant.MoeRoute

Information for mapping a MOE route_name to its corresponding endpoint.

Variables:
  • route_name – The name of the route (ie 'gp_ei')
  • endpoint – The endpoint for the route (ie '/gp/ei')
moe.views.constant.NEXT_POINTS_OPTIMIZER_METHOD_NAMES = ['multistart_expected_improvement_optimization', 'kriging_believer_expected_improvement_optimization', 'constant_liar_expected_improvement_optimization']

Names of optimizer methods for finding the next points to sample (e.g., EPI, Kriging, etc.) These need to match method names in moe/optimal_learning/python/cpp_wrappers/expected_improvement.py

moe.views.exceptions module

Views for handling Python exceptions.

Includes special views that catch the following:
  1. colander.Invalid
moe.views.exceptions.failed_colander_validation(exception, request)[source]

Catch colander.Invalid and give an informative 500 response.

Parameters:
  • exception (colander.Invalid) – exception to be handled
  • request (pyramid.request.Request) – the pyramid request that lead to the exception being raised.
Returns:

the pyramid response to be rendered

Return type:

pyramid.response.Response

moe.views.exceptions.general_error(exception, request)[source]

Catch any Python Exception.

Parameters:
  • exception (Exception) – exception to be handled
  • request (pyramid.request.Request) – the pyramid request that lead to the exception being raised.
Returns:

the pyramid response to be rendered

Return type:

pyramid.response.Response

moe.views.exceptions.pyramid_error_view(exception, request)[source]

Register a pyramid view to handle exceptions; i.e., log them and generate a Response.

Parameters:
  • exception (Exception (Python base exception type) (i.e., type of context)) – exception to be handled
  • request (pyramid.request.Request) – the pyramid request that lead to the exception being raised.
Returns:

the pyramid response to be rendered

Return type:

pyramid.response.Response

moe.views.frontend module

Frontend views for the MOE app.

moe.views.frontend.gp_plot_page(request)[source]

The MOE demo view.

GET /demo
moe.views.frontend.index_page(request)[source]

The MOE index view.

GET /

moe.views.gp_hyperparameter_update module

Classes for gp_ei endpoints.

Includes:
  1. request and response schemas
  2. pretty and backend views
class moe.views.gp_hyperparameter_update.GpEiRequest(*arg, **kw)[source]

Bases: colander.Schema

A gp_ei request colander schema.

Required fields

gp_info:a moe.views.schemas.GpInfo object of historical data

Example Request

Content-Type: text/javascript

{
    'gp_info': {
        'signal_variance': 1.0,
        'length_scale': [0.2],
        'points_sampled': [
                {'value_var': 0.01, 'value': 0.1, 'point': [0.0]},
                {'value_var': 0.01, 'value': 0.2, 'point': [1.0]}
            ],
        'domain': [
            [0, 1],
            ]
        },
    },
}

moe.views.gp_next_points_pretty_view module

A class to encapsulate ‘pretty’ views for gp_next_points_* endpoints; e.g., moe.views.rest.gp_next_points_epi.GpNextPointsEpi.

Include:

  1. Class that extends moe.views.optimizable_gp_pretty_view.GpPrettyView for next_points optimizers
class moe.views.gp_next_points_pretty_view.GpNextPointsPrettyView(request)[source]

Bases: moe.views.optimizable_gp_pretty_view.OptimizableGpPrettyView

A class to encapsulate ‘pretty’ gp_next_points_* views; e.g., moe.views.rest.gp_next_points_epi.GpNextPointsEpi.

Extends moe.views.optimizable_gp_pretty_view.GpPrettyView with:

  1. gaussian_process generation from params
  2. Converting params into a C++ consumable set of optimizer parameters
  3. A method (compute_next_points_to_sample_response) for computing the next best points to sample from a gaussian_process
compute_next_points_to_sample_response(params, optimizer_method_name, route_name, *args, **kwargs)[source]

Compute the next points to sample (and their expected improvement) using optimizer_method_name from params in the request.

Warning

Attempting to find num_to_sample optimal points with num_sampled < num_to_sample historical points sampled can cause matrix issues under some conditions. Try requesting num_to_sample < num_sampled points for better performance. To bootstrap more points try sampling at random, or from a grid.

Parameters:
request_schema = <moe.views.schemas.gp_next_points_pretty_view.GpNextPointsRequest object at 4796430928 (named )>
response_schema = <moe.views.schemas.gp_next_points_pretty_view.GpNextPointsResponse object at 4796431056 (named )>

moe.views.gp_pretty_view module

A class to encapsulate GP ‘pretty’ views.

class moe.views.gp_pretty_view.GpPrettyView(request)[source]

Bases: moe.views.pretty_view.PrettyView

A class to encapsulate GP ‘pretty’ views.

See moe.views.pretty_view.PrettyView superclass for more details.

moe.views.optimizable_gp_pretty_view module

A superclass to encapsulate getting optimizer parameters for views.

class moe.views.optimizable_gp_pretty_view.OptimizableGpPrettyView(request)[source]

Bases: moe.views.gp_pretty_view.GpPrettyView

A superclass to encapsulate getting optimizer parameters for views.

get_params_from_request()[source]

Return the deserialized parameters from the json_body of a request.

We explicitly pull out the optimizer_type and use it to deserialize and validate the other parameters (num_multistarts, num_random_samples, optimizer_parameters).

This is necessary because we have different default optimizer parameters for different combinations of optimizer_type, endpoint, and other features. See moe.optimal_learning.python.constants.OPTIMIZER_TYPE_AND_OBJECTIVE_TO_DEFAULT_PARAMETERS

Returns:A deserialized self.request_schema object
Return type:dict

moe.views.pretty_view module

A class to encapsulate ‘pretty’ views.

class moe.views.pretty_view.PrettyView(request)[source]

Bases: moe.resources.Root

A class to encapsulate ‘pretty’ views.

These views have:
  1. A backend endpoint
  2. A pretty, browser interactable view with forms to test the backend endpoint
form_response(response_dict)[source]

Return the serialized response object from a dict.

Parameters:response_dict (dict) – a dict that can be serialized by self.response_schema
Returns:a serialized self.response_schema object
get_params_from_request()[source]

Return the deserialized parameters from the json_body of a request.

Returns:A deserialized self.request_schema object
pretty_response()[source]

A pretty, browser interactive view for the interface. Includes form request and response.

Returns:A dictionary with ‘endpoint’ and ‘default_text’ keys.
request_schema = None
response_schema = None

moe.views.utils module

Utilities for MOE views.

Module contents

Views for the MOE frontend and REST interface.

Contains: