Skip to content

Commit

Permalink
Merge pull request #23 from Sujit-O/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Sujit-O committed Aug 17, 2019
2 parents ec1fae4 + af45894 commit 98f3edc
Show file tree
Hide file tree
Showing 15 changed files with 281 additions and 602 deletions.
7 changes: 4 additions & 3 deletions docs/source/api.rst
Expand Up @@ -96,12 +96,13 @@ Metrics
.. automodule:: dynamicgem.evaluation.metrics
:members:

Standard Test
----------------
Embedding Visualization
------------------------

.. automodule:: dynamicgem.evaluation.standardTest
.. automodule:: dynamicgem.evaluation.visualize_embedding
:members:


Experiments
============

Expand Down
55 changes: 55 additions & 0 deletions dynamicgem/experiments/exp.py
Expand Up @@ -27,6 +27,18 @@


def learn_emb(MethObj, graphs, params, res_pre, m_summ):
"""Function to learn embedding
Attributes:
MethObj (obj): Object of the algorithm class
graphs (Object): Networkx Graph Object
params (dict): Dictionary of parameters necessary for running the experiment
res_pre (str): Prefix of the filename for saving the result.
m_summ (str): summary added to the filename of the result.
Returns:
ndarray: Learned embedding
"""
if params["experiments"] == ["lp"]:
X = None
else:
Expand Down Expand Up @@ -57,6 +69,19 @@ def learn_emb(MethObj, graphs, params, res_pre, m_summ):


def run_exps(MethObj, meth, dim, graphs, data_set, params):
"""Function to run the experiment
Attributes:
MethObj (obj): Object of the algorithm class
meth (str): Name of the method
dim (int): Dimension of the embedding
graphs (Object): Networkx Graph Object
data_set (str): Name of the dataset to be used for the experiment
params (dict): Dictionary of parameters necessary for running the experiment
Returns:
ndarray: Learned embedding
"""
m_summ = '%s_%d' % (meth, dim)
res_pre = "results/%s" % data_set
n_r = params["rounds"]
Expand Down Expand Up @@ -87,13 +112,22 @@ def run_exps(MethObj, meth, dim, graphs, data_set, params):


def get_max(val, val_max, idx, idx_max):
"""Function to get the maximum value."""
if val > val_max:
return val, idx
else:
return val_max, idx_max


def choose_best_hyp(data_set, graphs, params):
"""Function to get the best hyperparameter using a grid search
Attributes:
data_set (str): Name of the dataset to be used for the experiment
graphs (Object): Networkx Graph Object
params (dict): Dictionary of parameters necessary for running the experiment
"""
# Load range of hyper parameters to test on
try:
model_hyp_range = json.load(
Expand Down Expand Up @@ -180,6 +214,13 @@ def choose_best_hyp(data_set, graphs, params):


def call_plot_hyp(data_set, params):
"""Function to plot the result of hyperparameter search
Attributes:
data_set (str): Name of the dataset to be used for the experiment
params (dict): Dictionary of parameters necessary for running the experiment
"""
# Load range of hyper parameters tested on to plot
try:
model_hyp_range = json.load(
Expand All @@ -198,6 +239,13 @@ def call_plot_hyp(data_set, params):


def call_plot_hyp_all(data_sets, params):
"""Function to plot the the result of all the hyper-parameters
Attributes:
data_set (str): Name of the dataset to be used for the experiment
params (dict): Dictionary of parameters necessary for running the experiment
"""
# Load range of hyper parameters tested on to plot
try:
model_hyp_range = json.load(
Expand All @@ -216,7 +264,14 @@ def call_plot_hyp_all(data_sets, params):


def call_exps(params, data_set, n_graphs):
"""Function to run the experiments
Attributes:
n_graphs (int): Total number of graphs in a sequence.
data_set (str): Name of the dataset to be used for the experiment
params (dict): Dictionary of parameters necessary for running the experiment
"""
# Load Dataset
print('Dataset: %s' % data_set)
if data_set == "sbm":
Expand Down
20 changes: 0 additions & 20 deletions dynamicgem/graph_generation/README.md

This file was deleted.

2 changes: 0 additions & 2 deletions dynamicgem/graph_generation/SBM_graph.py
Expand Up @@ -3,8 +3,6 @@
import numpy as np
import networkx as nx
import operator
import sys
sys.path.append('./')
from dynamicgem.utils import graph_util
import random

Expand Down
2 changes: 1 addition & 1 deletion dynamicgem/graph_generation/SBM_node_migration.py
Expand Up @@ -4,7 +4,7 @@
import random
import networkx as nx
import operator
import SBM_graph
import dynamicgem.graph_generation.SBM_graph

function_mapping = {'degree': nx.degree_centrality,
'eigenvector': nx.eigenvector_centrality,
Expand Down
3 changes: 0 additions & 3 deletions dynamicgem/graph_generation/createHepTHCollabNet_nx.py
Expand Up @@ -4,9 +4,6 @@
import pdb
import pickle

import sys
sys.path.append('./')

DATA_DIR = 'data/real/hep-th/abs'
folder_names = os.listdir(DATA_DIR)

Expand Down
1 change: 0 additions & 1 deletion dynamicgem/graph_generation/dynamic_SBM_graph.py
Expand Up @@ -5,7 +5,6 @@
import operator
import sys

sys.path.append('./')
from dynamicgem.graph_generation import SBM_graph
from dynamicgem.utils import graph_util

Expand Down

0 comments on commit 98f3edc

Please sign in to comment.