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. 


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. 



--
Sent from: 
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/
_______________________________________________
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool

Reply via email to