# Path: spearmint_salad/pkl_trace.py
# def get_sys_info():
# def get_default_trace_path():
#     def __init__(self, trace_path=None, trace_level=10):
#     def write(self, trace_level, collection, info  ):
#     def __call__(self, info ):
#     def __init__(self):
#     def docs(self):
#     def insert(self, doc):
#     def find(self, query={}):
#     def __init__(self):
#     def get_collection_list(self):
#     def __getattr__(self, key):
#     def __getitem__(self, key ):
# def get_column_dict( collection, *column_names):
# def get_column_list( collection, *col_names):
#     def __init__(self, trace_path=None):
#     def update_trace(self):
# def get_latest_trace(dir='/tmp'):
# def get_recursif(struct, path ):
# def get_recursif_(struct, path ):
# def plot_stats(collection, axes, x_key, *y_key_list):
# class Trace:
# class Collection:
# class DB:
# class TraceDB(object):
# class TraceDBFile(TraceDB):
# 
# Path: spearmint_salad/base.py
# def argmin_with_ties( eLoss_kN ):
# def aB_prob(w_km, loss_mN):
# def rand_arg_min(val_n):
# def arg_min_prob( loss_mN ):
#     def apply_async(self, func, args=(), kwds={}, callback=None):
#     def close(self): pass
#     def __init__(self, value):
#     def get(self):
#     def __enter__(self):
#     def __exit__(self,*args):
#     def __init__(self, ds_partition):
#     def __call__(self, hp_id, hp_config ):
#     def get_y_dict(self):
#     def ds_name(self):
# def eval_learner(learner, ds_partition):
# def get_tmp_dir():
# def build_bootstrap_matrix(k_bootstrap, m, essr, rng=None):
# def bootstrap_weight(n, essr=1.0, rng=None):
#     def add_point(self, point):
#     def get_point(self, hp_id):
#     def size(self):
#     def _shuffle(self):
#     def __init__(self, grid_size=10000, shuffle=True):
#     def __str__(self):
#     def init_grid(self,n_dims):
#     def __init__(self, dim_size=10, shuffle=True ):
#     def init_grid(self,n_dims):
#     def next(self, grid, values, durations,
#             candidates, pending, complete):
# def BasicGridOptimizer(hp_space, dim_size=10):
#     def __init__(self, *args, **kwargs ):
#     def __call__(self):
# def GPEIOptimizer(hp_space, grid_size=10000, mcmc_iters=0, **kwargs):
# def RandomSobol(hp_space, grid_size=10000 ):
#     def __init__(self, hp_space, Chooser = None, grid = None ):
#     def __str__(self):
#     def _init(self):
#     def next(self, result_list, pending):
#     def get_chooser_state(self):
#     def _build_grid_info(self, result_list, pending ):
# class NotAPool:
# class ApplyResult:
# class Profiler:
# class Evaluator:
# class Grid(object):
# class SobolGrid(Grid):
# class EvenGrid(Grid):
# class RandomChooser(object):
# class GPEIChooseWrapper:
# class Optimizer:
# 
# Path: spearmint_salad/greedy.py
# def agnostic_bayes_prob( eLoss_kN ):
# def greedy_prob( eLoss_kN, ensemble_d ):
# def greedy_ensemble( loss_mN, w_km, ensemble_size=10 ):
#     N = eLoss_kN.shape[1]


import numpy as np
import os, fnmatch
from spearmint_salad import pkl_trace, base, greedy
from os import path
        tst_info, val_info = zip( * [ info_dict[ds_name] 
            for info_dict in info_dict_list if ds_name in info_dict ] )
        
        eval_info_dict[ds_name] = (
            merge_eval_info(tst_info), 
            merge_eval_info(val_info) 
            )   
    return eval_info_dict


class Method(object): 
    @property
    def name(self):
        return self.__class__.__name__
    
class AB_bootstrap(Method):
    
    def __init__(self,  k_bootstrap=100, essr=0.5 ):
        self.k_bootstrap = k_bootstrap
        self.essr = essr
    
    @property
    def name(self):
        return 'AB'

    def get_loss_info(self, tst_eval_info, val_eval_info ):

        loss_mN = val_eval_info.get_loss()
        w_km = base.build_bootstrap_matrix(self.k_bootstrap, loss_mN.shape[0], self.essr)
        

