Skip to content

Commit

Permalink
change definition of weights
Browse files Browse the repository at this point in the history
  • Loading branch information
theoheimel committed Apr 3, 2023
1 parent 4c446d0 commit c7f4b2f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/loaders/prec_inn.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def compute_preprocessing(
input_obs.append(mass)

if append_delta_r:
drinv = lambda x: x #np.minimum(1/(x+1e-7), 20)
drinv = lambda x: np.minimum(1/(x+1e-7), 20)
if mult > 3:
input_obs.append(drinv(dr(obs.phi[:,2], obs.phi[:,3], obs.eta[:,2], obs.eta[:,3])))
if mult > 4:
Expand Down
19 changes: 4 additions & 15 deletions src/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def plot_roc(self, file: str):
Args:
file: Output file name
"""
scores = -np.concatenate((1/self.weights_true, self.weights_fake), axis=0)
scores = -np.concatenate((self.weights_true, self.weights_fake), axis=0)
labels = np.concatenate((
np.ones_like(self.weights_true),
np.zeros_like(self.weights_fake)
Expand Down Expand Up @@ -231,20 +231,17 @@ def plot_single_weight_hist(
if self.bayesian:
true_hists = np.stack([
np.histogram(
self.weights_true[:,i] / np.mean(self.weights_true[:,i]),
bins=bins
self.weights_true[:,i], bins=bins
)[0] for i in range(self.weights_true.shape[1])
], axis=1)
fake_hists = np.stack([
np.histogram(
self.weights_fake[:,i] / np.mean(self.weights_fake[:,i]),
bins=bins
self.weights_fake[:,i], bins=bins
)[0] for i in range(self.weights_fake.shape[1])
], axis=1)
combined_hists = np.stack([
np.histogram(
weights_combined[:,i] / np.mean(weights_combined[:,i]),
bins=bins
weights_combined[:,i], bins=bins
)[0] for i in range(weights_combined.shape[1])
], axis=1)

Expand All @@ -263,14 +260,6 @@ def plot_single_weight_hist(
np.quantile(combined_hists, 0.159, axis=1),
np.quantile(combined_hists, 0.841, axis=1)
), axis=0)

#y_true = np.mean(true_hists, axis=1)
#y_true_err = np.std(true_hists, axis=1)
#y_fake = np.mean(fake_hists, axis=1)
#y_fake_err = np.std(fake_hists, axis=1)
#y_combined = np.mean(combined_hists, axis=1)
#y_combined_err = np.std(combined_hists, axis=1)

else:
y_true = np.histogram(self.weights_true, bins=bins)[0]
y_true_err = None
Expand Down
2 changes: 1 addition & 1 deletion src/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def predict_single(self):
])
y_true_sig = y_true.sigmoid().flatten()
y_fake_sig = y_fake.sigmoid().flatten()
w_true = (1 - y_true_sig) / y_true_sig
w_true = y_true_sig / (1 - y_true_sig)
w_fake = y_fake_sig / (1 - y_fake_sig)
min_size = min(len(y_true), len(y_fake))
clf_score = self.loss(
Expand Down

0 comments on commit c7f4b2f

Please sign in to comment.