Skip to content

Commit d189695

Browse files
committed
implementing comments
1 parent 4607bf2 commit d189695

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

validphys2/src/validphys/hyperoptplot.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -686,14 +686,20 @@ def plot_activation_per_layer(hyperopt_dataframe):
686686
return fig
687687

688688
@figure
689-
def plot_cumulative_logp_chi2(hyperopt_dataframe):
689+
def plot_cumulative_logp_chi2(hyperopt_dataframe, commandline_args):
690+
"""
691+
Generate a plot of the running average of the log-likelihood (chi2)
692+
on the left (right) axis as a function of the trial index
693+
"""
690694

695+
args = SimpleNamespace(**commandline_args)
696+
chi2max = args.chi2_threshold
691697
results, _ = hyperopt_dataframe
692698
mlogp_ = results['hyper_loss_logp'].to_numpy()
693699
chi2_ = results['hyper_loss_chi2'].to_numpy()
694700

695701
# don t look at samples with -logp or chi2 too big
696-
idx_ok = np.where(chi2_<5.)
702+
idx_ok = np.where(chi2_<chi2max)
697703
fig, ax1 = plt.subplots()
698704
color = 'tab:blue'
699705
mlogp = mlogp_[idx_ok]
@@ -715,15 +721,21 @@ def plot_cumulative_logp_chi2(hyperopt_dataframe):
715721
return fig
716722

717723
@figure
718-
def plot_cumulative_loss(hyperopt_dataframe):
724+
def plot_cumulative_loss(hyperopt_dataframe, commandline_args):
725+
"""
726+
Generate a plot of the running average of the log-likelihood
727+
as a function of the trial index
728+
"""
719729

730+
args = SimpleNamespace(**commandline_args)
731+
chi2exp_max = args.chi2exp_threshold
720732
results, _ = hyperopt_dataframe
721733

722734
mloss_ = results['loss'].to_numpy()
723735
chi2_ = results['hyper_loss_chi2'].to_numpy()
724736
chi2exp = results['trvl_loss_chi2exp'].to_numpy()
725737

726-
idx_ok = np.where(chi2exp<1.35)
738+
idx_ok = np.where(chi2exp<chi2exp_max)
727739
fig, ax = plt.subplots()
728740
mloss = mloss_[idx_ok]
729741
xlabels = np.arange(len(mloss))

validphys2/src/validphys/scripts/vp_hyperoptplot.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ def add_positional_arguments(self, parser):
4444
type=float,
4545
default=1e3,
4646
)
47+
parser.add_argument(
48+
"-ct",
49+
"--chi2_threshold",
50+
help="Value of the chi2 threshold for logp plots",
51+
type=float,
52+
default=5.,
53+
)
54+
parser.add_argument(
55+
"-cet",
56+
"--chi2exp_threshold",
57+
help="Value of the exp chi2 threshold for loss plots",
58+
type=float,
59+
default=1.35,
60+
)
4761
parser.add_argument(
4862
"-f",
4963
"--filter",
@@ -123,6 +137,8 @@ def complete_mapping(self):
123137
"autofilter": args["autofilter"],
124138
"debug": args["debug"],
125139
"loss_target": args["loss_target"],
140+
"chi2exp_threshold": args["chi2exp_threshold"],
141+
"chi2_threshold": args["chi2_threshold"],
126142
}
127143

128144
try:

0 commit comments

Comments
 (0)