Skip to content

Commit

Permalink
update MVA models
Browse files Browse the repository at this point in the history
  • Loading branch information
mieskolainen committed Feb 6, 2024
1 parent 3fd5895 commit de6882d
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 42 deletions.
34 changes: 17 additions & 17 deletions configs/dqcd/models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ xgb01:

# general parameters
model_param:
num_boost_round: 100 # number of epochs (equal to the number of trees!)
booster: 'gbtree' # 'gbtree' (default), 'dart' (dropout boosting)
num_boost_round: 90 # number of epochs (equal to the number of trees!)
booster: 'gbtree' # 'gbtree' (default), 'dart' (dropout boosting)
tree_method: 'hist'
device: 'auto' # 'auto', 'cpu', 'cuda'

device: 'auto' # 'auto', 'cpu', 'cuda'
learning_rate: 0.1
gamma: 1.67
max_depth: 10
Expand Down Expand Up @@ -139,7 +139,7 @@ xgb01-no-mass:

# general parameters
model_param:
num_boost_round: 100 # number of epochs (equal to the number of trees!)
num_boost_round: 90 # number of epochs (equal to the number of trees!)
booster: 'gbtree' # 'gbtree' (default), 'dart' (dropout boosting)
tree_method: 'hist'
device: 'auto' # 'auto', 'cpu', 'cuda'
Expand Down Expand Up @@ -171,10 +171,10 @@ xgb01-no-mass:

# XGBoost
# https://xgboost.readthedocs.io/en/latest/parameter.html
xgb01-only-mu:
xgb01-no-jets:
train: 'xgb'
predict: 'xgb'
label: 'XGB-only-mu'
label: 'XGB-no-jets'
raytune: xgb_trial_0

# ** Custom set of variables **
Expand All @@ -183,7 +183,7 @@ xgb01-only-mu:

# general parameters
model_param:
num_boost_round: 100 # number of epochs (equal to the number of trees!)
num_boost_round: 90 # number of epochs (equal to the number of trees!)
booster: 'gbtree' # 'gbtree' (default), 'dart' (dropout boosting)
tree_method: 'hist'
device: 'auto' # 'auto', 'cpu', 'cuda'
Expand Down Expand Up @@ -217,16 +217,16 @@ xgb01-only-mu:
# https://xgboost.readthedocs.io/en/latest/parameter.html
iceboost:
train: 'xgb'
predict: 'xgb'
predict: 'xgb_logistic' # We apply logistic link function manually (because custom loss)
label: 'ICEBOOST'
raytune: xgb_trial_0

#exclude_MVA_vars: ['.*']
#include_MVA_vars: ['.*']

# general parameters
model_param:
num_boost_round: 100 # number of epochs (equal to the number of trees!)
num_boost_round: 90 # number of epochs (equal to the number of trees!)
booster: 'gbtree' # 'gbtree' (default), 'dart' (dropout boosting)
tree_method: 'hist'
device: 'auto' # 'auto', 'cpu', 'cuda'
Expand Down Expand Up @@ -265,7 +265,7 @@ iceboost:
# https://xgboost.readthedocs.io/en/latest/parameter.html
iceboost-no-mass:
train: 'xgb'
predict: 'xgb'
predict: 'xgb_logistic' # We apply logistic link function manually (because custom loss)
label: 'ICEBOOST-no-mass'
raytune: xgb_trial_0

Expand All @@ -275,7 +275,7 @@ iceboost-no-mass:

# general parameters
model_param:
num_boost_round: 100 # number of epochs (equal to the number of trees!)
num_boost_round: 90 # number of epochs (equal to the number of trees!)
booster: 'gbtree' # 'gbtree' (default), 'dart' (dropout boosting)
tree_method: 'hist'
device: 'auto' # 'auto', 'cpu', 'cuda'
Expand Down Expand Up @@ -312,10 +312,10 @@ iceboost-no-mass:

# XGBoost
# https://xgboost.readthedocs.io/en/latest/parameter.html
iceboost-only-mu:
iceboost-no-jets:
train: 'xgb'
predict: 'xgb'
label: 'ICEBOOST-only-mu'
predict: 'xgb_logistic' # We apply logistic link function manually (because custom loss)
label: 'ICEBOOST-no-jets'
raytune: xgb_trial_0

# ** Custom set of variables **
Expand All @@ -324,7 +324,7 @@ iceboost-only-mu:

