Пример #1
0
        graph_label[i, 0] -= 1

#===========================================================================
# COMPUTE PROPAGATION KERNELS
#===========================================================================
num_Iteration = 10
w = 1e-4
dist = 'tv'  # possible values: 'tv', 'hellinger'
np.random.seed(
    1
)  # set random seed to get reproducible kernel matrices (to account for randomness in kernel average resutls over several returns of the experiment)
K = graphKernels.propagationKernel(A,
                                   node_label,
                                   gr_id,
                                   num_Iteration,
                                   w,
                                   dist,
                                   'label_diffusion',
                                   SUM=True,
                                   VIS=False,
                                   showEachStep=False)

#----------------------------------------------------------------------
# Cross Validation
#----------------------------------------------------------------------
print '...GP prediction (10-fold CV)'

for t in xrange(num_Iteration + 1):
    ACC = []  # accuracy

    print 'number of kernel iterations =', t
    Matrix = K[:, :, t]
Пример #2
0
graph_label = data['labels']                          # N x 1 graph label array
N = graph_label.shape[0]                              # number of graphs)

graph_label = np.int8(graph_label)
for i in range(N):
    if graph_label[i,0] == 0:
        graph_label[i,0] -= 1

#===========================================================================
# COMPUTE PROPAGATION KERNELS
#===========================================================================
num_Iteration = 10
w = 1e-4
dist = 'tv'         # possible values: 'tv', 'hellinger'
np.random.seed(1)    # set random seed to get reproducible kernel matrices (to account for randomness in kernel average resutls over several returns of the experiment)    
K = graphKernels.propagationKernel(A, node_label, gr_id, num_Iteration, w, dist, 'label_diffusion', SUM=True, VIS=False, showEachStep=False) 

#----------------------------------------------------------------------
# Cross Validation
#----------------------------------------------------------------------
print('...GP prediction (10-fold CV)')

for t in range(num_Iteration+1):
    ACC = []           # accuracy
    
    print('number of kernel iterations =', t)
    Matrix = K[:,:,t]
    # normalize kernel matrix (not useful for MUTAG)
    # Matrix = graphUtil.normalizeKernel(Matrix)
            
    # start cross-validation for this t