#subs=['S1','S2','S3','S4','S5','S7','S8','S9','S10','S11','S12','S13'] toydata=rw.Toydata({ 'numx': 3, 'trim': 1, 'jump': 0.0, 'jumptype': "stationary", 'priming': 0.0, 'startX': "stationary"}) fitinfo=rw.Fitinfo({ 'startGraph': "windowgraph_valid", 'windowgraph_size': 2, 'windowgraph_threshold': 2, 'followtype': "avg", 'prior_samplesize': 10000, 'recorddir': "records/", 'directed': True, 'prune_limit': np.inf, 'triangle_limit': np.inf, 'other_limit': np.inf}) toygraphs=rw.Toygraphs({ 'numgraphs': 1, 'graphtype': "steyvers", 'numnodes': 280, 'numlinks': 6, 'prob_rewire': .3}) irts=rw.Irts({ 'data': [],
def network_properties(command): subj_props = command['data_parameters'] command = command['network_parameters'] Xs, items, irts, numnodes = rw.readX(subj_props['subject'], subj_props['category'], subj_props['fullpath']) def no_persev(x): seen = set() seen_add = seen.add return [i for i in x if not (i in seen or seen_add(i))] toydata = rw.Data({ 'numx': len(Xs), 'trim': 1, 'jump': 0.0, 'jumptype': "stationary", 'priming': 0.0, 'startX': "stationary" }) fitinfo = rw.Fitinfo({ 'startGraph': "goni_valid", 'goni_size': 2, 'goni_threshold': 2, 'followtype': "avg", 'prior_samplesize': 10000, 'recorddir': "records/", 'prune_limit': 100, 'triangle_limit': 100, 'other_limit': 100 }) if command['network_method'] == "RW": bestgraph = rw.noHidden(Xs, numnodes) elif command['network_method'] == "Goni": bestgraph = rw.goni(Xs, numnodes, td=toydata, valid=0, fitinfo=fitinfo) elif command['network_method'] == "U-INVITE": no_persev_Xs = [no_persev(x) for x in Xs ] # U-INVITE doesn't work with perseverations bestgraph, ll = rw.uinvite(no_persev_Xs, toydata, numnodes, fitinfo=fitinfo, debug=False) nxg = nx.to_networkx_graph(bestgraph) node_degree = np.mean(nxg.degree().values()) nxg_json = jsonGraph(nxg, items) clustering_coefficient = nx.average_clustering(nxg) try: aspl = nx.average_shortest_path_length(nxg) except: aspl = "disjointed graph" return { "type": "network_properties", "node_degree": node_degree, "clustering_coefficient": clustering_coefficient, "aspl": aspl, "graph": nxg_json }
usf_numnodes = len(usf_items) numsubs = 50 numlists = 3 listlength = 35 numsims = 1 #methods=['rw','goni','chan','kenett','fe'] methods = ['uinvite'] toydata = rw.Data({'numx': numlists, 'trim': listlength}) fitinfo = rw.Fitinfo({ 'startGraph': "goni_valid", 'goni_size': 2, 'goni_threshold': 2, 'followtype': "avg", 'prune_limit': np.inf, 'triangle_limit': np.inf, 'other_limit': np.inf }) #toygraphs=rw.Graphs({ # 'numgraphs': 1, # 'graphtype': "steyvers", # 'numnodes': 280, # 'numlinks': 6, # 'prob_rewire': .3}) # generate data for `numsub` participants, each having `numlists` lists of `listlengths` items seednum = 0 # seednum=150 (numsubs*numlists) means start at second sim, etc.
import rw toydata = rw.Toydata({ 'numx': range(250, 251), 'priming': 0.3, 'jump': 0.0, 'trim': 0.7, 'jumptype': "stationary", 'startX': "stationary" }) fitinfo = rw.Fitinfo({ 'startGraph': "windowgraph_valid", 'followtype': "avg", 'record': False, 'recorddir': "records/", 'prune_limit': 100, 'triangle_limit': 100, 'other_limit': 100 }) toygraph = rw.Toygraphs({ 'graphtype': "steyvers", 'numnodes': 50, 'numlinks': 6 }) fh = open('priming_test.csv', 'w') seed = 15
'jump': 0.0, 'jumptype': "uniform", 'startX': "uniform" }) irts = rw.Irts({ 'data': [], 'irttype': "gamma", 'beta': (1 / 1.1), 'irt_weight': 0.9, 'rcutoff': 20 }) fitinfo = rw.Fitinfo({ 'tolerance': 1500, 'startGraph': "naiverw", 'prob_multi': 1.0, 'prob_overlap': 0.5 }) x_seed = 1 graph_seed = 1 td = toydata[0] g, a = rw.genG(toygraphs, seed=graph_seed) [Xs, irts.data] = zip(*[rw.genX(g, td, seed=x_seed + i) for i in range(td.numx)]) Xs = list(Xs) irts.data = list(irts.data) [Xs, irts.data, alter_graph] = rw.trimX(td.trim, Xs, irts.data) # trim data when necessary
toydata = rw.Toydata({ 'numx': 3, 'trim': 1, 'jump': 0.0, 'jumptype': "stationary", 'priming': 0.0, 'startX': "stationary" }) fitinfo = rw.Fitinfo({ 'startGraph': "goni_valid", 'goni_size': 2, 'goni_threshold': 2, 'followtype': "avg", 'prior_samplesize': 10000, 'prior_a': 1, 'prior_b': 1, 'recorddir': "records/", 'directed': False, 'prune_limit': np.inf, 'triangle_limit': np.inf, 'other_limit': np.inf }) toygraphs = rw.Toygraphs({ 'numgraphs': 1, 'graphtype': "steyvers", 'numnodes': 280, 'numlinks': 6, 'prob_rewire': .3 })