h2o-py/h2o/h2o.py
def get_grid(grid_id):
    """
    Return the specified grid.

    :param grid_id: The grid identification in h2o

    :returns: an :class:`H2OGridSearch` instance.
    """
    assert_is_type(grid_id, str)
    grid_json = api("GET /99/Grids/%s" % grid_id)
    models = [get_model(key["name"]) for key in grid_json["model_ids"]]
    # get first model returned in list of models from grid search to get model class (binomial, multinomial, etc)
    first_model_json = api("GET /3/Models/%s" % grid_json["model_ids"][0]["name"])["models"][0]
    gs = H2OGridSearch(None, {}, grid_id)
    gs._resolve_grid(grid_id, grid_json, first_model_json)
    gs.models = models
    hyper_params = {param: set() for param in gs.hyper_names}
    for param in gs.hyper_names:
        for model in models:
            if isinstance(model.full_parameters[param]["actual_value"], list):
                hyper_params[param].add(model.full_parameters[param]["actual_value"][0])
            else:
                hyper_params[param].add(model.full_parameters[param]["actual_value"])

    hyper_params = {str(param): list(vals) for param, vals in hyper_params.items()}
    gs.hyper_params = hyper_params
    gs.model = model.__class__()
    return gs
def get_grid(grid_id):
    assert_is_type(grid_id, str)
    grid_json = api("GET /99/Grids/%s" % grid_id)
    models = [get_model(key["name"]) for key in grid_json["model_ids"]]
    # get first model returned in list of models from grid search to get model class (binomial, multinomial, etc)
    first_model_json = api("GET /3/Models/%s" % grid_json["model_ids"][0]["name"])["models"][0]
    gs = H2OGridSearch(None, {}, grid_id)
    gs._resolve_grid(grid_id, grid_json, first_model_json)
    gs.models = models
    hyper_params = {param: set() for param in gs.hyper_names}
    for param in gs.hyper_names:
        for model in models:
            if isinstance(model.full_parameters[param]["actual_value"], list):
                hyper_params[param].add(model.full_parameters[param]["actual_value"][0])
            else:
                hyper_params[param].add(model.full_parameters[param]["actual_value"])

    hyper_params = {str(param): list(vals) for param, vals in hyper_params.items()}
    gs.hyper_params = hyper_params
    gs.model = model.__class__()
    return gs
def get_grid ( grid_id ) : assert_is_type ( grid_id , str ) grid_json = api ( "GET /99/Grids/%s" % grid_id ) models = [ get_model ( key [ "name" ] ) for key in grid_json [ "model_ids" ] ] # get first model returned in list of models from grid search to get model class (binomial, multinomial, etc) first_model_json = api ( "GET /3/Models/%s" % grid_json [ "model_ids" ] [ 0 ] [ "name" ] ) [ "models" ] [ 0 ] gs = H2OGridSearch ( None , { } , grid_id ) gs . _resolve_grid ( grid_id , grid_json , first_model_json ) gs . models = models hyper_params = { param : set ( ) for param in gs . hyper_names } for param in gs . hyper_names : for model in models : if isinstance ( model . full_parameters [ param ] [ "actual_value" ] , list ) : hyper_params [ param ] . add ( model . full_parameters [ param ] [ "actual_value" ] [ 0 ] ) else : hyper_params [ param ] . add ( model . full_parameters [ param ] [ "actual_value" ] ) hyper_params = { str ( param ) : list ( vals ) for param , vals in hyper_params . items ( ) } gs . hyper_params = hyper_params gs . model = model . __class__ ( ) return gs
Return the specified grid.

    :param grid_id: The grid identification in h2o

    :returns: an :class:`H2OGridSearch` instance.
Return the specified grid .