From 29a80bedcb61d78616dd5e1222e6a64df07f0729 Mon Sep 17 00:00:00 2001 From: Nikolai Hartmann <Nikolai.Hartmann@physik.uni-muenchen.de> Date: Mon, 20 Aug 2018 11:39:12 +0200 Subject: [PATCH] invert activation option for plot_score --- toolkit.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/toolkit.py b/toolkit.py index b02ae40..bf7d48d 100755 --- a/toolkit.py +++ b/toolkit.py @@ -1104,8 +1104,18 @@ class ClassificationProject(object): plt.clf() - def plot_score(self, log=True, plot_opts=dict(bins=50, range=(0, 1)), - ylim=None, xlim=None, density=True, lumifactor=None, apply_class_weight=True): + def plot_score(self, log=True, plot_opts=dict(bins=50, range=(0,1)), + ylim=None, xlim=None, density=True, + lumifactor=None, apply_class_weight=True, + invert_activation=False): + if invert_activation: + if not self.activation_function_output == "sigmoid": + raise NotImplementedError("Inverse function of {} not supported yet - " + "currently only sigmoid" + .format(self.activation_function_output)) + trf = lambda y : np.log(y/(1-y)) + else: + trf = lambda y : y fig, ax = plt.subplots() for scores, weights, y, class_label, fn, opts in [ (self.scores_train, self.w_train, self.y_train, 1, ax.bar, dict(color="r", label="signal train")), @@ -1121,7 +1131,7 @@ class ClassificationProject(object): if lumifactor is not None: weights = weights*lumifactor centers, hist, rel_errors = self.get_bin_centered_hist( - scores[y==class_label].reshape(-1), + trf(scores[y==class_label].reshape(-1)), weights=weights, **plot_opts ) -- GitLab