# Path: spearmint_salad/pkl_trace.py
# def get_sys_info():
# def get_default_trace_path():
#     def __init__(self, trace_path=None, trace_level=10):
#     def write(self, trace_level, collection, info  ):
#     def __call__(self, info ):
#     def __init__(self):
#     def docs(self):
#     def insert(self, doc):
#     def find(self, query={}):
#     def __init__(self):
#     def get_collection_list(self):
#     def __getattr__(self, key):
#     def __getitem__(self, key ):
# def get_column_dict( collection, *column_names):
# def get_column_list( collection, *col_names):
#     def __init__(self, trace_path=None):
#     def update_trace(self):
# def get_latest_trace(dir='/tmp'):
# def get_recursif(struct, path ):
# def get_recursif_(struct, path ):
# def plot_stats(collection, axes, x_key, *y_key_list):
# class Trace:
# class Collection:
# class DB:
# class TraceDB(object):
# class TraceDBFile(TraceDB):
# 
# Path: spearmint_salad/base.py
# def argmin_with_ties( eLoss_kN ):
# def aB_prob(w_km, loss_mN):
# def rand_arg_min(val_n):
# def arg_min_prob( loss_mN ):
#     def apply_async(self, func, args=(), kwds={}, callback=None):
#     def close(self): pass
#     def __init__(self, value):
#     def get(self):
#     def __enter__(self):
#     def __exit__(self,*args):
#     def __init__(self, ds_partition):
#     def __call__(self, hp_id, hp_config ):
#     def get_y_dict(self):
#     def ds_name(self):
# def eval_learner(learner, ds_partition):
# def get_tmp_dir():
# def build_bootstrap_matrix(k_bootstrap, m, essr, rng=None):
# def bootstrap_weight(n, essr=1.0, rng=None):
#     def add_point(self, point):
#     def get_point(self, hp_id):
#     def size(self):
#     def _shuffle(self):
#     def __init__(self, grid_size=10000, shuffle=True):
#     def __str__(self):
#     def init_grid(self,n_dims):
#     def __init__(self, dim_size=10, shuffle=True ):
#     def init_grid(self,n_dims):
#     def next(self, grid, values, durations,
#             candidates, pending, complete):
# def BasicGridOptimizer(hp_space, dim_size=10):
#     def __init__(self, *args, **kwargs ):
#     def __call__(self):
# def GPEIOptimizer(hp_space, grid_size=10000, mcmc_iters=0, **kwargs):
# def RandomSobol(hp_space, grid_size=10000 ):
#     def __init__(self, hp_space, Chooser = None, grid = None ):
#     def __str__(self):
#     def _init(self):
#     def next(self, result_list, pending):
#     def get_chooser_state(self):
#     def _build_grid_info(self, result_list, pending ):
# class NotAPool:
# class ApplyResult:
# class Profiler:
# class Evaluator:
# class Grid(object):
# class SobolGrid(Grid):
# class EvenGrid(Grid):
# class RandomChooser(object):
# class GPEIChooseWrapper:
# class Optimizer:
# 
# Path: spearmint_salad/greedy.py
# def agnostic_bayes_prob( eLoss_kN ):
# def greedy_prob( eLoss_kN, ensemble_d ):
# def greedy_ensemble( loss_mN, w_km, ensemble_size=10 ):
#     N = eLoss_kN.shape[1]


# Path: spearmint_salad/loss_info.py
import numpy as np
import os, fnmatch
from spearmint_salad import pkl_trace, base, greedy
from os import path

        tst_info, val_info = zip( * [ info_dict[ds_name] 
            for info_dict in info_dict_list if ds_name in info_dict ] )
        
        eval_info_dict[ds_name] = (
            merge_eval_info(tst_info), 
            merge_eval_info(val_info) 
            )   
    return eval_info_dict


class Method(object): 
    @property
    def name(self):
        return self.__class__.__name__
    
class AB_bootstrap(Method):
    
    def __init__(self,  k_bootstrap=100, essr=0.5 ):
        self.k_bootstrap = k_bootstrap
        self.essr = essr
    
    @property
    def name(self):
        return 'AB'

    def get_loss_info(self, tst_eval_info, val_eval_info ):

        loss_mN = val_eval_info.get_loss()
        w_km = base.build_bootstrap_matrix(self.k_bootstrap, loss_mN.shape[0], self.essr)
        

        prob_N = base.aB_prob(w_km, loss_mN)