# general parameters
model_param:
num_boost_round: 100 # number of epochs (equal to the number of trees!)
num_boost_round: 90 # number of epochs (equal to the number of trees!)
booster: 'gbtree' # 'gbtree' (default), 'dart' (dropout boosting)
tree_method: 'hist'
device: 'auto' # 'auto', 'cpu', 'cuda'
Expand Down
4 changes: 2 additions & 2 deletions configs/dqcd/mvavars.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,12 @@

# Mutual information regularization targets
MI_VARS = [
'muonSV_mass.*'
#'muonSV_mass.*' # All
'muonSV_mass(0)' # The leading one
]

print(LOAD_VARS)

# (regular expressions supported here)
#LOAD_VARS = ['.+hlt.?', '.?gen.?']
#LOAD_VARS = ['.*'] # all

6 changes: 3 additions & 3 deletions configs/dqcd/plots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ FILTER: &FILTER


basic:
active: False
active: True
nbins: 70
exclude_vals: [null, -999.0]

Expand All @@ -45,14 +45,14 @@ contours:

ROC:
active: true
num_bootstrap: 200
num_bootstrap: 50
xmin: 1.0E-6
set_filter: *FILTER

## Binned ROC plots can be 1D or 2D
ROC_binned:
active: false
num_bootstrap: 200
num_bootstrap: 50
xmin: 1.0E-4

#plot[0]:
Expand Down
6 changes: 3 additions & 3 deletions configs/dqcd/plots_new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ FILTER: &FILTER


basic:
active: False
active: True
nbins: 70
exclude_vals: [null, -999.0]

Expand All @@ -45,14 +45,14 @@ contours:

ROC:
active: true
num_bootstrap: 200
num_bootstrap: 50
xmin: 1.0E-6
set_filter: *FILTER

## Binned ROC plots can be 1D or 2D
ROC_binned:
active: false
num_bootstrap: 200
num_bootstrap: 50
xmin: 1.0E-4

#plot[0]:
Expand Down
6 changes: 3 additions & 3 deletions configs/dqcd/tune0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ train_runmode:

- xgb01
- xgb01-no-mass
- xgb01-only-mu
- xgb01-no-jets

- iceboost
- iceboost-no-mass
- iceboost-only-mu

- iceboost-no-jets
#- dmlp
#- lgr0

Expand Down
6 changes: 3 additions & 3 deletions configs/dqcd/tune0_new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ train_runmode:
algo: 'truncate' # algorithm: 'truncate', null
qmin: 0.01 # in [0,100]
qmax: 99.9 # in [0,100]


# ** Activate models here **
# Give all models some unique identifier and label
Expand All @@ -144,11 +144,11 @@ train_runmode:

- xgb01
- xgb01-no-mass
- xgb01-only-mu
- xgb01-no-jets

- iceboost
- iceboost-no-mass
- iceboost-only-mu
- iceboost-no-jets

#- dmlp
#- lgr0
Expand Down
36 changes: 25 additions & 11 deletions icenet/tools/aux.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import awkward as ak
import re
import time
import datetime

import numba
import copy
Expand Down Expand Up @@ -827,21 +828,34 @@ def deltar(eta1,eta2, phi1,phi2):
return np.sqrt((eta1 - eta2)**2 + deltaphi(phi1,phi2)**2)


def create_model_filename(path, label, epoch, filetype, max_epochs=int(1e5)):
def getmtime(filename):
""" Return the last modification time of a file, reported by os.stat()
"""
return os.stat(filename).st_mtime

def createfilename(i):
return path + '/' + label + '_' + str(i) + filetype

# Loop over epochs
last_found = -1
for i in range(max_epochs):
filename = createfilename(i)
if os.path.exists(filename):
last_found = i
def create_model_filename(path: str, label: str, filetype='.dat', epoch:int=None, max_epochs:int=int(1e5)):
""" Create model filename
"""
def createfilename(i):
return f'{path}/{label}_{i}{filetype}'

if epoch is None or epoch == -1:

last_found = -1
for i in range(max_epochs):
filename = createfilename(i)
if os.path.exists(filename):
last_found = i
else:
break
else:
last_found = epoch

filename = createfilename(last_found)
print(__name__ + f'.create_model_filename: Found model file: {filename}')

dt = datetime.datetime.fromtimestamp(getmtime(filename))
print(__name__ + f'.create_model_filename: Found a model file: {filename} (modified {dt})')

return filename


Expand Down

0 comments on commit de6882d

Please sign in to comment.