summaryrefslogtreecommitdiffstats
path: root/experiments/README.txt
blob: 80f6aa03bf935f6c46844335edf993db049f5510 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Description of the files
========================

* build_network.py: takes a .csv file containing a criminal network and builds
  and extract a compressed binary representation tailored to make the other
  scripts faster.

  Takes one argument, the name of the .csv file. The output file has the same
  name but the extension .pickle

* ml.pyx: code to compute the likelihood of a given alpha (time component) and
  delta (structural component) for a given infection graph. The optimization of
  the beta parameter (probability of being a root) is done internally.

* process.py: simple loop to do an exhaustive search over a range of alpha
  (time component) and delta (structural component). The likelihood (and a few
  other things) for each of the values is printed in the file "out.log". 
  Takes as argument the name of .pickle file computed by build_network.py
  Prints columns as alpha, delta, beta, number of roots, likelihood

* plot3d.py: code to obtain a 3d plot of the log likelihood as a function of
  alpha and delta. Can also be easily modified to obtain 2d plots along
  specific axes

Installation
============

* most of the code uses standard python + numpy + matplotlib

* the file ml.pyx is a Cython file which must be compiled in order to be used.
At a high level, ml.pyx is compiled into ml.so. The line "import ml" in
"process.py" will fail if the file ml.so is not present in the directory.
Important: do not forget to recompile ml.pyx after changing it, otherwise you
will be working with an outdated version of ml.so!

How to compile? A Makefile is provided. If using make on MacOS is too
complicated, it is also possible to compile .pyx files using python distutils
(which I would assume is more standard on MacOS). This only requires distutils
and a simple setup.py file. More details here:
http://docs.cython.org/src/reference/compilation.html#configuring-the-c-build

Running Code
============
python build_network.py ../../Results/dag_dat_all.csv
python setup.py build_ext --inplace
python process.py ../../Results/dag_dat_all.pickle
python plot3d.py