diff options
| author | Ben Green <ben@SEASITs-MacBook-Pro.local> | 2015-06-25 23:56:26 -0400 |
|---|---|---|
| committer | Ben Green <ben@SEASITs-MacBook-Pro.local> | 2015-06-25 23:56:26 -0400 |
| commit | 7167a81cfb8b872dd1547e5a8669004b191417db (patch) | |
| tree | dd160b9a7f438837118d8ca9fe83ae6c35a0d71a /experiments/build_network.py | |
| parent | c8fc620dda6096932707566dc8f20a3e65cb26b0 (diff) | |
| download | criminal_cascades-7167a81cfb8b872dd1547e5a8669004b191417db.tar.gz | |
Worked on process to generate cascades in R, recover them in ml2, and
compare true/recovered. Results look good: ml2 finds close-to-actual
parameters and gets ~60% of the infectors right. I will check how many
recovery gets in the top 2 or 3 infectors.
Diffstat (limited to 'experiments/build_network.py')
| -rw-r--r-- | experiments/build_network.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/experiments/build_network.py b/experiments/build_network.py index 6cb994c..0e912b0 100644 --- a/experiments/build_network.py +++ b/experiments/build_network.py @@ -14,12 +14,12 @@ def build_network(filename): from_, to = int(float(row["from"])), int(float(row["to"])) dist = int(row["dist"]) w1, w2, w3 = float(row["w1"]), float(row["w2"]), float(row["w3"]) - if int(float(row["dist"])) > 1: - continue + # if int(float(row["dist"])) > 1: + # continue # 'to' is a victim if row["t2"] != "NA": dt = int(row["t2"]) - int(row["t1"]) - parent = (dist, dt, w1, w2, w3) + parent = (from_, dist, dt, w1, w2, w3) if to not in victims: age += int(row["t2"]) - int(row["spawn2"]) victims[to] = [] @@ -29,8 +29,8 @@ def build_network(filename): victims[from_] = [] # 'to' is not a victim else: - dt = 3012 - int(row["t1"]) - parent = (dist, dt, w1, w2, w3) + dt = 1000 - int(row["t1"]) + parent = (from_, dist, dt, w1, w2, w3) if to not in non_victims: # age += 3012 - int(row["spawn2"]) non_victims[to] = [] @@ -39,13 +39,14 @@ def build_network(filename): age += int(row["t1"]) - int(row["spawn1"]) victims[from_] = [] root_victims = {} - # print victims.keys() + print sorted(victims.keys()) + # print victims for victim in victims.keys(): if not victims[victim]: del victims[victim] root_victims[victim] = [] - # print root_victims.keys() - # print len(root_victims), len(victims), len(non_victims) + print sorted(root_victims.keys()) + print len(root_victims), len(victims), len(non_victims) return root_victims, victims, non_victims, age |
