import scipy.sparse as sps from scripts.scikit_ensemble.scikit_ensamble import Optimizer from utils.definitions import * from utils.datareader import Datareader cat = 5 matrix = list() from utils.definitions import load_obj name = load_obj("name") directory = ROOT_DIR + "/scripts/scikit_ensemble/offline/" matrix_dict = load_obj("matrix_dict", path="") m = list() for n in name[cat-1]: m.append(sps.load_npz(directory + matrix_dict[n])) matrix.append(m) dr = Datareader(verbose=False, mode = "offline", only_load="False") opt = Optimizer(matrices_array=matrix[0], matrices_names=name[cat-1], dr=dr, cat=cat, start=0, end=1) del matrix opt.run()
import itertools def flatten(L): return list(set([val for sublist in L for val in sublist])) def reorder(dict, order): assert len(dict) == len(order) ret = [dict[k] for k in order] return ret if __name__ == '__main__': name = load_obj("name") mode = "online" type = "unique" print("[ Initizalizing Datereader ]") dr = Datareader(verbose=False, mode=mode, only_load="False") directory = ROOT_DIR + "/scripts/scikit_ensemble/" + mode + "/" w = [] print("[ Loading weights ]") for i in range(1, 11): arg = load_obj("best/cat" + str(i) + "") w.append(reorder(dict(arg[:len(arg) - 1][0]), name[i - 1])) print("[ Loading matrix name ]") if mode == "offline": matrix_dict = load_obj("matrix_dict", path="")
best_score = 0 best_params = [] verbose = True calls_constant = 60 start_index = (cat-1)*1000 end_index = cat*1000 global_counter=0 x0 = None y0 = None if os.path.isfile(ROOT_DIR + '/bayesian_scikit/' + configuration_name + '/memory/cat'+ str(cat)+'_y0_MEMORY.pkl') and \ os.path.isfile(ROOT_DIR + '/bayesian_scikit/' + configuration_name + '/memory/cat' + str(cat) + '_x0_MEMORY.pkl'): x0 = load_obj('cat' + str(cat) + '_x0_MEMORY', path= ROOT_DIR + '/bayesian_scikit/' + configuration_name + '/memory/') y0 = load_obj('cat' + str(cat) + '_y0_MEMORY', path= ROOT_DIR + '/bayesian_scikit/' + configuration_name + '/memory/') global_counter = len(y0) print("[ CAT"+str(cat)+" : RESUMING FROM RUN", global_counter, "]") print("[ CAT "+str(cat)+": STARTING, NOW LOADING MATRICES ]") matrices_names = read_params_dict(ROOT_DIR+'/bayesian_scikit/'+configuration_name+'/name_settings')[cat-1] file_locations = read_params_dict(ROOT_DIR+'/bayesian_scikit/bayesian_common_files/file_locations_offline') matrices_array = [norm( eurm_remove_seed( sps.load_npz(file_locations[x]), dr)[start_index:end_index]) for x in matrices_names ] del dr start_time=time.time() space = [Real(0, 100, name=x) for x in matrices_names] res = gp_minimize(objective_function, space,
import os, sys from utils.definitions import ROOT_DIR, load_obj configuration_name = sys.argv[1] print("cat 1 ",load_obj(ROOT_DIR + '/bayesian_scikit/' + configuration_name + '/best_params/cat'+str(1)+'_params_dict')) print("cat 2 ",load_obj(ROOT_DIR + '/bayesian_scikit/' + configuration_name + '/best_params/cat'+str(2)+'_params_dict')) print("cat 3 ",load_obj(ROOT_DIR + '/bayesian_scikit/' + configuration_name + '/best_params/cat'+str(3)+'_params_dict')) print("cat 4 ",load_obj(ROOT_DIR + '/bayesian_scikit/' + configuration_name + '/best_params/cat'+str(4)+'_params_dict')) print("cat 5 ",load_obj(ROOT_DIR + '/bayesian_scikit/' + configuration_name + '/best_params/cat'+str(5)+'_params_dict')) print("cat 6 ",load_obj(ROOT_DIR + '/bayesian_scikit/' + configuration_name + '/best_params/cat'+str(6)+'_params_dict')) print("cat 7 ",load_obj(ROOT_DIR + '/bayesian_scikit/' + configuration_name + '/best_params/cat'+str(7)+'_params_dict')) print("cat 8 ",load_obj(ROOT_DIR + '/bayesian_scikit/' + configuration_name + '/best_params/cat'+str(8)+'_params_dict')) print("cat 9 ",load_obj(ROOT_DIR + '/bayesian_scikit/' + configuration_name + '/best_params/cat'+str(9)+'_params_dict')) print("cat 10 ",load_obj(ROOT_DIR + '/bayesian_scikit/' + configuration_name + '/best_params/cat'+str(10)+'_params_dict'))