From f94bf128133f8dc3adaa81282ed7ce54b55dd528 Mon Sep 17 00:00:00 2001 From: jeanpouget-abadie Date: Fri, 6 Feb 2015 10:48:51 -0500 Subject: changing figures --- src/make_plots.py | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/make_plots.py b/src/make_plots.py index 840cc94..c5a50f6 100644 --- a/src/make_plots.py +++ b/src/make_plots.py @@ -28,7 +28,7 @@ def compare_greedy_and_lagrange_cs284r(): def compute_graph(graph_name, n_cascades, lbda, passed_function, min_proba, - max_proba, sparse_edges=False): + max_proba, sparse_edges=False, p_init=.05): """ Test running time on different algorithms """ @@ -36,7 +36,7 @@ def compute_graph(graph_name, n_cascades, lbda, passed_function, min_proba, min_proba=min_proba, sparse_edges=sparse_edges) G.import_from_file(graph_name) - A = cascade_creation.generate_cascades(G, p_init=.05, n_cascades=n_cascades) + A = cascade_creation.generate_cascades(G, p_init=p_init, n_cascades=n_cascades) if passed_function==algorithms.greedy_prediction: G_hat = algorithms.greedy_prediction(G, A) @@ -184,6 +184,7 @@ def plot_ROC_curve(figure_name): plt.xlabel("Recall") plt.ylabel("Precision") plt.grid(color="lightgrey") + ax.plot(recall_lasso_200, precision_lasso_200, 'ko-', color="lightseagreen", label="Lasso-200 cascades") ax.plot(recall_sparse_200, precision_sparse_200, 'ko-', @@ -196,14 +197,43 @@ def plot_ROC_curve(figure_name): plt.savefig("../paper/figures/"+"ROC_curve.pdf") +def plot_kronecker_l2norm_nonsparse(): + plt.clf() + fig = plt.figure(1) + x = [.01, .05, .1, .15, .2] + greedy = [.43, .29, .18, .1, .08] + sparse_recov = [.7, .58, .48, .39, .31] + max_likel = [.69, .56, .45, .37, .3] + lasso = [.66, .55, .46, .38, .3] + + fig, ax = plt.subplots() + + #plt.subplots_adjust(bottom=.2, top=.85) + #plt.xticks(ha="right", rotation=45) + + #plt.axis((50, 2000, 0, 145)) + plt.xlabel("Number of Cascades") + plt.ylabel("l2-norm") + plt.grid(color="lightgrey") + ax.plot(x, greedy, 'ko-', color="lightseagreen", label='Greedy') + ax.plot(x, lasso, 'ko-', color="orange", label="Lasso") + ax.plot(x, max_likel, 'ko-', color="cornflowerblue", label="MLE") + ax.plot(x, sparse_recov, 'ko-', color="k", label="Our Method") + plt.legend(loc="upper right") + ax.set_xticks(x) + ax.set_xticklabels(tuple(x)) + plt.savefig("../paper/figures/"+"watts_strogatz_p_init.pdf") + + + if __name__=="__main__": if 1: compute_graph("../datasets/watts_strogatz_300_30_point3.txt", - n_cascades=300, lbda=.01, min_proba=.2, max_proba=.7, + n_cascades=300, lbda=.013382, min_proba=.2, max_proba=.7, passed_function= #convex_optimization.sparse_recovery) - #algorithms.greedy_prediction) - convex_optimization.sparse_recovery, p_init=.15) + algorithms.greedy_prediction, p_init=.2) + #convex_optimization.sparse_recovery, p_init=.15) if 0: compute_graph("../datasets/powerlaw_200_30_point3.txt", n_cascades=200, lbda=.01, min_proba=.2, max_proba=.7, -- cgit v1.2.3-70-g09d2