def run(filename): model = models.UnrollingHelices(use_outlier=False, dbscan_features = ["sina1", "cosa1", "z1", "x1", "x2", "x_y", "x_rt", "y_rt"], dbscan_weight = [1.0, 1.0, 0.75, 0.5, 0.5, 0.2, 0.2, 0.2]) path_to_input = os.path.join(path_to_trackml, "train_1") for event_id, hits, truth in load_dataset(path_to_input, parts=["hits", "truth"], skip=0, nevents=1): def Fun4BO(w_a1, w_z1 w_x1, w_x2, w_x_y, w_xy_rt, niter): model.dbscan_weight[0] = w_a1 model.dbscan_weight[1] = w_a1 model.dbscan_weight[2] = w_z1 model.dbscan_weight[3] = w_x1 model.dbscan_weight[4] = w_x2 model.dbscan_weight[5] = w_x_y model.dbscan_weight[6] = w_xy_rt model.dbscan_weight[7] = w_xy_rt model.iter_size_helix = int(niter) labels = model.predict(hits) one_submission = create_one_event_submission(event_id, hits, labels) score = score_event(truth, one_submission) return score print("Bayesian Optimization") opt = BayesianOptimization(Fun4BO, {"w1": (0.9, 1.2), "w2": (0.3, 0.8), "w3": (0.1, 0.6), "w4": (0.1, 0.6), "w5": (0.1, 0.6), "w6": (0.1, 0.6), "niter": (140, 190)}, #(140, 190) verbose = True) opt.maximize(init_points = 3, n_iter = 20, acq = "ucb", kappa = 2.576) # [string] labels = opt.res["max"]["max_params"].keys() # [dict(string, [float])] params = opt.res["all"]["params"] len_params = len(params) data_dic = {} for label in labels: val = [opt.res["max"]["max_params"][label]] for i in range(len_params): val.append(params[i][label]) data_dic[label] = val data_dic["value"] = [opt.res["max"]["max_val"]] + opt.res["all"]["values"] data_dic["label"] = ["max"] + [str(x) for x in range(len_params)] df = pd.DataFrame(data_dic) df.to_csv(filename, label=None)
import sys import models import train if __name__ == "__main__": model = models.UnrollingHelices(use_outlier=False, iter_size_helix=100) train.run(model, "train_1", sys.argv[0].split(".")[0], 1)
import os import sys import models import train if __name__ == "__main__": model = models.UnrollingHelices( use_outlier=False, iter_size_helix=100, dbscan_features=[ "sina1", "cosa1", "z1", "x1", "x2", "x_y", "x_rt", "y_rt" ], dbscan_weight=[1.0, 1.0, 0.75, 0.5, 0.5, 0.1, 0.1, 0.1]) train.run(model, "train_1", path_to_out=os.path.join("out", sys.argv[0].split(".")[0]), 1)
import os import sys import models import train if __name__ == "__main__": model = models.UnrollingHelices( use_outlier=False, iter_size_helix=100, dz0=-0.00070, stepdz=+0.00001, dbscan_features=["sina1", "cosa1", "z1", "x1", "x2"], dbscan_weight=[1.0, 1.0, 0.75, 0.5, 0.5]) train.run(model, "train_1", path_to_out=os.path.join("out", sys.argv[0].split(".")[0]), 1)