Skip to content
Snippets Groups Projects
Commit a74dbdc7 authored by Nikolai.Hartmann's avatar Nikolai.Hartmann
Browse files

fix profile average and quantile range

parent 4405753d
No related branches found
No related tags found
No related merge requests found
...@@ -62,7 +62,7 @@ layer = args.layer ...@@ -62,7 +62,7 @@ layer = args.layer
neuron = args.neuron neuron = args.neuron
if layer is None: if layer is None:
layer = c.layers layer = len(c.model.layers)-1
varx_index = c.fields.index(args.varx) varx_index = c.fields.index(args.varx)
if not plot_vs_activation: if not plot_vs_activation:
...@@ -86,8 +86,8 @@ vary_test = c.x_test[:,vary_index] ...@@ -86,8 +86,8 @@ vary_test = c.x_test[:,vary_index]
x_not_masked = np.where(varx_test != mask_value)[0] x_not_masked = np.where(varx_test != mask_value)[0]
y_not_masked = np.where(vary_test != mask_value)[0] y_not_masked = np.where(vary_test != mask_value)[0]
percentilesx = weighted_quantile(varx_test[x_not_masked], [0.1, 0.99], sample_weight=total_weights[x_not_masked]) percentilesx = weighted_quantile(varx_test[x_not_masked], [0.01, 0.99], sample_weight=total_weights[x_not_masked])
percentilesy = weighted_quantile(vary_test[y_not_masked], [0.1, 0.99], sample_weight=total_weights[y_not_masked]) percentilesy = weighted_quantile(vary_test[y_not_masked], [0.01, 0.99], sample_weight=total_weights[y_not_masked])
if args.xrange is not None: if args.xrange is not None:
if len(args.xrange) < 3: if len(args.xrange) < 3:
...@@ -154,10 +154,16 @@ if args.mode.startswith("mean"): ...@@ -154,10 +154,16 @@ if args.mode.startswith("mean"):
elif args.mode.startswith("profile"): elif args.mode.startswith("profile"):
def my_average(x, weights):
if weights.sum() <= 0:
return np.nan
else:
return np.average(x, weights=weights)
metric_dict = { metric_dict = {
"mean" : np.mean, "mean" : np.mean,
"max" : np.max, "max" : np.max,
"average" : np.average, "average" : my_average,
} }
if args.mode == "profile_sig": if args.mode == "profile_sig":
......
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