diff options
Diffstat (limited to 'experiments/ml.pyx')
| -rw-r--r-- | experiments/ml.pyx | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/experiments/ml.pyx b/experiments/ml.pyx index 858207f..0d72c44 100644 --- a/experiments/ml.pyx +++ b/experiments/ml.pyx @@ -11,7 +11,7 @@ cdef DTYPE_t weight_success(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, """weight for successful infection, exponential time model""" cdef DTYPE_t structural, temporal, result structural = delta ** dist - temporal = log(exp(alpha)-1.) - alpha*dt/7. + temporal = log(exp(alpha)-1.) - alpha*dt/1. result = log(structural) + temporal return result @@ -20,7 +20,7 @@ cdef DTYPE_t weight_failure(int dist, int dt, DTYPE_t alpha, DTYPE_t delta, """weight for failed infection, exponential time model""" cdef DTYPE_t structural, temporal, result structural = delta ** dist - temporal = exp(-alpha * dt/7.) + temporal = exp(-alpha * dt/1.) result = log(1. - structural + structural * temporal) return result @@ -31,7 +31,7 @@ def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, DTYPE_t beta, ll, beta_add, max_beta, max_beta_add list parents, failures, successes n_roots, n_victims = len(root_victims), len(victims) - n_nodes = 148152 + n_nodes = 5000 cdef: np.ndarray[DTYPE_t] probs = np.zeros(n_victims, dtype=DTYPE) np.ndarray[DTYPE_t] probs_fail = np.zeros(n_victims, dtype=DTYPE) @@ -74,11 +74,10 @@ def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, ll = probs_fail.sum() # add probability that all edges to all victims fail ll += probs_nv.sum() # add probability that all edges to non_victims fail - # print 'probs', probs max_beta_add = float('-inf') # iterate over all victim nodes to find the optimal threshold for beta in np.arange(0.01, 1., .01): - thresh = log(beta/(3012.*(1.-beta))) + thresh = log(beta/(1000.*(1.-beta))) seeds = probs<thresh non_seeds = probs>=thresh roots = n_roots + sum(seeds) @@ -87,7 +86,7 @@ def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age, # add probability for realized edges and subtract probability these edges fail beta_add += (probs[non_seeds]).sum() # add probability for the seeds and non-seeds - beta_add += roots * log(beta/3012.) + (n_nodes-roots) * log(1. - beta) + beta_add += roots * log(beta/1000.) + (n_nodes-roots) * log(1. - beta) if beta_add > max_beta_add: max_beta = beta |
