import networkx
import math
import scipy.optimize
import numpy
from lib.time_graph import *
from lib.vis import *
from lib.syn import *
from lib.io import *
from lib.datasets import *
from lib.time_graph import *
from lib.experiments import *
from IPython.display import Image
algos = [TemporalCuts("FSTC-16", "fast-sparse", eps=1e-5, k=16),
TemporalCuts("FSTC-64", "fast-sparse", eps=1e-5, k=64),
TemporalCuts("STC", "diff-sparse"),
TemporalCuts("LAP", "laplacian-sparse"),
TemporalCuts("UNION", "union-sparse"),
TemporalCuts("SINGLE", "indep-sparse")]
grid = slide_diagonal_grids(10, 5, 10.)
grid = add_gaussian_noise(grid, 2.8)
G, values = time_graph_from_grid(grid, 2)
swap_costs = numpy.array([0., .5, 1., 1.5, 2.])
#swap_costs = numpy.array([0.]) * math.exp(2.)
res = sparsity_experiments(G, algos, swap_costs, 10)
output_file_name = "figs/syn_sparsity.png"
plot_sparsity_experiments(res, algos, swap_costs, output_file_name, 0, 600, 1e-4, 1e-1)
Image(filename=output_file_name)
algos = [TemporalCuts("FSTC-16", "fast-norm", eps=1e-5, k=16),
TemporalCuts("FSTC-64", "fast-norm", eps=1e-5, k=64),
TemporalCuts("STC", "diff-norm"),
TemporalCuts("LAP", "laplacian-norm"),
TemporalCuts("UNION", "union-norm"),
TemporalCuts("SINGLE", "indep-norm")]
grid = grow_diagonal_grids(10, 5, 10.)
grid = add_gaussian_noise(grid, 2.8)
G, values = time_graph_from_grid(grid, 2)
swap_costs = numpy.array([0., .5, 1., 1.5, 2.0])
#swap_costs = numpy.array([0.]) * math.exp(2.)
res = sparsity_experiments(G, algos, swap_costs, 10)
output_file_name = "figs/syn_norm_sparsity.png"
plot_sparsity_experiments(res, algos, swap_costs, output_file_name, 0, 600, 1e-5, 1e-2)
Image(filename=output_file_name)
algos = [TemporalCuts("FSTC-16", "fast-sparse", eps=1e-5, k=16),
TemporalCuts("FSTC-64", "fast-sparse", eps=1e-5, k=64),
TemporalCuts("STC", "diff-sparse", eps=0.),
TemporalCuts("LAP", "laplacian-sparse"),
TemporalCuts("UNION", "union-sparse"),
TemporalCuts("SINGLE", "indep-sparse")]
swap_costs = numpy.array([0., 0.01, .02, 0.03, .04])
#swap_costs = numpy.array([0.]) * math.exp(2.)
G = read_time_graph(primary_school["graph"], .1)
res = sparsity_experiments(G, algos, swap_costs, 10)
/usr/local/lib/python3.6/dist-packages/numpy/core/numeric.py:538: ComplexWarning: Casting complex values to real discards the imaginary part return array(a, dtype, copy=False, order=order) ERROR:root:Internal Python error in the inspect module. Below is the traceback from this internal error. KeyboardInterrupt
output_file_name = "figs/school_sparsity.png"
plot_sparsity_experiments(res, algos, swap_costs, output_file_name, 0, 600, 1e-6, 1e-3)
Image(filename=output_file_name)
algos = [TemporalCuts("FSTC-16", "fast-norm", eps=1e-5, k=16),
TemporalCuts("FSTC-64", "fast-norm", eps=1e-5, k=64),
TemporalCuts("STC", "diff-norm", eps=0.),
TemporalCuts("LAP", "laplacian-norm"),
TemporalCuts("UNION", "union-norm"),
TemporalCuts("SINGLE", "indep-norm")]
swap_costs = numpy.array([0., 0.01, .02, 0.03, .04])
#swap_costs = numpy.array([0.]) * math.exp(2.)
G = read_time_graph(primary_school["graph"], .1)
res2 = sparsity_experiments(G, algos, swap_costs, 10)
output_file_name = "figs/school_norm_sparsity.png"
plot_sparsity_experiments(res, algos, swap_costs, output_file_name, 0, 600, 1e-4, 2e-1)
Image(filename=output_file_name)
res
[[{'sparsity': 0.00010241654674475139, 'time': 6.538489818572998}, {'sparsity': 0.00010582485740925848, 'time': 11.494817018508911}], [{'sparsity': 6.6736857885161909e-05, 'time': 40.719489336013794}, {'sparsity': 7.8907975117481751e-05, 'time': 132.10709691047668}], [{'sparsity': 0.00010611961232560125, 'time': 40.53948187828064}, {'sparsity': 0.00011545379295257346, 'time': 137.88838601112366}], [{'sparsity': 0.00014976361257238095, 'time': 36.939737558364868}, {'sparsity': 0.0001513597780593675, 'time': 132.25599908828735}], [{'sparsity': 0.00019466883765824252, 'time': 32.860485553741455}, {'sparsity': 0.00018484176952833506, 'time': 126.84684538841248}]]
algos = [TemporalCuts("FSTC-16", "fast-sparse", eps=1e-5, k=16),
TemporalCuts("FSTC-64", "fast-sparse", eps=1e-5, k=64),
TemporalCuts("STC", "diff-sparse", eps=2e-5),
TemporalCuts("LAP", "laplacian-sparse"),
TemporalCuts("UNION", "union-sparse"),
TemporalCuts("SINGLE", "indep-sparse")]
swap_costs = numpy.array([0., 0.1, 0.2, 0.3, 0.4])
G = read_time_graph(stock["graph"], .1)
res = sparsity_experiments(G, algos, swap_costs, 10)
output_file_name = "figs/stock_sparsity.png"
plot_sparsity_experiments(res, algos, [0., 0.1, 0.2, 0.3, 0.4], output_file_name, 0, 600, 1e-6,6e-3)
Image(filename=output_file_name)
res
[[{'sparsity': 7.2142470271865315e-05, 'time': 3.7352564334869385}, {'sparsity': 0.00010241654674475139, 'time': 6.9934237003326416}, {'sparsity': 0.0, 'time': 34.622586727142334}, {'sparsity': -5.1024842940552675e-23, 'time': 36.042699098587036}, {'sparsity': 1.1982585451096368e-05, 'time': 0.34286141395568848}, {'sparsity': 0.0, 'time': 5.5506081581115723}]]
algos = [TemporalCuts("FSTC-16", "fast-norm", eps=1e-5, k=16),
TemporalCuts("FSTC-64", "fast-norm", eps=1e-5, k=64),
TemporalCuts("STC", "diff-norm", eps=2e-5),
TemporalCuts("LAP", "laplacian-norm"),
TemporalCuts("UNION", "union-norm"),
TemporalCuts("SINGLE", "indep-norm")]
swap_costs = numpy.array([0., 0.1, 0.2, 0.3, 0.4])
#swap_costs = numpy.array([0.]) * math.exp(2.)
G = read_time_graph(stock["graph"], .1)
res2 = sparsity_experiments(G, algos, swap_costs, 10)
output_file_name = "figs/stock_norm_sparsity.png"
plot_sparsity_experiments(res2, algos, [0., 0.1, 0.2, 0.3, 0.4], output_file_name, 0, 600, 1e-4, 2)
Image(filename=output_file_name)
algos = [TemporalCuts("FSTC-16", "fast-sparse", eps=1e-5, k=16),
TemporalCuts("FSTC-64", "fast-sparse", eps=1e-5, k=64),
TemporalCuts("UNION", "union-sparse"),
TemporalCuts("SINGLE", "indep-sparse")]
#algos = [TemporalCuts("FSTC-10", "fast-sparse", eps=1e-5, k=10)]
swap_costs = numpy.array([0., .002, .004, .006, .008])
G = read_time_graph(dblp["graph"], .1)
res = sparsity_experiments(G, algos, swap_costs, 10)
res
output_file_name = "figs/dblp_sparsity.png"
plot_sparsity_experiments(res, algos, [0., .02, .04, .06, .08], output_file_name, 0, 600, 1e-7, 1e-4)
Image(filename=output_file_name)