diff options
Diffstat (limited to 'experiments/ml.pyx')
| -rw-r--r-- | experiments/ml.pyx | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/experiments/ml.pyx b/experiments/ml.pyx index e1ce4cf..53e614b 100644 --- a/experiments/ml.pyx +++ b/experiments/ml.pyx @@ -13,13 +13,13 @@ cdef DTYPE_t weight_success(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, DTYPE_t w1, DTYPE_t w2, DTYPE_t w3): """weight for successful infection, exponential time model""" cdef DTYPE_t structural, temporal, result - structural = delta ** dist + structural = dist * log(delta) # structural = plogis(w1,delta) * plogis(w2,delta) * plogis(w3,delta) - temporal = exp(-alpha*dt) * (exp(alpha)-1.) + temporal = log(exp(alpha)-1.) - alpha*dt # temporal = 1 - exp(-alpha*dt) - if exp(-alpha*dt)==0.: print 'UNDERFLOW ERROR' + # if exp(-alpha*dt)==0.: print 'UNDERFLOW ERROR' # temporal = 1. / (1. + (dt - 1.)/alpha)**0.01 - 1. / (1. + dt/alpha)**0.01 - result = log(structural * temporal) + result = structural + temporal # print 'st', structural, temporal return result @@ -42,7 +42,7 @@ def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, DTYPE_t beta, ll list parents, failures, successes n_roots, n_victims = len(root_victims), len(victims) - n_nodes = 100 + n_nodes = 148152 cdef: np.ndarray[DTYPE_t] probs = np.zeros(n_victims, dtype=DTYPE) np.ndarray[DTYPE_t] probs_fail = np.zeros(n_victims, dtype=DTYPE) @@ -83,8 +83,8 @@ def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # print 'probs', probs max_beta_add = float('-inf') # iterate over all victim nodes to find the optimal threshold - for beta in [0.13]:#np.arange(0.001, .2, .002): - thresh = log(beta/(1.-beta)) + for beta in np.arange(0.001, .2, .002): + thresh = log(beta/(3012*(1.-beta))) # print 'beta:', beta, 'thresh:', thresh, 'infected:', len(probs[probs>=thresh]) roots = n_roots + len(probs[probs<thresh]) |
