aboutsummaryrefslogtreecommitdiffstats
path: root/jpa_test/algorithms.py
diff options
context:
space:
mode:
authorjeanpouget-abadie <jean.pougetabadie@gmail.com>2014-12-01 21:14:27 -0500
committerjeanpouget-abadie <jean.pougetabadie@gmail.com>2014-12-01 21:14:27 -0500
commitf8678b1b37f9136814be0197aabf32831d0c013e (patch)
treed46e76b4b379ab9a88ad999ec124b1b93e204a79 /jpa_test/algorithms.py
parentb1a6d4397bd1dc784a68987fc645eabe2bbcc8ec (diff)
downloadcascades-f8678b1b37f9136814be0197aabf32831d0c013e.tar.gz
rip_condition
Diffstat (limited to 'jpa_test/algorithms.py')
-rw-r--r--jpa_test/algorithms.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/jpa_test/algorithms.py b/jpa_test/algorithms.py
index 76a3c51..be9caba 100644
--- a/jpa_test/algorithms.py
+++ b/jpa_test/algorithms.py
@@ -34,7 +34,7 @@ def greedy_prediction(G, cascades):
return G_hat
-def sparserecovery(G, cascades):
+def recovery_l1obj_l2constraint(G, cascades):
"""
Returns estimated graph from following convex program:
min |theta_1| + lbda | exp(M theta) -(1- w)|
@@ -44,8 +44,8 @@ def sparserecovery(G, cascades):
G_hat.add_nodes_from(G.nodes())
for node in G_hat.nodes():
M, w = cascade_creation.icc_matrixvector_for_node(cascades, node)
- M = M.astype("int8")
- edges_node = convex_optimization.l1regls(M,w)
+ M = M.astype("float64")
+ edges_node = convex_optimization.l1obj_l2constraint(M,w)
print edges_node
@@ -69,9 +69,9 @@ def test():
G.erdos_init(n = 100, p = .5)
import time
t0 = time.time()
- A = cascade_creation.generate_cascades(G, .1, 100)
+ A = cascade_creation.generate_cascades(G, .2, 2)
- sparserecovery(G, A)
+ recovery_l1obj_l2constraint(G, A)
G_hat = greedy_prediction(G, A)
fp, fn, gp = correctness_measure(G, G_hat)