# we split the data in 2 sets data1, data2 = data1.splitInTwo() #data 1 -> training data #data 2 -> data to predict # parameters of the calibration lim = 150 # if ecal + hcal > lim, ecalib = math.nan n_neighbors_ecal_eq_0 = 2000 # number of neighbors for ecal = 0 n_neighbors_ecal_neq_0 = 250 # number of neighbors for ecal ≠ 0 energystep_ecal_eq_0 = 1 energystep_ecal_neq_0 = 5 try: # We import the calibration filename = "calibrations/KNNGaussianFitDirect_162Kpart_ecal_train_ecal_neq_0_min_0.292026728392_hcal_train_ecal_eq_0_min_1.00043606758_hcal_train_ecal_neq_0_min_1.00002634525_lim_150_n_neighbors_ecal_eq_0_2000_n_neighbors_ecal_neq_0_250.calibration" KNNGFD = importCalib(filename) except FileNotFoundError: # We create the calibration KNNGFD = data1.KNNGaussianFitDirect( n_neighbors_ecal_eq_0=n_neighbors_ecal_eq_0, n_neighbors_ecal_neq_0=n_neighbors_ecal_neq_0, lim=lim) KNNGFD.saveCalib() classname = KNNGFD.classname #plot 3D Training points fig = plt.figure(1, figsize=(5, 4)) usplt.plot3D_training(data1) #plt.show() savefig(fig, directory, classname + "_plot3D_training.png") plt.close()
# parameters of the calibration n_neighbors_ecal_eq_0 = 2000 n_neighbors_ecal_neq_0 = 250 weights = 'gaussian' algorithm = 'auto' sigma = 5 lim = 150 energystep = 1 kind = 'cubic' cut = 2 try: # We import the calibration filename = "calibrations/KNNGaussianCleaning_162Kpart_cut_2_lim_150_n_neighbors_ecal_eq_0_2000_n_neighbors_ecal_neq_0_250_sigma_5.calibration" KNNGC = importCalib(filename) except FileNotFoundError: # We create the calibration KNNGC = data1.KNNGaussianCleaning(n_neighbors_ecal_eq_0, n_neighbors_ecal_neq_0, weights, algorithm, sigma, lim, energystep, kind, cut) KNNGC.saveCalib() classname = KNNGC.classname #plot 3D Training points fig = plt.figure(1, figsize=(6, 4)) usplt.plot3D_training(data1) plt.show() savefig(fig, directory, classname + "_plot3D_training.png")
#importation of simulated particles filename = 'charged_hadrons_100k.energydata' data1 = importData(filename) filename = 'prod2_200_400k.energydata' data2 = importData(filename) # we merge the 2 sets of data data1 = data1.mergeWith(data2) # we split the data in 2 sets data1, data2 = data1.splitInTwo() #data 1 -> training data #data 2 -> data to predict # We import LR filename = "calibrations/LinearRegression_162Kpart_lim_150_lim_max_80_lim_min_20.calibration" LinearRegression = importCalib(filename) # We import KNNGFD filename = "calibrations/KNNGaussianFitDirect_162Kpart_ecal_train_ecal_neq_0_min_0.292026728392_hcal_train_ecal_eq_0_min_1.00043606758_hcal_train_ecal_neq_0_min_1.00002634525_lim_150_n_neighbors_ecal_eq_0_2000_n_neighbors_ecal_neq_0_250.calibration" KNNGFD = importCalib(filename) # We import KNNGF filename = "calibrations/KNNGaussianFit_162Kpart_hcal_train_ecal_eq_0_min_1.00043606758_lim_150_n_neighbors_ecal_eq_0_2000_n_neighbors_ecal_neq_0_250.calibration" KNNGF = importCalib(filename) # We import KNNGC filename = "calibrations/KNNGaussianCleaning_162Kpart_cut_2_lim_150_n_neighbors_ecal_eq_0_2000_n_neighbors_ecal_neq_0_250_sigma_5.calibration" KNNGC = importCalib(filename) # We import KNN filename = "calibrations/KNN_162Kpart_lim_150_n_neighbors_ecal_eq_0_2000_n_neighbors_ecal_neq_0_250_recalibrated_False_sigma_5.calibration"
# we split the data in 2 sets data1, data2 = data1.splitInTwo() #data 1 -> training data #data 2 -> data to predict # parameters of the calibration lim_min = 20 lim_max = 80 lim = 150 # file to save the pictures directory = "pictures/testLinearRegression/" try: # We import the calibration filename = "calibrations/LinearRegression_162Kpart_lim_150_lim_max_80_lim_min_20.calibration" LinearRegression = importCalib(filename) except FileNotFoundError: # We create the calibration LinearRegression = data1.LinearRegression(lim_min=20, lim_max=80, lim=150) # We save the calibration LinearRegression.saveCalib() classname = LinearRegression.classname #plot 3D Training points fig = plt.figure(1, figsize=(6, 4)) usplt.plot3D_training(data1) plt.show() savefig(fig, directory, classname + "_plot3D_training.png") plt.close() #plot 3D surface calibration
data1 = importData(filename) filename = 'prod2_200_400k.energydata' data2 = importData(filename) # we merge the 2 sets of data data1 = data1.mergeWith(data2) # we split the data in 2 sets data1, data2 = data1.splitInTwo() #data 1 -> training data #data 2 -> data to predict # parameters of the calibration nbLego = 60 try: filename = "calibrations/CalibrationLego_162Kpart_delta_2.66856677123_ecal_max_262.853826966_hcal_max_262.853826966_lim_150_nbLego_100.calibration" CalibrationLego = importCalib(filename) except FileNotFoundError: # We create the calibration CalibrationLego = data1.CalibrationLego(nbLego=nbLego) CalibrationLego.saveCalib() classname = CalibrationLego.classname #plot 3D Training points fig = plt.figure(1, figsize=(6, 4)) usplt.plot3D_training(data1) plt.show() savefig(fig, directory, classname + "_plot3D_training.png") plt.close() #plot 3D surface calibration fig = plt.figure(1, figsize=(6, 4))
Developed by Samuel Niang For IPNL (Nuclear Physics Institute of Lyon) Script to understand how does LinearRegression works. """ import matplotlib.pyplot as plt import pfcalibration.usualplots as usplt from pfcalibration.tools import savefig from pfcalibration.tools import importData, importCalib # file to save the pictures directory = "pictures/testLinearRegression/" try: filename = "calibrations/LinearRegression_162Kpart_lim_150_lim_max_80_lim_min_20.calibration" LR = importCalib(filename) except FileNotFoundError: #importation of simulated particles filename = 'charged_hadrons_100k.energydata' data1 = importData(filename) filename = 'prod2_200_400k.energydata' data2 = importData(filename) # we merge the 2 sets of data data1 = data1.mergeWith(data2) # we split the data in 2 sets data1, data2 = data1.splitInTwo() #data 1 -> training data #data 2 -> data to predict # parameters of the calibration lim_min = 20