forked from xiaohan2012/controversy_detection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_simulation.py
68 lines (46 loc) · 1.49 KB
/
run_simulation.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# coding: utf-8
# In[2]:
import networkx as nx
import metis
import pickle
import pandas as pd
import random
from scipy.stats import pearsonr
from collections import defaultdict
from datetime import timedelta, datetime
from tqdm import tqdm
from joblib import Parallel, delayed
from rwc import controversy_score
from util import tw_list, get_cut_ratio, add_edges, remove_edges
from leopard import update_partition
# In[3]:
retweets = pd.read_pickle('data/july.pkl')
# In[4]:
retweets.sort_values(by=['created_at'], axis='index', inplace=True)
# In[5]:
DEBUG = False
incremental = True
update_interval = timedelta(minutes=10)
T_window = timedelta(minutes=60*12)
top_node_percent=0.01
# In[6]:
# prevent pickling error in multiprocessing
def defaultdict_using_list_func():
return defaultdict(list)
def earlist_date_func():
return datetime(1970, 1, 1)
# In[13]:
from simulation import run_simulation
# some test
result = run_simulation(retweets,
T_window=T_window,
top_node_percent=top_node_percent,
update_interval=update_interval,
incremental=True,
top_k=10,
top_k_computation_interval=timedelta(minutes=60),
min_rwc_score=0.85,
head_n=12*1e5,
return_graph=True
)
pickle.dump(result, open('output/simulation_result.pkl', 'wb'))