f = open(features, 'r') g = open(output_features, 'w') # skip csv header if configs.feature_header: f.readline() for l in f.readlines(): # convert userID to nodeID try: vec = l.strip().split(",") g.write("{} ".format(nodes[vec[0]])) g.write(" ".join(vec[1:])) g.write("\n") except: vec = l.strip().split(",") print(f"node {vec[0]} not in the graph") g.close() f.close() if __name__ == "__main__": parser = argparse.ArgumentParser( description="Parser feature file generator") parser.add_argument("--json_path", type=str, required=True, help="Path to the json config file") args = parser.parse_args() configs = load_json(args.json_path) main(dict2dotdict(configs))
if v_i == v_j: continue adj_mtx_r[v_i, v_j] = self.get_edge_weight(v_i, v_j) return adj_mtx_r def get_edge_weight(self, i, j): return np.dot(self.embedding[i, :], self.embedding[j, :]) dummy_model = _Dummy(embedding) MAP, prec_curv, err, err_baseline = gr.evaluateStaticGraphReconstruction(graph, dummy_model, embedding, None) return (MAP, prec_curv) # Change the name of the dataset dataset = "pastebin" json_path = f"./data/{dataset}/config.json" configs = load_json(json_path) configs = dict2dotdict(configs) timespells = configs.timespells graph_embeddings = {} reconstruction_performance = {} reconstruction_performance_curve = {} for ts in range(1, int(timespells)+1): f = open(f"{configs.DATA_PATH}/TS{str(ts)}/generated/graphs.pkl", 'rb') graph, graph_str = pickle.load(f) f.close() for model in configs.models: if model not in graph_embeddings.keys(): graph_embeddings[model] = {} reconstruction_performance[model] = {} reconstruction_performance_curve[model] = {}