Closed ljmartin closed 1 year ago
Hi @ljmartin ,
Indeed, for the graphs that are given as input to the transform()
function, the edge labels are not retained from one iteration of the WL algorithm to the next and this is why the neighborhood subgraph pairwise distance kernel function cannot be computed (since it requires edges to be annotated with discrete labels).
We will fix this bug in the new version of the package. For now, you can just use the following code:
gs = ... #networkx graphs with node labels & edge labels
graphs = [i for i in graph_from_networkx(gs,
as_Graph=False,
node_labels_tag='atomic_num',
edge_labels_tag='bond_type'
)]
kern = WeisfeilerLehman(n_iter=2, normalize=False, base_graph_kernel=NeighborhoodSubgraphPairwiseDistance)
K_full = kern.fit_transform(graphs)
K = K_full[0,1:]
Thanks for the library and for your time in reading this! Describe the bug I'm calculating kernel similarity between a reference graph and a set of 'probe' graphs, avoiding the necessity to calculate the full pairwise kernel matrix. Doing this with
kern.fit(graph[:1])
followed bykern.transform(graphs)
results in an error (below). Is this expected?To Reproduce
Expected behavior Running this with, say,
RandomWalkLabeled
gives an array of shape [1, N] that contains the 1 vs many kernel values. That's what I expected here, too.Stack Trace full output: