Skip to content

Commit b8323d9

Browse files
committed
convert delta bic to bayes factors
1 parent 94b1d37 commit b8323d9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

happler/tree/terminator.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def check(
211211

212212

213213
class BICTerminator(Terminator):
214-
def __init__(self, thresh: float = 10, log: Logger = None):
214+
def __init__(self, thresh: float = 3, log: Logger = None):
215215
super().__init__()
216216
self.thresh = thresh
217217
self.log = log or getLogger(self.__class__.__name__)
@@ -239,7 +239,10 @@ def compute_val(
239239
# terminate if the effect sizes have gone in the opposite direction
240240
self.log.debug("Terminated b/c effect size did not improve")
241241
return True
242-
stat = results.data["bic"] - parent_res.bic
242+
stat = parent_res.bic - results.data["bic"]
243+
# compute the bayes factor approximation from the delta BIC:
244+
# A practical solution to the pervasive problems of p values
245+
stat = np.exp(stat/2)
243246
stat = stat[best_idx]
244247
else:
245248
# parent_res = None when the parent node is the root node
@@ -274,6 +277,7 @@ def check(
274277
else:
275278
pval, stat = computed_val
276279
if stat is None:
280+
# TODO: handle this case by using delta BIC to rank, instead?
277281
if pval >= self.thresh:
278282
self.log.debug(
279283
f"Terminated with delta BIC {stat} and p-value {pval} >= {self.thresh}"

0 commit comments

Comments
 (0)