diff options
| author | Ben Green <ben@SEASITs-MacBook-Pro.local> | 2015-06-20 12:11:47 -0400 |
|---|---|---|
| committer | Ben Green <ben@SEASITs-MacBook-Pro.local> | 2015-06-20 12:11:47 -0400 |
| commit | aaa2f530675f9f76bcd48e9641354f7a0e043012 (patch) | |
| tree | 1da776ef59414233b80bc4e6afbc56bfd1e33dde /experiments/ml.pyx | |
| parent | f2891c93b96388442d44512e6c43b092153f8c25 (diff) | |
| download | criminal_cascades-aaa2f530675f9f76bcd48e9641354f7a0e043012.tar.gz | |
added new model, ml2, which assumes all victims are infected by someone
else (unless they are root victims)
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]) |
