Am 30.11.18 um 07:22 schrieb ashutosh:
Sir,
I am trying to follow the example on "edge prediction as binary classification".
Here is my code:
*import graph_tool as gt import pandas as pd*
# create a graph object in data frame format
*ndf = pd.DataFrame({'Node1':['a','b','c','d','e'],'Node2':['c','e','b','a','d'],'Weight':[0.2,0.8,0.4,0.5,0.7], 'RandProp1':[1,2,3,1,2]})
ng = gt.Graph()
nprop = ng.new_edge_property("float") ng.edge_properties['Weight'] = nprop* # important to map the properties to the graph
*LayerProp = ng.new_edge_property('float') ng.edge_properties['LayerProp'] = LayerProp*
*nvp = ng.add_edge_list(ndf.values.tolist(),hashed=True,string_vals=True,eprops=[nprop,LayerProp])*
# minimizing the graph and inferring partitions
*stateA = gt.inference.minimize_nested_blockmodel_dl(ng,layers=True, state_args=dict(ec=LayerProp,layers=True), deg_corr=True,verbose=True)* *L = 10 bs = stateA.get_bs() bs += [np.zeros(1)]*(L-len(bs))
stateB = stateA.copy(bs=bs, sampling=True) probs=([])
def collect_edge_probs(s): p = s.get_edges_prob([missing_edges[0]],entropy_args=dict(partition_dl=False)) probs[0].append(p);
missing_edges = [(1,2,1)] *# for layered network you need to specify layer number
*gt.inference.mcmc_equilibrate(stateB,force_niter=1000,mcmc_args=dict(niter=10), callback=collect_edge_probs,verbose=True)*
When I run this code, it gives me kernel died error. Please help.
This might be a bug. Please open an issue in the website with this example, and I'll take a look at it when I have the time. (Also, please do not post the same email multiple times to the mailing list. If I haven't responded the first time, it's because I did not have the chance to look into it)
I have another query that; how can we get the layer associated with the node?
In the above code when I try the command
*for i in nvp: print(i)*
I get the output as : *a,c,b,e,d*
and when I type the command
*LayerProp.a*
I get the output: *PropertyArray([ 1., 2., 3., 1., 2.])*
How do I understand that because the order of addition of nodes depends on the order they come along with add_edge_list command, while the LayerProp is added in the order as mentioned in the property map. I'm not sure I understand your question. Nodes do not belong to different layers, only the edges do.
-- Tiago de Paula Peixoto <tiago@skewed.de>