From 8e09ca6ca68c71bdab65525b529e2adfa281823c Mon Sep 17 00:00:00 2001 From: Ben Green Date: Wed, 1 Jul 2015 00:49:23 -0400 Subject: Got predict-victims running in parallel, drastically reducing the time for each test. Also changed how we get the rankings of infected individuals each day. --- R Scripts/generate-network.R | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'R Scripts/generate-network.R') diff --git a/R Scripts/generate-network.R b/R Scripts/generate-network.R index 3b40969..dab81a4 100644 --- a/R Scripts/generate-network.R +++ b/R Scripts/generate-network.R @@ -3,20 +3,20 @@ setwd("~/Documents/Cascade Project/") source('criminal_cascades/R Scripts/temporal.R') source('criminal_cascades/R Scripts/structural.R') -alpha = 1/100 -beta = 0.02 -delta = 0.15 +alpha = 1/10 +beta = 0.01 +delta = 0.25 # lmbda = 1/10 t_max = 1000 N = 5000 g = forest.fire.game(nodes=N, fw.prob=0.3, ambs=1, directed=F) -plot(g, vertex.size=5, vertex.label=NA) +plot(g, vertex.size=3, vertex.label=NA) V(g)$seed = runif(vcount(g)) Date: Thu, 2 Jul 2015 23:10:54 -0400 Subject: just some minor tests with ml --- R Scripts/generate-network.R | 16 +- experiments/build/temp.macosx-10.6-x86_64-2.7/ml.o | Bin 306196 -> 306268 bytes experiments/build_network.py | 2 +- experiments/ml.c | 180 +++++++++---------- experiments/ml.pyx | 11 +- experiments/ml.so | Bin 119284 -> 119276 bytes experiments/out.log | 200 ++++++++++----------- experiments/process.py | 4 +- 8 files changed, 207 insertions(+), 206 deletions(-) (limited to 'R Scripts/generate-network.R') diff --git a/R Scripts/generate-network.R b/R Scripts/generate-network.R index dab81a4..db7012d 100644 --- a/R Scripts/generate-network.R +++ b/R Scripts/generate-network.R @@ -3,9 +3,9 @@ setwd("~/Documents/Cascade Project/") source('criminal_cascades/R Scripts/temporal.R') source('criminal_cascades/R Scripts/structural.R') -alpha = 1/10 -beta = 0.01 -delta = 0.25 +alpha = 0.1 +beta = 0.25 +delta = 0.1 # lmbda = 1/10 t_max = 1000 @@ -16,7 +16,7 @@ plot(g, vertex.size=3, vertex.label=NA) V(g)$seed = runif(vcount(g))tp_iternext; if (unlikely(!__pyx_t_36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_36 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; for (;;) { @@ -2929,16 +2929,16 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ if (likely(PyList_CheckExact(__pyx_t_6))) { if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_6)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_6)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } } else { @@ -2947,79 +2947,79 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } __Pyx_GOTREF(__pyx_t_5); } - __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_beta = __pyx_t_27; - /* "ml.pyx":81 + /* "ml.pyx":80 * # 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 */ - __pyx_v_thresh = log((__pyx_v_beta / (3012. * (1. - __pyx_v_beta)))); + __pyx_v_thresh = log((__pyx_v_beta / (1000. * (1. - __pyx_v_beta)))); - /* "ml.pyx":82 + /* "ml.pyx":81 * for beta in np.arange(0.01, 1., .01): - * thresh = log(beta/(3012.*(1.-beta))) + * thresh = log(beta/(1000.*(1.-beta))) * seeds = probs=thresh * roots = n_roots + sum(seeds) */ - __pyx_t_5 = PyFloat_FromDouble(__pyx_v_thresh); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyFloat_FromDouble(__pyx_v_thresh); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_v_probs), __pyx_t_5, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_v_probs), __pyx_t_5, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF_SET(__pyx_v_seeds, __pyx_t_4); __pyx_t_4 = 0; - /* "ml.pyx":83 - * thresh = log(beta/(3012.*(1.-beta))) + /* "ml.pyx":82 + * thresh = log(beta/(1000.*(1.-beta))) * seeds = probs=thresh # <<<<<<<<<<<<<< * roots = n_roots + sum(seeds) * */ - __pyx_t_4 = PyFloat_FromDouble(__pyx_v_thresh); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_thresh); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyObject_RichCompare(((PyObject *)__pyx_v_probs), __pyx_t_4, Py_GE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_RichCompare(((PyObject *)__pyx_v_probs), __pyx_t_4, Py_GE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_v_non_seeds, __pyx_t_5); __pyx_t_5 = 0; - /* "ml.pyx":84 + /* "ml.pyx":83 * seeds = probs=thresh * roots = n_roots + sum(seeds) # <<<<<<<<<<<<<< * * beta_add = 0. */ - __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_n_roots); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_n_roots); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_seeds); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_seeds); __Pyx_GIVEREF(__pyx_v_seeds); - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_sum, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyNumber_Add(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyNumber_Add(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_12 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_roots = __pyx_t_12; - /* "ml.pyx":86 + /* "ml.pyx":85 * roots = n_roots + sum(seeds) * * beta_add = 0. # <<<<<<<<<<<<<< @@ -3028,18 +3028,18 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ */ __pyx_v_beta_add = 0.; - /* "ml.pyx":88 + /* "ml.pyx":87 * beta_add = 0. * # 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) */ - __pyx_t_4 = PyFloat_FromDouble(__pyx_v_beta_add); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_beta_add); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyObject_GetItem(((PyObject *)__pyx_v_probs), __pyx_v_non_seeds); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_5 = PyObject_GetItem(((PyObject *)__pyx_v_probs), __pyx_v_non_seeds); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_5); - __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_sum); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_sum); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; @@ -3053,57 +3053,57 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ } } if (__pyx_t_5) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_21, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_21, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { - __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_21); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_21); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; - __pyx_t_21 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_21 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_t_21); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_t_21); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __pyx_v_beta_add = __pyx_t_27; - /* "ml.pyx":90 + /* "ml.pyx":89 * 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: */ - __pyx_t_21 = PyFloat_FromDouble(__pyx_v_beta_add); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_21 = PyFloat_FromDouble(__pyx_v_beta_add); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_21); - __pyx_t_3 = PyFloat_FromDouble((__pyx_v_roots * log((__pyx_v_beta / 3012.)))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyFloat_FromDouble((__pyx_v_roots * log((__pyx_v_beta / 1000.)))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_roots); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_roots); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyNumber_Subtract(__pyx_v_n_nodes, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_Subtract(__pyx_v_n_nodes, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyFloat_FromDouble(log((1. - __pyx_v_beta))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyFloat_FromDouble(log((1. - __pyx_v_beta))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_20 = PyNumber_Multiply(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_20 = PyNumber_Multiply(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_t_20); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_t_20); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; - __pyx_t_20 = PyNumber_InPlaceAdd(__pyx_t_21, __pyx_t_4); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_20 = PyNumber_InPlaceAdd(__pyx_t_21, __pyx_t_4); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_t_20); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_t_20); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __pyx_v_beta_add = __pyx_t_27; - /* "ml.pyx":92 - * beta_add += roots * log(beta/3012.) + (n_nodes-roots) * log(1. - beta) + /* "ml.pyx":91 + * beta_add += roots * log(beta/1000.) + (n_nodes-roots) * log(1. - beta) * * if beta_add > max_beta_add: # <<<<<<<<<<<<<< * max_beta = beta @@ -3112,7 +3112,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ __pyx_t_31 = ((__pyx_v_beta_add > __pyx_v_max_beta_add) != 0); if (__pyx_t_31) { - /* "ml.pyx":93 + /* "ml.pyx":92 * * if beta_add > max_beta_add: * max_beta = beta # <<<<<<<<<<<<<< @@ -3121,7 +3121,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ */ __pyx_v_max_beta = __pyx_v_beta; - /* "ml.pyx":94 + /* "ml.pyx":93 * if beta_add > max_beta_add: * max_beta = beta * max_roots = roots # <<<<<<<<<<<<<< @@ -3130,7 +3130,7 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ */ __pyx_v_max_roots = __pyx_v_roots; - /* "ml.pyx":95 + /* "ml.pyx":94 * max_beta = beta * max_roots = roots * max_beta_add = beta_add # <<<<<<<<<<<<<< @@ -3142,17 +3142,17 @@ static PyObject *__pyx_pf_2ml_ml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *_ } __pyx_L32:; - /* "ml.pyx":80 + /* "ml.pyx":79 * 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 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 diff --git a/experiments/ml.so b/experiments/ml.so index a08d635..d4cd7b4 100755 Binary files a/experiments/ml.so and b/experiments/ml.so differ diff --git a/experiments/out.log b/experiments/out.log index a718511..895f69f 100644 --- a/experiments/out.log +++ b/experiments/out.log @@ -1,100 +1,100 @@ -0.001 0.001 0.08 11270 -130174.021949 -0.001 0.0016681005372 0.08 11270 -130186.81792 -0.001 0.00278255940221 0.08 11270 -130208.510741 -0.001 0.00464158883361 0.08 11270 -130245.688267 -0.001 0.00774263682681 0.08 11270 -130310.57411 -0.001 0.0129154966501 0.08 11270 -130427.308991 -0.001 0.0215443469003 0.08 11270 -130648.06397 -0.001 0.035938136638 0.04 6478 -128816.657559 -0.001 0.0599484250319 0.04 6478 -127394.665041 -0.001 0.1 0.04 6478 -127688.933813 -0.0016681005372 0.001 0.08 11270 -130184.321487 -0.0016681005372 0.0016681005372 0.08 11270 -130204.10481 -0.0016681005372 0.00278255940221 0.08 11270 -130237.646155 -0.0016681005372 0.00464158883361 0.08 11270 -130295.138019 -0.0016681005372 0.00774263682681 0.08 11270 -130395.500445 -0.0016681005372 0.0129154966501 0.08 11270 -130576.118953 -0.0016681005372 0.0215443469003 0.04 6478 -128846.541805 -0.0016681005372 0.035938136638 0.04 6478 -127087.253323 -0.0016681005372 0.0599484250319 0.04 6478 -126230.808822 -0.0016681005372 0.1 0.02 2792 -126557.181556 -0.00278255940221 0.001 0.08 11270 -130198.331202 -0.00278255940221 0.0016681005372 0.08 11270 -130227.620554 -0.00278255940221 0.00278255940221 0.08 11270 -130277.284253 -0.00278255940221 0.00464158883361 0.08 11270 -130362.425847 -0.00278255940221 0.00774263682681 0.08 11270 -130511.096608 -0.00278255940221 0.0129154966501 0.04 6499 -129059.422383 -0.00278255940221 0.0215443469003 0.04 6478 -127109.015024 -0.00278255940221 0.035938136638 0.04 6478 -125684.241338 -0.00278255940221 0.0599484250319 0.04 6478 -125600.024485 -0.00278255940221 0.1 0.02 2792 -126287.212393 -0.00464158883361 0.001 0.08 11270 -130215.294173 -0.00464158883361 0.0016681005372 0.08 11270 -130256.095445 -0.00464158883361 0.00278255940221 0.08 11270 -130325.28705 -0.00464158883361 0.00464158883361 0.08 11270 -130443.928528 -0.00464158883361 0.00774263682681 0.05 7027 -129395.352373 -0.00464158883361 0.0129154966501 0.04 6516 -127431.591365 -0.00464158883361 0.0215443469003 0.04 6478 -125683.037727 -0.00464158883361 0.035938136638 0.04 6478 -124664.01619 -0.00464158883361 0.0599484250319 0.02 2914 -124502.496739 -0.00464158883361 0.1 0.02 2792 -127134.604186 -0.00774263682681 0.001 0.08 11270 -130232.773853 -0.00774263682681 0.0016681005372 0.08 11270 -130285.439066 -0.00774263682681 0.00278255940221 0.08 11270 -130374.758088 -0.00774263682681 0.00464158883361 0.05 7652 -129744.991978 -0.00774263682681 0.00774263682681 0.05 6995 -127969.97982 -0.00774263682681 0.0129154966501 0.05 6677 -126168.108707 -0.00774263682681 0.0215443469003 0.04 6513 -124653.173909 -0.00774263682681 0.035938136638 0.04 6478 -124060.374554 -0.00774263682681 0.0599484250319 0.02 2937 -123459.631205 -0.00774263682681 0.1 0.01 1199 -128091.177099 -0.0129154966501 0.001 0.08 11270 -130247.637572 -0.0129154966501 0.0016681005372 0.08 11270 -130310.391126 -0.0129154966501 0.00278255940221 0.06 8952 -129978.711147 -0.0129154966501 0.00464158883361 0.05 7622 -128580.851845 -0.0129154966501 0.00774263682681 0.05 7183 -126905.034076 -0.0129154966501 0.0129154966501 0.05 6902 -125304.331411 -0.0129154966501 0.0215443469003 0.05 6712 -124093.056726 -0.0129154966501 0.035938136638 0.03 4220 -123607.130582 -0.0129154966501 0.0599484250319 0.02 3041 -122971.205801 -0.0129154966501 0.1 0.01 1210 -129142.326165 -0.0215443469003 0.001 0.08 11270 -130258.217698 -0.0215443469003 0.0016681005372 0.07 9957 -130081.814439 -0.0215443469003 0.00278255940221 0.06 8662 -129124.841865 -0.0215443469003 0.00464158883361 0.05 7864 -127781.895187 -0.0215443469003 0.00774263682681 0.05 7487 -126287.652103 -0.0215443469003 0.0129154966501 0.05 7248 -124916.428004 -0.0215443469003 0.0215443469003 0.05 7058 -124002.594007 -0.0215443469003 0.035938136638 0.03 4060 -122986.296269 -0.0215443469003 0.0599484250319 0.02 3225 -122943.105886 -0.0215443469003 0.1 0.01 1280 -129952.279246 -0.035938136638 0.001 0.07 10368 -130108.933188 -0.035938136638 0.0016681005372 0.06 9401 -129491.738149 -0.035938136638 0.00278255940221 0.06 8856 -128521.580165 -0.035938136638 0.00464158883361 0.06 8372 -127371.393158 -0.035938136638 0.00774263682681 0.05 7935 -126147.240183 -0.035938136638 0.0129154966501 0.05 7682 -125046.741534 -0.035938136638 0.0215443469003 0.05 7476 -124429.198394 -0.035938136638 0.035938136638 0.03 4307 -122878.240073 -0.035938136638 0.0599484250319 0.02 2939 -123316.885543 -0.035938136638 0.1 0.01 1389 -130593.383741 -0.0599484250319 0.001 0.07 10079 -129709.888924 -0.0599484250319 0.0016681005372 0.06 9545 -129062.475372 -0.0599484250319 0.00278255940221 0.06 9190 -128212.556391 -0.0599484250319 0.00464158883361 0.06 8868 -127288.891344 -0.0599484250319 0.00774263682681 0.06 8559 -126362.833809 -0.0599484250319 0.0129154966501 0.06 8304 -125604.769419 -0.0599484250319 0.0215443469003 0.04 6187 -124909.433209 -0.0599484250319 0.035938136638 0.03 4809 -123357.362127 -0.0599484250319 0.0599484250319 0.02 2564 -123821.010849 -0.0599484250319 0.1 0.01 1603 -131308.788018 -0.1 0.001 0.07 10122 -129407.183852 -0.1 0.0016681005372 0.07 9858 -128826.387421 -0.1 0.00278255940221 0.06 9551 -128164.459489 -0.1 0.00464158883361 0.06 9323 -127449.154213 -0.1 0.00774263682681 0.06 9138 -126798.726378 -0.1 0.0129154966501 0.06 8941 -126366.966378 -0.1 0.0215443469003 0.05 6820 -125456.586416 -0.1 0.035938136638 0.04 5608 -124150.372812 -0.1 0.0599484250319 0.02 2771 -124505.31667 -0.1 0.1 0.01 1909 -132157.286741 +0.1 0.01 0.32 1587 -16246.2835303 +0.1 0.0129154966501 0.3 1522 -16193.1560593 +0.1 0.016681005372 0.3 1482 -16136.7007139 +0.1 0.0215443469003 0.29 1445 -16083.927662 +0.1 0.0278255940221 0.28 1418 -16045.4325535 +0.1 0.035938136638 0.28 1399 -16033.3471288 +0.1 0.0464158883361 0.28 1381 -16065.8045855 +0.1 0.0599484250319 0.27 1365 -16174.1785652 +0.1 0.0774263682681 0.23 1166 -16354.0210508 +0.1 0.1 0.22 1094 -16710.6318304 +0.113646366639 0.01 0.32 1587 -16223.0544334 +0.113646366639 0.0129154966501 0.3 1522 -16169.9167648 +0.113646366639 0.016681005372 0.3 1496 -16114.7613028 +0.113646366639 0.0215443469003 0.29 1453 -16064.997114 +0.113646366639 0.0278255940221 0.29 1436 -16029.4224738 +0.113646366639 0.035938136638 0.28 1413 -16020.1691105 +0.113646366639 0.0464158883361 0.28 1399 -16057.1566663 +0.113646366639 0.0599484250319 0.26 1321 -16167.2369119 +0.113646366639 0.0774263682681 0.23 1173 -16335.8221545 +0.113646366639 0.1 0.22 1108 -16694.4584299 +0.129154966501 0.01 0.32 1587 -16201.5712361 +0.129154966501 0.0129154966501 0.31 1537 -16149.1696536 +0.129154966501 0.016681005372 0.3 1496 -16095.9372617 +0.129154966501 0.0215443469003 0.29 1464 -16049.6817227 +0.129154966501 0.0278255940221 0.29 1445 -16016.7348561 +0.129154966501 0.035938136638 0.29 1426 -16011.4090845 +0.129154966501 0.0464158883361 0.28 1407 -16051.4875514 +0.129154966501 0.0599484250319 0.26 1288 -16157.5499839 +0.129154966501 0.0774263682681 0.24 1183 -16321.8627529 +0.129154966501 0.1 0.22 1115 -16682.3833134 +0.146779926762 0.01 0.32 1587 -16182.0774435 +0.146779926762 0.0129154966501 0.31 1537 -16131.2048239 +0.146779926762 0.016681005372 0.3 1507 -16080.1708094 +0.146779926762 0.0215443469003 0.3 1482 -16037.2306303 +0.146779926762 0.0278255940221 0.29 1453 -16008.0169599 +0.146779926762 0.035938136638 0.29 1436 -16006.0071619 +0.146779926762 0.0464158883361 0.28 1418 -16050.0144027 +0.146779926762 0.0599484250319 0.26 1281 -16148.6892961 +0.146779926762 0.0774263682681 0.24 1187 -16311.3545786 +0.146779926762 0.1 0.23 1138 -16673.8963578 +0.16681005372 0.01 0.32 1587 -16164.849071 +0.16681005372 0.0129154966501 0.31 1560 -16116.449014 +0.16681005372 0.016681005372 0.3 1522 -16067.8766242 +0.16681005372 0.0215443469003 0.3 1496 -16027.3638618 +0.16681005372 0.0278255940221 0.29 1464 -16003.2426018 +0.16681005372 0.035938136638 0.29 1453 -16004.4084252 +0.16681005372 0.0464158883361 0.29 1436 -16052.4652191 +0.16681005372 0.0599484250319 0.26 1289 -16141.4404164 +0.16681005372 0.0774263682681 0.24 1196 -16303.5459122 +0.16681005372 0.1 0.23 1145 -16670.0806528 +0.189573565241 0.01 0.32 1613 -16149.7026241 +0.189573565241 0.0129154966501 0.31 1560 -16103.5965222 +0.189573565241 0.016681005372 0.31 1537 -16058.5451224 +0.189573565241 0.0215443469003 0.3 1507 -16020.9935104 +0.189573565241 0.0278255940221 0.3 1496 -16000.5729402 +0.189573565241 0.035938136638 0.29 1464 -16006.9538317 +0.189573565241 0.0464158883361 0.29 1453 -16058.7205642 +0.189573565241 0.0599484250319 0.25 1260 -16136.4254637 +0.189573565241 0.0774263682681 0.24 1206 -16299.8411955 +0.189573565241 0.1 0.23 1157 -16671.3131735 +0.215443469003 0.01 0.32 1613 -16136.2887288 +0.215443469003 0.0129154966501 0.32 1587 -16093.9635334 +0.215443469003 0.016681005372 0.31 1537 -16052.071471 +0.215443469003 0.0215443469003 0.3 1522 -16018.1621521 +0.215443469003 0.0278255940221 0.3 1507 -16000.7844822 +0.215443469003 0.035938136638 0.3 1482 -16012.1618981 +0.215443469003 0.0464158883361 0.28 1399 -16066.3079647 +0.215443469003 0.0599484250319 0.25 1272 -16136.5860246 +0.215443469003 0.0774263682681 0.24 1212 -16301.153347 +0.215443469003 0.1 0.23 1173 -16676.745682 +0.244843674682 0.01 0.32 1613 -16125.5232284 +0.244843674682 0.0129154966501 0.32 1587 -16085.6169883 +0.244843674682 0.016681005372 0.31 1560 -16048.1741694 +0.244843674682 0.0215443469003 0.31 1537 -16018.2052077 +0.244843674682 0.0278255940221 0.3 1522 -16004.8785245 +0.244843674682 0.035938136638 0.3 1507 -16019.6055296 +0.244843674682 0.0464158883361 0.28 1415 -16072.4792069 +0.244843674682 0.0599484250319 0.26 1278 -16139.4702448 +0.244843674682 0.0774263682681 0.25 1237 -16306.1951749 +0.244843674682 0.1 0.24 1195 -16688.1452238 +0.278255940221 0.01 0.33 1637 -16116.7453334 +0.278255940221 0.0129154966501 0.32 1613 -16080.0365035 +0.278255940221 0.016681005372 0.32 1587 -16046.9682889 +0.278255940221 0.0215443469003 0.31 1560 -16021.5867637 +0.278255940221 0.0278255940221 0.31 1537 -16011.7866661 +0.278255940221 0.035938136638 0.3 1522 -16030.8034204 +0.278255940221 0.0464158883361 0.27 1367 -16078.1951393 +0.278255940221 0.0599484250319 0.26 1298 -16144.7176332 +0.278255940221 0.0774263682681 0.25 1249 -16315.5245594 +0.278255940221 0.1 0.24 1207 -16702.3027221 +0.316227766017 0.01 0.33 1637 -16109.5865483 +0.316227766017 0.0129154966501 0.32 1613 -16075.7276647 +0.316227766017 0.016681005372 0.32 1587 -16046.7383729 +0.316227766017 0.0215443469003 0.31 1560 -16026.6264576 +0.316227766017 0.0278255940221 0.31 1537 -16022.2115914 +0.316227766017 0.035938136638 0.31 1537 -16044.7445633 +0.316227766017 0.0464158883361 0.27 1374 -16084.9299944 +0.316227766017 0.0599484250319 0.26 1308 -16152.3121983 +0.316227766017 0.0774263682681 0.25 1260 -16327.1609197 +0.316227766017 0.1 0.25 1235 -16718.4366844 diff --git a/experiments/process.py b/experiments/process.py index a0c9b98..6c71934 100644 --- a/experiments/process.py +++ b/experiments/process.py @@ -16,9 +16,9 @@ if __name__ == "__main__": root_victims, victims, non_victims, age = load(open(sys.argv[1])) # alphas = np.arange(.02, .1, .01) # parameter of the time component - alphas = np.logspace(-3,-1,num=10) + alphas = np.logspace(-1,-.5,num=10) # deltas = np.arange(.02, .1, .01) # parameter of the structural component - deltas = np.logspace(-3,-1,num=10) + deltas = np.logspace(-2,-1,num=10) with open("out.log", "w") as fh: for alpha, delta in product(alphas, deltas): beta, roots, ll = ml(root_victims, victims, non_victims, age, alpha, delta) -- cgit v1.2.3-70-g09d2