Skip to content
Snippets Groups Projects
Commit 60eb8e90 authored by Dennis Noll's avatar Dennis Noll
Browse files

[plotting] adding capability for hl vars

parent 4f0216a2
No related branches found
No related tags found
No related merge requests found
......@@ -17,8 +17,11 @@ class Multiplot:
def __init__(self, n):
try:
self.cols, self.rows = [i for i in n]
except ValueError:
n = n[0]
self.cols = np.ceil(np.sqrt(n)).astype(int)
self.rows = np.ceil(n / self.cols).astype(int)
except TypeError:
self.n = n
self.cols = np.ceil(np.sqrt(n)).astype(int)
self.rows = np.ceil(n / self.cols).astype(int)
......@@ -99,12 +102,10 @@ def figure_activations(activations, class_names=None):
def figure_history(history_csv_path):
# self.input()["training"]["history"].path
pd.read_csv(history_csv_path).plot(subplots=True, figsize=(30, 30), layout=(7, 6))
fig = plt.figure()
fig.tight_layout()
return fig
# plt.savefig(self.output()["plots"].path + "/history.pdf")
def plot_histories(history_csv_path, path, cut=None, roll=1):
......@@ -128,6 +129,14 @@ def plot_histories(history_csv_path, path, cut=None, roll=1):
plt.close("all")
def plot_dict(importance, path="tmp.pdf"):
fig = plt.figure(figsize=(8, len(importance) / 3))
plt.barh(*zip(*importance.items()))
fig.tight_layout()
plt.savefig(path)
plt.close("all")
def figure_weights(w, y, class_names=None, relative=False):
n_p = y.shape[1]
bins = range(n_p)
......@@ -238,7 +247,14 @@ def figure_roc_curve(
def figure_inputs(
inps, truth, sample_weight=None, columns=None, class_names=None, signalvsbkg=False, bins=20
inps,
truth,
sample_weight=None,
columns=None,
class_names=None,
signalvsbkg=False,
bins=20,
overflow=1000,
):
multiplot = Multiplot(inps.shape[1:][::-1])
rows, cols = multiplot.lenghts()
......@@ -246,6 +262,7 @@ def figure_inputs(
fig, ax = plt.subplots(rows, cols, figsize=(size, size * rows / cols))
inps = inps.reshape(inps.shape[0], -1)
inps = np.clip(inps, -overflow, overflow)
order = np.argsort(-(sample_weight[:, None] * truth).sum(axis=0))
class_names = np.array(class_names)[order]
for feat, name in enumerate(columns):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment