diff --git a/toolkit.py b/toolkit.py index 25231056fb769f6253fe6c825eac65e85451aaf9..e2d3bb44cb2c1c1375d58b8af20690e7c0188588 100755 --- a/toolkit.py +++ b/toolkit.py @@ -404,7 +404,7 @@ class KerasROOTClassification(object): try: self.history = History() self.shuffle_training_data() - + self.model.fit(self.x_train, # the reshape might be unnescessary here self.y_train.reshape(-1, 1), @@ -541,7 +541,36 @@ class KerasROOTClassification(object): plt.clf() def plot_score(self): - pass + + logger.info("Plot output scores") + + sig_weights = np.empty(sum(self.y_test == 1)) + sig_weights.fill(self.class_weight[1]) + bkg_weights = np.empty(sum(self.y_test == 0)) + bkg_weights.fill(self.class_weight[0]) + + print sig_weights.reshape(-1,1).shape + print self.scores_test[self.y_test==1].shape + binning = [20,0,1] + + fig = plt.figure(figsize=(8,6)) + + ax1 = plt.subplot2grid((4,4), (0,0), colspan=4, rowspan=4) + ax1.tick_params(direction='in') + ax1.set_xlim((binning[1], binning[2])) + ax1.xaxis.set_ticks_position('both') + ax1.yaxis.set_ticks_position('both') + + s_histTest, s_binsTest, s_patchesTest = plt.hist(self.scores_test[self.y_test==1],weights=sig_weights.reshape(-1,1), histtype='stepfilled', color='r', label='Signal (Training)', alpha=0.5, bins=binning[0], range=(binning[1], binning[2])) + b_histTest, b_binsTest, b_patchesTest = plt.hist(self.scores_test[self.y_test==0],weights=bkg_weights.reshape(-1,1), histtype='stepfilled', color='b', label='Background (Training)', alpha=0.5, bins=binning[0], range=(binning[1], binning[2])) + + plt.xlabel('Output score') + plt.ylabel('a.u.') + + plt.legend(loc='upper right', framealpha=1.0) + plt.savefig(os.path.join(self.project_dir, "scores.pdf")) + plt.clf() + def plot_loss(self):