diff --git a/toolkit.py b/toolkit.py index b02ae40060513a5a7a34e8d3c99e49e932102b06..bf7d48de5573d33373a09eb423964037c0a99673 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 )