summaryrefslogtreecommitdiffstats
path: root/experiments/ml.pyx
diff options
context:
space:
mode:
Diffstat (limited to 'experiments/ml.pyx')
-rw-r--r--experiments/ml.pyx7
1 files changed, 4 insertions, 3 deletions
diff --git a/experiments/ml.pyx b/experiments/ml.pyx
index 53e614b..5016347 100644
--- a/experiments/ml.pyx
+++ b/experiments/ml.pyx
@@ -39,7 +39,7 @@ def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age,
DTYPE_t alpha, DTYPE_t delta):
cdef:
int n_roots, n_victims, n_nodes, roots, i, dist, dt, t, l
- DTYPE_t beta, ll
+ 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
@@ -84,12 +84,13 @@ def ml(dict root_victims, dict victims, dict non_victims, DTYPE_t age,
max_beta_add = float('-inf')
# iterate over all victim nodes to find the optimal threshold
for beta in np.arange(0.001, .2, .002):
- thresh = log(beta/(3012*(1.-beta)))
+ thresh = log(beta/(3012.*(1.-beta)))
# print 'beta:', beta, 'thresh:', thresh, 'infected:', len(probs[probs>=thresh])
roots = n_roots + len(probs[probs<thresh])
+ beta_add = 0.
# add probability for realized edges and subtract probability these edges fail
- beta_add = (probs[probs>=thresh]).sum()
+ beta_add += (probs[probs>=thresh]).sum()
# add probability for the seeds and non-seeds
beta_add += roots * log(beta) + (n_nodes-roots) * log(1. - beta)