diff options
| author | jeanpouget-abadie <jean.pougetabadie@gmail.com> | 2015-02-03 16:06:07 -0500 |
|---|---|---|
| committer | jeanpouget-abadie <jean.pougetabadie@gmail.com> | 2015-02-03 16:06:07 -0500 |
| commit | 8f65bdb15bf7a76ba0a07836644731d098c15d03 (patch) | |
| tree | 1361b4a038d966432a282adcd5c89fcb365b8011 /src | |
| parent | a9125f9e7c23063e42eeaceead8c8014686c6427 (diff) | |
| download | cascades-8f65bdb15bf7a76ba0a07836644731d098c15d03.tar.gz | |
changes for runnning functions
Diffstat (limited to 'src')
| -rw-r--r-- | src/algorithms.py | 2 | ||||
| -rw-r--r-- | src/cascade_creation.py | 3 | ||||
| -rw-r--r-- | src/convex_optimization.py | 6 | ||||
| -rw-r--r-- | src/make_plots.py | 16 |
4 files changed, 20 insertions, 7 deletions
diff --git a/src/algorithms.py b/src/algorithms.py index 9f6d3ea..fb0a37d 100644 --- a/src/algorithms.py +++ b/src/algorithms.py @@ -54,7 +54,7 @@ def recovery_passed_function(G, cascades, floor_cstt, passed_function, return G_hat -def correctness_measure(G, G_hat, print_values=False): +def correctness_measure(G, G_hat, print_values=True): """ Measures correctness of estimated graph G_hat to ground truth G """ diff --git a/src/cascade_creation.py b/src/cascade_creation.py index c297f76..df0384e 100644 --- a/src/cascade_creation.py +++ b/src/cascade_creation.py @@ -25,8 +25,8 @@ class InfluenceGraph(nx.DiGraph): p : proba of rewiring edge """ G = nx.connected_watts_strogatz_graph(n, k, p) - G = nx.convert_to_directed(G) self.add_edges_from(G.edges()) + self.add_edges_from([(node_2, node_1) for node_1, node_2 in G.edges()]) def import_from_file(self, file_name): """ @@ -153,7 +153,6 @@ def add_edges_from_proba_vector(G, p_node, node, floor_cstt): Also updates G's mat matrix """ floor_parent = np.nonzero(p_node*(p_node > floor_cstt)) - print(floor_parent) for parent in floor_parent[0]: G.add_edge(parent, node) #TODO: update G's mat matrix diff --git a/src/convex_optimization.py b/src/convex_optimization.py index f283d6b..f4c997a 100644 --- a/src/convex_optimization.py +++ b/src/convex_optimization.py @@ -80,7 +80,7 @@ def type_lasso(lbda): return f_x, f_xz -@timeout.timeout(8) +@timeout.timeout(30) def diff_and_opt(M_val, w_val, f_x, f_xz): if M_val.dtype == bool: @@ -90,7 +90,7 @@ def diff_and_opt(M_val, w_val, f_x, f_xz): def F(x=None, z=None): if x is None: - return 0, cvxopt.matrix(-.001, (n,1)) + return 0, cvxopt.matrix(-.0001, (n,1)) elif z is None: y, y_diff = f_x(x, M_val, w_val) return cvxopt.matrix(float(y), (1, 1)),\ @@ -108,7 +108,7 @@ def diff_and_opt(M_val, w_val, f_x, f_xz): #cvxopt.solvers.options['feastol'] = 2e-5 #cvxopt.solvers.options['abstol'] = 2e-5 #cvxopt.solvers.options['maxiters'] = 100 - cvxopt.solvers.options['show_progress'] = False + cvxopt.solvers.options['show_progress'] = True try: theta = cvxopt.solvers.cp(F, G, h)['x'] except ArithmeticError: diff --git a/src/make_plots.py b/src/make_plots.py index bfe78f8..18864d3 100644 --- a/src/make_plots.py +++ b/src/make_plots.py @@ -27,6 +27,19 @@ def compare_greedy_and_lagrange_cs284r(): algorithms.correctness_measure(G, G_hat, print_values=True) +def watts_strogatz(n_cascades, lbda, passed_function): + """ + Test running time on different algorithms + """ + G = cascade_creation.InfluenceGraph(max_proba=1, min_proba=.2) + G.import_from_file("../datasets/watts_strogatz_500_80_point3.txt") + A = cascade_creation.generate_cascades(G, p_init=.05, n_cascades=n_cascades) + + G_hat = algorithms.recovery_passed_function(G, A, + passed_function=passed_function, + floor_cstt=.1, lbda=lbda, n_cascades=1000) + + def test(): """ unit test @@ -41,4 +54,5 @@ def test(): if __name__=="__main__": - test() + watts_strogatz(n_cascades=1000, lbda=.001, passed_function= + convex_optimization.sparse_recovery) |
