|
|
@@ -90,11 +90,6 @@ def unpack_phi_mono(phi):
|
|
|
|
|
|
return p, a, b, s, k, th
|
|
|
|
|
|
-# Priors
|
|
|
-# Beta prior on p centered at empirical rate
|
|
|
-TAU = 25.0 # reduce to ~5 if you want it weaker
|
|
|
-alpha = max(TAU * float(p_emp), 1e-6)
|
|
|
-beta = max(TAU * (1.0 - float(p_emp)), 1e-6)
|
|
|
|
|
|
# Weak log-normal shrinkage on positive parameters
|
|
|
def nlog_lognormal(x, mu, sigma, eps=1e-12):
|
|
|
@@ -116,27 +111,7 @@ def neg_post_phi_mono_WITH_CONST_REG(phi, X, y):
|
|
|
# Prior on p ~ Beta(alpha, beta)
|
|
|
npr_p = -((alpha-1)*np.log(p + eps) + (beta-1)*np.log(1 - p + eps))
|
|
|
|
|
|
- # Regularization (weak priors)
|
|
|
- # AE median m1: use AE median if present; otherwise overall median.
|
|
|
- if (y == 1).any():
|
|
|
- m1 = np.median(X[y == 1])
|
|
|
- else:
|
|
|
- m1 = np.median(X)
|
|
|
-
|
|
|
- reg = 0.0 # total penalty starts at zero
|
|
|
-
|
|
|
- # 1) Gamma shape k (>0): very weak prior centered at 2 (σ=1.2).
|
|
|
- reg += nlog_lognormal(k, mu=np.log(2.0), sigma=1.2)
|
|
|
-
|
|
|
- # 2) Beta-Prime shape b (>0): same weak prior.
|
|
|
- reg += nlog_lognormal(b, mu=np.log(2.0), sigma=1.2)
|
|
|
-
|
|
|
- # 3) Beta-Prime scale s (>0): center near AE median (tighter σ=0.5).
|
|
|
- reg += nlog_lognormal(s, mu=np.log(max(m1, 1e-6)), sigma=0.5)
|
|
|
-
|
|
|
- # 4) Left-tail gap delta = a - k (>0): center around ~1.5 (σ=0.5)
|
|
|
- delta = a - k
|
|
|
- reg += nlog_lognormal(delta, mu=np.log(1.5), sigma=0.5)
|
|
|
+
|
|
|
|
|
|
# Keep theta away from the boundary: Beta(3,3) on r = th/th_cap
|
|
|
thcap = theta_max(a, b, k, s)
|
|
|
@@ -146,7 +121,7 @@ def neg_post_phi_mono_WITH_CONST_REG(phi, X, y):
|
|
|
else:
|
|
|
npr_r = 0.0
|
|
|
|
|
|
- return nll + npr_p + reg + npr_r
|
|
|
+ return nll +npr_r
|
|
|
|
|
|
# Initialization
|
|
|
def init_phi(X, y):
|